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.

433 lines
10 KiB

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