Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

462 lines
11 KiB

  1. // ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!!
  2. // $MULTITEXTURE && $BASETEXTURE
  3. // $SIMPLEOVERLAY && $BASETEXTURE
  4. // $SIMPLEOVERLAY && !$FLOWMAP
  5. // $FLOWMAP && $MULTITEXTURE
  6. // ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 )
  7. // ( $FLASHLIGHT || $LIGHTMAPWATERFOG ) && ( ( $BASETEXTURE && !$FLOWMAP ) || $MULTITEXTURE )
  8. // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA
  9. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT
  10. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST
  11. // defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH
  12. // ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW
  13. // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA
  14. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT
  15. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST
  16. // defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH
  17. // ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW
  18. // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA
  19. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT
  20. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST
  21. // defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH
  22. // ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW
  23. #include "shaderlib/cshader.h"
  24. class water_ps20b_Static_Index
  25. {
  26. private:
  27. int m_nBASETEXTURE;
  28. #ifdef _DEBUG
  29. bool m_bBASETEXTURE;
  30. #endif
  31. public:
  32. void SetBASETEXTURE( int i )
  33. {
  34. Assert( i >= 0 && i <= 1 );
  35. m_nBASETEXTURE = i;
  36. #ifdef _DEBUG
  37. m_bBASETEXTURE = true;
  38. #endif
  39. }
  40. void SetBASETEXTURE( bool i )
  41. {
  42. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  43. m_nBASETEXTURE = i ? 1 : 0;
  44. #ifdef _DEBUG
  45. m_bBASETEXTURE = true;
  46. #endif
  47. }
  48. private:
  49. int m_nMULTITEXTURE;
  50. #ifdef _DEBUG
  51. bool m_bMULTITEXTURE;
  52. #endif
  53. public:
  54. void SetMULTITEXTURE( int i )
  55. {
  56. Assert( i >= 0 && i <= 1 );
  57. m_nMULTITEXTURE = i;
  58. #ifdef _DEBUG
  59. m_bMULTITEXTURE = true;
  60. #endif
  61. }
  62. void SetMULTITEXTURE( bool i )
  63. {
  64. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  65. m_nMULTITEXTURE = i ? 1 : 0;
  66. #ifdef _DEBUG
  67. m_bMULTITEXTURE = true;
  68. #endif
  69. }
  70. private:
  71. int m_nREFLECT;
  72. #ifdef _DEBUG
  73. bool m_bREFLECT;
  74. #endif
  75. public:
  76. void SetREFLECT( int i )
  77. {
  78. Assert( i >= 0 && i <= 1 );
  79. m_nREFLECT = i;
  80. #ifdef _DEBUG
  81. m_bREFLECT = true;
  82. #endif
  83. }
  84. void SetREFLECT( bool i )
  85. {
  86. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  87. m_nREFLECT = i ? 1 : 0;
  88. #ifdef _DEBUG
  89. m_bREFLECT = true;
  90. #endif
  91. }
  92. private:
  93. int m_nREFRACT;
  94. #ifdef _DEBUG
  95. bool m_bREFRACT;
  96. #endif
  97. public:
  98. void SetREFRACT( int i )
  99. {
  100. Assert( i >= 0 && i <= 1 );
  101. m_nREFRACT = i;
  102. #ifdef _DEBUG
  103. m_bREFRACT = true;
  104. #endif
  105. }
  106. void SetREFRACT( bool i )
  107. {
  108. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  109. m_nREFRACT = i ? 1 : 0;
  110. #ifdef _DEBUG
  111. m_bREFRACT = true;
  112. #endif
  113. }
  114. private:
  115. int m_nABOVEWATER;
  116. #ifdef _DEBUG
  117. bool m_bABOVEWATER;
  118. #endif
  119. public:
  120. void SetABOVEWATER( int i )
  121. {
  122. Assert( i >= 0 && i <= 1 );
  123. m_nABOVEWATER = i;
  124. #ifdef _DEBUG
  125. m_bABOVEWATER = true;
  126. #endif
  127. }
  128. void SetABOVEWATER( bool i )
  129. {
  130. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  131. m_nABOVEWATER = i ? 1 : 0;
  132. #ifdef _DEBUG
  133. m_bABOVEWATER = true;
  134. #endif
  135. }
  136. private:
  137. int m_nFLOWMAP;
  138. #ifdef _DEBUG
  139. bool m_bFLOWMAP;
  140. #endif
  141. public:
  142. void SetFLOWMAP( int i )
  143. {
  144. Assert( i >= 0 && i <= 1 );
  145. m_nFLOWMAP = i;
  146. #ifdef _DEBUG
  147. m_bFLOWMAP = true;
  148. #endif
  149. }
  150. void SetFLOWMAP( bool i )
  151. {
  152. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  153. m_nFLOWMAP = i ? 1 : 0;
  154. #ifdef _DEBUG
  155. m_bFLOWMAP = true;
  156. #endif
  157. }
  158. private:
  159. int m_nFLOW_DEBUG;
  160. #ifdef _DEBUG
  161. bool m_bFLOW_DEBUG;
  162. #endif
  163. public:
  164. void SetFLOW_DEBUG( int i )
  165. {
  166. Assert( i >= 0 && i <= 2 );
  167. m_nFLOW_DEBUG = i;
  168. #ifdef _DEBUG
  169. m_bFLOW_DEBUG = true;
  170. #endif
  171. }
  172. void SetFLOW_DEBUG( bool i )
  173. {
  174. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 2 );
  175. m_nFLOW_DEBUG = i ? 1 : 0;
  176. #ifdef _DEBUG
  177. m_bFLOW_DEBUG = true;
  178. #endif
  179. }
  180. private:
  181. int m_nFLASHLIGHT;
  182. #ifdef _DEBUG
  183. bool m_bFLASHLIGHT;
  184. #endif
  185. public:
  186. void SetFLASHLIGHT( int i )
  187. {
  188. Assert( i >= 0 && i <= 1 );
  189. m_nFLASHLIGHT = i;
  190. #ifdef _DEBUG
  191. m_bFLASHLIGHT = true;
  192. #endif
  193. }
  194. void SetFLASHLIGHT( bool i )
  195. {
  196. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  197. m_nFLASHLIGHT = i ? 1 : 0;
  198. #ifdef _DEBUG
  199. m_bFLASHLIGHT = true;
  200. #endif
  201. }
  202. private:
  203. int m_nLIGHTMAPWATERFOG;
  204. #ifdef _DEBUG
  205. bool m_bLIGHTMAPWATERFOG;
  206. #endif
  207. public:
  208. void SetLIGHTMAPWATERFOG( int i )
  209. {
  210. Assert( i >= 0 && i <= 1 );
  211. m_nLIGHTMAPWATERFOG = i;
  212. #ifdef _DEBUG
  213. m_bLIGHTMAPWATERFOG = true;
  214. #endif
  215. }
  216. void SetLIGHTMAPWATERFOG( bool i )
  217. {
  218. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  219. m_nLIGHTMAPWATERFOG = i ? 1 : 0;
  220. #ifdef _DEBUG
  221. m_bLIGHTMAPWATERFOG = true;
  222. #endif
  223. }
  224. private:
  225. int m_nFORCEFRESNEL;
  226. #ifdef _DEBUG
  227. bool m_bFORCEFRESNEL;
  228. #endif
  229. public:
  230. void SetFORCEFRESNEL( int i )
  231. {
  232. Assert( i >= 0 && i <= 1 );
  233. m_nFORCEFRESNEL = i;
  234. #ifdef _DEBUG
  235. m_bFORCEFRESNEL = true;
  236. #endif
  237. }
  238. void SetFORCEFRESNEL( bool i )
  239. {
  240. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  241. m_nFORCEFRESNEL = i ? 1 : 0;
  242. #ifdef _DEBUG
  243. m_bFORCEFRESNEL = true;
  244. #endif
  245. }
  246. private:
  247. int m_nSIMPLEOVERLAY;
  248. #ifdef _DEBUG
  249. bool m_bSIMPLEOVERLAY;
  250. #endif
  251. public:
  252. void SetSIMPLEOVERLAY( int i )
  253. {
  254. Assert( i >= 0 && i <= 1 );
  255. m_nSIMPLEOVERLAY = i;
  256. #ifdef _DEBUG
  257. m_bSIMPLEOVERLAY = true;
  258. #endif
  259. }
  260. void SetSIMPLEOVERLAY( bool i )
  261. {
  262. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  263. m_nSIMPLEOVERLAY = i ? 1 : 0;
  264. #ifdef _DEBUG
  265. m_bSIMPLEOVERLAY = true;
  266. #endif
  267. }
  268. public:
  269. // CONSTRUCTOR
  270. water_ps20b_Static_Index( IShaderShadow *pShaderShadow, IMaterialVar **params )
  271. {
  272. #ifdef _DEBUG
  273. m_bBASETEXTURE = false;
  274. #endif // _DEBUG
  275. m_nBASETEXTURE = 0;
  276. #ifdef _DEBUG
  277. m_bMULTITEXTURE = false;
  278. #endif // _DEBUG
  279. m_nMULTITEXTURE = 0;
  280. #ifdef _DEBUG
  281. m_bREFLECT = false;
  282. #endif // _DEBUG
  283. m_nREFLECT = 0;
  284. #ifdef _DEBUG
  285. m_bREFRACT = false;
  286. #endif // _DEBUG
  287. m_nREFRACT = 0;
  288. #ifdef _DEBUG
  289. m_bABOVEWATER = false;
  290. #endif // _DEBUG
  291. m_nABOVEWATER = 0;
  292. #ifdef _DEBUG
  293. m_bFLOWMAP = false;
  294. #endif // _DEBUG
  295. m_nFLOWMAP = 0;
  296. #ifdef _DEBUG
  297. m_bFLOW_DEBUG = false;
  298. #endif // _DEBUG
  299. m_nFLOW_DEBUG = 0;
  300. #ifdef _DEBUG
  301. m_bFLASHLIGHT = false;
  302. #endif // _DEBUG
  303. m_nFLASHLIGHT = 0;
  304. #ifdef _DEBUG
  305. m_bLIGHTMAPWATERFOG = false;
  306. #endif // _DEBUG
  307. m_nLIGHTMAPWATERFOG = 0;
  308. #ifdef _DEBUG
  309. m_bFORCEFRESNEL = false;
  310. #endif // _DEBUG
  311. m_nFORCEFRESNEL = 0;
  312. #ifdef _DEBUG
  313. m_bSIMPLEOVERLAY = false;
  314. #endif // _DEBUG
  315. m_nSIMPLEOVERLAY = 0;
  316. }
  317. int GetIndex()
  318. {
  319. // Asserts to make sure that we aren't using any skipped combinations.
  320. // Asserts to make sure that we are setting all of the combination vars.
  321. #ifdef _DEBUG
  322. bool bAllStaticVarsDefined = m_bBASETEXTURE && m_bMULTITEXTURE && m_bREFLECT && m_bREFRACT && m_bABOVEWATER && m_bFLOWMAP && m_bFLOW_DEBUG && m_bFLASHLIGHT && m_bLIGHTMAPWATERFOG && m_bFORCEFRESNEL && m_bSIMPLEOVERLAY;
  323. Assert( bAllStaticVarsDefined );
  324. #endif // _DEBUG
  325. return ( 8 * m_nBASETEXTURE ) + ( 16 * m_nMULTITEXTURE ) + ( 32 * m_nREFLECT ) + ( 64 * m_nREFRACT ) + ( 128 * m_nABOVEWATER ) + ( 256 * m_nFLOWMAP ) + ( 512 * m_nFLOW_DEBUG ) + ( 1536 * m_nFLASHLIGHT ) + ( 3072 * m_nLIGHTMAPWATERFOG ) + ( 6144 * m_nFORCEFRESNEL ) + ( 12288 * m_nSIMPLEOVERLAY ) + 0;
  326. }
  327. };
  328. #define shaderStaticTest_water_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_MULTITEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ABOVEWATER + psh_forgot_to_set_static_FLOWMAP + psh_forgot_to_set_static_FLOW_DEBUG + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTMAPWATERFOG + psh_forgot_to_set_static_FORCEFRESNEL + psh_forgot_to_set_static_SIMPLEOVERLAY + 0
  329. class water_ps20b_Dynamic_Index
  330. {
  331. private:
  332. int m_nFLASHLIGHTSHADOWS;
  333. #ifdef _DEBUG
  334. bool m_bFLASHLIGHTSHADOWS;
  335. #endif
  336. public:
  337. void SetFLASHLIGHTSHADOWS( int i )
  338. {
  339. Assert( i >= 0 && i <= 1 );
  340. m_nFLASHLIGHTSHADOWS = i;
  341. #ifdef _DEBUG
  342. m_bFLASHLIGHTSHADOWS = true;
  343. #endif
  344. }
  345. void SetFLASHLIGHTSHADOWS( bool i )
  346. {
  347. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  348. m_nFLASHLIGHTSHADOWS = i ? 1 : 0;
  349. #ifdef _DEBUG
  350. m_bFLASHLIGHTSHADOWS = true;
  351. #endif
  352. }
  353. private:
  354. int m_nBUILDWORLDIMPOSTER;
  355. #ifdef _DEBUG
  356. bool m_bBUILDWORLDIMPOSTER;
  357. #endif
  358. public:
  359. void SetBUILDWORLDIMPOSTER( int i )
  360. {
  361. Assert( i >= 0 && i <= 1 );
  362. m_nBUILDWORLDIMPOSTER = i;
  363. #ifdef _DEBUG
  364. m_bBUILDWORLDIMPOSTER = true;
  365. #endif
  366. }
  367. void SetBUILDWORLDIMPOSTER( bool i )
  368. {
  369. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  370. m_nBUILDWORLDIMPOSTER = i ? 1 : 0;
  371. #ifdef _DEBUG
  372. m_bBUILDWORLDIMPOSTER = true;
  373. #endif
  374. }
  375. private:
  376. int m_nPIXELFOGTYPE;
  377. #ifdef _DEBUG
  378. bool m_bPIXELFOGTYPE;
  379. #endif
  380. public:
  381. void SetPIXELFOGTYPE( int i )
  382. {
  383. Assert( i >= 0 && i <= 1 );
  384. m_nPIXELFOGTYPE = i;
  385. #ifdef _DEBUG
  386. m_bPIXELFOGTYPE = true;
  387. #endif
  388. }
  389. void SetPIXELFOGTYPE( bool i )
  390. {
  391. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  392. m_nPIXELFOGTYPE = i ? 1 : 0;
  393. #ifdef _DEBUG
  394. m_bPIXELFOGTYPE = true;
  395. #endif
  396. }
  397. public:
  398. // CONSTRUCTOR
  399. water_ps20b_Dynamic_Index( IShaderDynamicAPI *pShaderAPI )
  400. {
  401. #ifdef _DEBUG
  402. m_bFLASHLIGHTSHADOWS = false;
  403. #endif // _DEBUG
  404. m_nFLASHLIGHTSHADOWS = 0;
  405. #ifdef _DEBUG
  406. m_bBUILDWORLDIMPOSTER = true;
  407. #endif // _DEBUG
  408. m_nBUILDWORLDIMPOSTER = r_buildingmapforworld.GetBool() ? 1 : 0 ;
  409. #ifdef _DEBUG
  410. m_bPIXELFOGTYPE = true;
  411. #endif // _DEBUG
  412. m_nPIXELFOGTYPE = ( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ;
  413. }
  414. int GetIndex()
  415. {
  416. // Asserts to make sure that we aren't using any skipped combinations.
  417. // Asserts to make sure that we are setting all of the combination vars.
  418. #ifdef _DEBUG
  419. bool bAllDynamicVarsDefined = m_bFLASHLIGHTSHADOWS && m_bBUILDWORLDIMPOSTER && m_bPIXELFOGTYPE;
  420. Assert( bAllDynamicVarsDefined );
  421. #endif // _DEBUG
  422. return ( 1 * m_nFLASHLIGHTSHADOWS ) + ( 2 * m_nBUILDWORLDIMPOSTER ) + ( 4 * m_nPIXELFOGTYPE ) + 0;
  423. }
  424. };
  425. #define shaderDynamicTest_water_ps20b psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0
  426. static const ShaderComboInformation_t s_DynamicComboArray_water_ps20b[3] =
  427. {
  428. { "FLASHLIGHTSHADOWS", 0, 1 },
  429. { "BUILDWORLDIMPOSTER", 0, 1 },
  430. { "PIXELFOGTYPE", 0, 1 },
  431. };
  432. static const ShaderComboInformation_t s_StaticComboArray_water_ps20b[11] =
  433. {
  434. { "BASETEXTURE", 0, 1 },
  435. { "MULTITEXTURE", 0, 1 },
  436. { "REFLECT", 0, 1 },
  437. { "REFRACT", 0, 1 },
  438. { "ABOVEWATER", 0, 1 },
  439. { "FLOWMAP", 0, 1 },
  440. { "FLOW_DEBUG", 0, 2 },
  441. { "FLASHLIGHT", 0, 1 },
  442. { "LIGHTMAPWATERFOG", 0, 1 },
  443. { "FORCEFRESNEL", 0, 1 },
  444. { "SIMPLEOVERLAY", 0, 1 },
  445. };
  446. static const ShaderComboSemantics_t water_ps20b_combos =
  447. {
  448. "water_ps20b", s_DynamicComboArray_water_ps20b, 3, s_StaticComboArray_water_ps20b, 11
  449. };
  450. class ConstructMe_water_ps20b
  451. {
  452. public:
  453. ConstructMe_water_ps20b()
  454. {
  455. GetShaderDLL()->AddShaderComboInformation( &water_ps20b_combos );
  456. }
  457. };
  458. static ConstructMe_water_ps20b s_ConstructMe_water_ps20b;