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.

488 lines
12 KiB

  1. // ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!!
  2. // ( $AMBIENTREFLECTION == 0 ) && ( $USEBOUNCECOLOR == 1 )
  3. // ( $BASEALPHAENVMASK == 1 ) && ( $ENVMAP == 0 )
  4. // ( $BUMPALPHAENVMASK == 1 ) && ( $ENVMAP == 0 )
  5. // ( $BASEALPHAENVMASK == 1 ) && ( $BUMPALPHAENVMASK == 1 )
  6. // ( $BASEALPHASELFILLUMMASK == 1) && ( $BASEALPHAENVMASK == 1 )
  7. // ( $BASEALPHASELFILLUMMASK == 1) && ( $BASEALPHAPHONGMASK == 1 )
  8. // ( $BASEALPHAENVMASK == 1 ) && ( $BASEALPHASELFILLUMMASK )
  9. // ( $CASCADED_SHADOW_MAPPING == 0 ) && ( $DYN_CSM_ENABLED == 1 )
  10. // ( $CASCADED_SHADOW_MAPPING == 0 ) && ( $CSM_MODE != 0 )
  11. // ( $AMBIENTREFLECTION == 0 ) && ( $USEBOUNCECOLOR == 1 )
  12. // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA
  13. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT
  14. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST
  15. // defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH
  16. // ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW
  17. // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA
  18. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT
  19. // defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST
  20. // defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH
  21. // ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW
  22. #include "shaderlib/cshader.h"
  23. class character_ps20b_Static_Index
  24. {
  25. private:
  26. int m_nMASKS1;
  27. #ifdef _DEBUG
  28. bool m_bMASKS1;
  29. #endif
  30. public:
  31. void SetMASKS1( int i )
  32. {
  33. Assert( i >= 0 && i <= 1 );
  34. m_nMASKS1 = i;
  35. #ifdef _DEBUG
  36. m_bMASKS1 = true;
  37. #endif
  38. }
  39. void SetMASKS1( bool i )
  40. {
  41. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  42. m_nMASKS1 = i ? 1 : 0;
  43. #ifdef _DEBUG
  44. m_bMASKS1 = true;
  45. #endif
  46. }
  47. private:
  48. int m_nMASKS2;
  49. #ifdef _DEBUG
  50. bool m_bMASKS2;
  51. #endif
  52. public:
  53. void SetMASKS2( int i )
  54. {
  55. Assert( i >= 0 && i <= 1 );
  56. m_nMASKS2 = i;
  57. #ifdef _DEBUG
  58. m_bMASKS2 = true;
  59. #endif
  60. }
  61. void SetMASKS2( bool i )
  62. {
  63. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  64. m_nMASKS2 = i ? 1 : 0;
  65. #ifdef _DEBUG
  66. m_bMASKS2 = true;
  67. #endif
  68. }
  69. private:
  70. int m_nFRESNELRANGESTEXTURE;
  71. #ifdef _DEBUG
  72. bool m_bFRESNELRANGESTEXTURE;
  73. #endif
  74. public:
  75. void SetFRESNELRANGESTEXTURE( int i )
  76. {
  77. Assert( i >= 0 && i <= 1 );
  78. m_nFRESNELRANGESTEXTURE = i;
  79. #ifdef _DEBUG
  80. m_bFRESNELRANGESTEXTURE = true;
  81. #endif
  82. }
  83. void SetFRESNELRANGESTEXTURE( bool i )
  84. {
  85. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  86. m_nFRESNELRANGESTEXTURE = i ? 1 : 0;
  87. #ifdef _DEBUG
  88. m_bFRESNELRANGESTEXTURE = true;
  89. #endif
  90. }
  91. private:
  92. int m_nENVMAP;
  93. #ifdef _DEBUG
  94. bool m_bENVMAP;
  95. #endif
  96. public:
  97. void SetENVMAP( int i )
  98. {
  99. Assert( i >= 0 && i <= 1 );
  100. m_nENVMAP = i;
  101. #ifdef _DEBUG
  102. m_bENVMAP = true;
  103. #endif
  104. }
  105. void SetENVMAP( bool i )
  106. {
  107. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  108. m_nENVMAP = i ? 1 : 0;
  109. #ifdef _DEBUG
  110. m_bENVMAP = true;
  111. #endif
  112. }
  113. private:
  114. int m_nAMBIENTREFLECTION;
  115. #ifdef _DEBUG
  116. bool m_bAMBIENTREFLECTION;
  117. #endif
  118. public:
  119. void SetAMBIENTREFLECTION( int i )
  120. {
  121. Assert( i >= 0 && i <= 1 );
  122. m_nAMBIENTREFLECTION = i;
  123. #ifdef _DEBUG
  124. m_bAMBIENTREFLECTION = true;
  125. #endif
  126. }
  127. void SetAMBIENTREFLECTION( bool i )
  128. {
  129. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  130. m_nAMBIENTREFLECTION = i ? 1 : 0;
  131. #ifdef _DEBUG
  132. m_bAMBIENTREFLECTION = true;
  133. #endif
  134. }
  135. private:
  136. int m_nBASEALPHAENVMASK;
  137. #ifdef _DEBUG
  138. bool m_bBASEALPHAENVMASK;
  139. #endif
  140. public:
  141. void SetBASEALPHAENVMASK( int i )
  142. {
  143. Assert( i >= 0 && i <= 1 );
  144. m_nBASEALPHAENVMASK = i;
  145. #ifdef _DEBUG
  146. m_bBASEALPHAENVMASK = true;
  147. #endif
  148. }
  149. void SetBASEALPHAENVMASK( bool i )
  150. {
  151. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  152. m_nBASEALPHAENVMASK = i ? 1 : 0;
  153. #ifdef _DEBUG
  154. m_bBASEALPHAENVMASK = true;
  155. #endif
  156. }
  157. private:
  158. int m_nBUMPALPHAENVMASK;
  159. #ifdef _DEBUG
  160. bool m_bBUMPALPHAENVMASK;
  161. #endif
  162. public:
  163. void SetBUMPALPHAENVMASK( int i )
  164. {
  165. Assert( i >= 0 && i <= 1 );
  166. m_nBUMPALPHAENVMASK = i;
  167. #ifdef _DEBUG
  168. m_bBUMPALPHAENVMASK = true;
  169. #endif
  170. }
  171. void SetBUMPALPHAENVMASK( bool i )
  172. {
  173. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  174. m_nBUMPALPHAENVMASK = i ? 1 : 0;
  175. #ifdef _DEBUG
  176. m_bBUMPALPHAENVMASK = true;
  177. #endif
  178. }
  179. private:
  180. int m_nBASEALPHASELFILLUMMASK;
  181. #ifdef _DEBUG
  182. bool m_bBASEALPHASELFILLUMMASK;
  183. #endif
  184. public:
  185. void SetBASEALPHASELFILLUMMASK( int i )
  186. {
  187. Assert( i >= 0 && i <= 1 );
  188. m_nBASEALPHASELFILLUMMASK = i;
  189. #ifdef _DEBUG
  190. m_bBASEALPHASELFILLUMMASK = true;
  191. #endif
  192. }
  193. void SetBASEALPHASELFILLUMMASK( bool i )
  194. {
  195. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  196. m_nBASEALPHASELFILLUMMASK = i ? 1 : 0;
  197. #ifdef _DEBUG
  198. m_bBASEALPHASELFILLUMMASK = true;
  199. #endif
  200. }
  201. private:
  202. int m_nFAKERIM;
  203. #ifdef _DEBUG
  204. bool m_bFAKERIM;
  205. #endif
  206. public:
  207. void SetFAKERIM( int i )
  208. {
  209. Assert( i >= 0 && i <= 1 );
  210. m_nFAKERIM = i;
  211. #ifdef _DEBUG
  212. m_bFAKERIM = true;
  213. #endif
  214. }
  215. void SetFAKERIM( bool i )
  216. {
  217. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  218. m_nFAKERIM = i ? 1 : 0;
  219. #ifdef _DEBUG
  220. m_bFAKERIM = true;
  221. #endif
  222. }
  223. private:
  224. int m_nCASCADED_SHADOW_MAPPING;
  225. #ifdef _DEBUG
  226. bool m_bCASCADED_SHADOW_MAPPING;
  227. #endif
  228. public:
  229. void SetCASCADED_SHADOW_MAPPING( int i )
  230. {
  231. Assert( i >= 0 && i <= 1 );
  232. m_nCASCADED_SHADOW_MAPPING = i;
  233. #ifdef _DEBUG
  234. m_bCASCADED_SHADOW_MAPPING = true;
  235. #endif
  236. }
  237. void SetCASCADED_SHADOW_MAPPING( bool i )
  238. {
  239. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  240. m_nCASCADED_SHADOW_MAPPING = i ? 1 : 0;
  241. #ifdef _DEBUG
  242. m_bCASCADED_SHADOW_MAPPING = true;
  243. #endif
  244. }
  245. public:
  246. // CONSTRUCTOR
  247. character_ps20b_Static_Index( IShaderShadow *pShaderShadow, IMaterialVar **params )
  248. {
  249. #ifdef _DEBUG
  250. m_bMASKS1 = false;
  251. #endif // _DEBUG
  252. m_nMASKS1 = 0;
  253. #ifdef _DEBUG
  254. m_bMASKS2 = false;
  255. #endif // _DEBUG
  256. m_nMASKS2 = 0;
  257. #ifdef _DEBUG
  258. m_bFRESNELRANGESTEXTURE = false;
  259. #endif // _DEBUG
  260. m_nFRESNELRANGESTEXTURE = 0;
  261. #ifdef _DEBUG
  262. m_bENVMAP = false;
  263. #endif // _DEBUG
  264. m_nENVMAP = 0;
  265. #ifdef _DEBUG
  266. m_bAMBIENTREFLECTION = false;
  267. #endif // _DEBUG
  268. m_nAMBIENTREFLECTION = 0;
  269. #ifdef _DEBUG
  270. m_bBASEALPHAENVMASK = false;
  271. #endif // _DEBUG
  272. m_nBASEALPHAENVMASK = 0;
  273. #ifdef _DEBUG
  274. m_bBUMPALPHAENVMASK = false;
  275. #endif // _DEBUG
  276. m_nBUMPALPHAENVMASK = 0;
  277. #ifdef _DEBUG
  278. m_bBASEALPHASELFILLUMMASK = false;
  279. #endif // _DEBUG
  280. m_nBASEALPHASELFILLUMMASK = 0;
  281. #ifdef _DEBUG
  282. m_bFAKERIM = false;
  283. #endif // _DEBUG
  284. m_nFAKERIM = 0;
  285. #ifdef _DEBUG
  286. m_bCASCADED_SHADOW_MAPPING = false;
  287. #endif // _DEBUG
  288. m_nCASCADED_SHADOW_MAPPING = 0;
  289. }
  290. int GetIndex()
  291. {
  292. // Asserts to make sure that we aren't using any skipped combinations.
  293. // Asserts to make sure that we are setting all of the combination vars.
  294. #ifdef _DEBUG
  295. bool bAllStaticVarsDefined = m_bMASKS1 && m_bMASKS2 && m_bFRESNELRANGESTEXTURE && m_bENVMAP && m_bAMBIENTREFLECTION && m_bBASEALPHAENVMASK && m_bBUMPALPHAENVMASK && m_bBASEALPHASELFILLUMMASK && m_bFAKERIM && m_bCASCADED_SHADOW_MAPPING;
  296. Assert( bAllStaticVarsDefined );
  297. #endif // _DEBUG
  298. return ( 80 * m_nMASKS1 ) + ( 160 * m_nMASKS2 ) + ( 320 * m_nFRESNELRANGESTEXTURE ) + ( 640 * m_nENVMAP ) + ( 1280 * m_nAMBIENTREFLECTION ) + ( 2560 * m_nBASEALPHAENVMASK ) + ( 5120 * m_nBUMPALPHAENVMASK ) + ( 10240 * m_nBASEALPHASELFILLUMMASK ) + ( 20480 * m_nFAKERIM ) + ( 40960 * m_nCASCADED_SHADOW_MAPPING ) + 0;
  299. }
  300. };
  301. #define shaderStaticTest_character_ps20b psh_forgot_to_set_static_MASKS1 + psh_forgot_to_set_static_MASKS2 + psh_forgot_to_set_static_FRESNELRANGESTEXTURE + psh_forgot_to_set_static_ENVMAP + psh_forgot_to_set_static_AMBIENTREFLECTION + psh_forgot_to_set_static_BASEALPHAENVMASK + psh_forgot_to_set_static_BUMPALPHAENVMASK + psh_forgot_to_set_static_BASEALPHASELFILLUMMASK + psh_forgot_to_set_static_FAKERIM + psh_forgot_to_set_static_CASCADED_SHADOW_MAPPING + 0
  302. class character_ps20b_Dynamic_Index
  303. {
  304. private:
  305. int m_nNUM_LIGHTS;
  306. #ifdef _DEBUG
  307. bool m_bNUM_LIGHTS;
  308. #endif
  309. public:
  310. void SetNUM_LIGHTS( int i )
  311. {
  312. Assert( i >= 0 && i <= 4 );
  313. m_nNUM_LIGHTS = i;
  314. #ifdef _DEBUG
  315. m_bNUM_LIGHTS = true;
  316. #endif
  317. }
  318. void SetNUM_LIGHTS( bool i )
  319. {
  320. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 4 );
  321. m_nNUM_LIGHTS = i ? 1 : 0;
  322. #ifdef _DEBUG
  323. m_bNUM_LIGHTS = true;
  324. #endif
  325. }
  326. private:
  327. int m_nDYN_CSM_ENABLED;
  328. #ifdef _DEBUG
  329. bool m_bDYN_CSM_ENABLED;
  330. #endif
  331. public:
  332. void SetDYN_CSM_ENABLED( int i )
  333. {
  334. Assert( i >= 0 && i <= 1 );
  335. m_nDYN_CSM_ENABLED = i;
  336. #ifdef _DEBUG
  337. m_bDYN_CSM_ENABLED = true;
  338. #endif
  339. }
  340. void SetDYN_CSM_ENABLED( bool i )
  341. {
  342. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  343. m_nDYN_CSM_ENABLED = i ? 1 : 0;
  344. #ifdef _DEBUG
  345. m_bDYN_CSM_ENABLED = true;
  346. #endif
  347. }
  348. private:
  349. int m_nWRITE_DEPTH_TO_DESTALPHA;
  350. #ifdef _DEBUG
  351. bool m_bWRITE_DEPTH_TO_DESTALPHA;
  352. #endif
  353. public:
  354. void SetWRITE_DEPTH_TO_DESTALPHA( int i )
  355. {
  356. Assert( i >= 0 && i <= 1 );
  357. m_nWRITE_DEPTH_TO_DESTALPHA = i;
  358. #ifdef _DEBUG
  359. m_bWRITE_DEPTH_TO_DESTALPHA = true;
  360. #endif
  361. }
  362. void SetWRITE_DEPTH_TO_DESTALPHA( bool i )
  363. {
  364. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  365. m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0;
  366. #ifdef _DEBUG
  367. m_bWRITE_DEPTH_TO_DESTALPHA = true;
  368. #endif
  369. }
  370. private:
  371. int m_nWRITEWATERFOGTODESTALPHA;
  372. #ifdef _DEBUG
  373. bool m_bWRITEWATERFOGTODESTALPHA;
  374. #endif
  375. public:
  376. void SetWRITEWATERFOGTODESTALPHA( int i )
  377. {
  378. Assert( i >= 0 && i <= 1 );
  379. m_nWRITEWATERFOGTODESTALPHA = i;
  380. #ifdef _DEBUG
  381. m_bWRITEWATERFOGTODESTALPHA = true;
  382. #endif
  383. }
  384. void SetWRITEWATERFOGTODESTALPHA( bool i )
  385. {
  386. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  387. m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0;
  388. #ifdef _DEBUG
  389. m_bWRITEWATERFOGTODESTALPHA = true;
  390. #endif
  391. }
  392. private:
  393. int m_nPIXELFOGTYPE;
  394. #ifdef _DEBUG
  395. bool m_bPIXELFOGTYPE;
  396. #endif
  397. public:
  398. void SetPIXELFOGTYPE( int i )
  399. {
  400. Assert( i >= 0 && i <= 1 );
  401. m_nPIXELFOGTYPE = i;
  402. #ifdef _DEBUG
  403. m_bPIXELFOGTYPE = true;
  404. #endif
  405. }
  406. void SetPIXELFOGTYPE( bool i )
  407. {
  408. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  409. m_nPIXELFOGTYPE = i ? 1 : 0;
  410. #ifdef _DEBUG
  411. m_bPIXELFOGTYPE = true;
  412. #endif
  413. }
  414. public:
  415. // CONSTRUCTOR
  416. character_ps20b_Dynamic_Index( IShaderDynamicAPI *pShaderAPI )
  417. {
  418. #ifdef _DEBUG
  419. m_bNUM_LIGHTS = false;
  420. #endif // _DEBUG
  421. m_nNUM_LIGHTS = 0;
  422. #ifdef _DEBUG
  423. m_bDYN_CSM_ENABLED = false;
  424. #endif // _DEBUG
  425. m_nDYN_CSM_ENABLED = 0;
  426. #ifdef _DEBUG
  427. m_bWRITE_DEPTH_TO_DESTALPHA = false;
  428. #endif // _DEBUG
  429. m_nWRITE_DEPTH_TO_DESTALPHA = 0;
  430. #ifdef _DEBUG
  431. m_bWRITEWATERFOGTODESTALPHA = false;
  432. #endif // _DEBUG
  433. m_nWRITEWATERFOGTODESTALPHA = 0;
  434. #ifdef _DEBUG
  435. m_bPIXELFOGTYPE = true;
  436. #endif // _DEBUG
  437. m_nPIXELFOGTYPE = ( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ;
  438. }
  439. int GetIndex()
  440. {
  441. // Asserts to make sure that we aren't using any skipped combinations.
  442. // Asserts to make sure that we are setting all of the combination vars.
  443. #ifdef _DEBUG
  444. bool bAllDynamicVarsDefined = m_bNUM_LIGHTS && m_bDYN_CSM_ENABLED && m_bWRITE_DEPTH_TO_DESTALPHA && m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE;
  445. Assert( bAllDynamicVarsDefined );
  446. #endif // _DEBUG
  447. return ( 1 * m_nNUM_LIGHTS ) + ( 5 * m_nDYN_CSM_ENABLED ) + ( 10 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 20 * m_nWRITEWATERFOGTODESTALPHA ) + ( 40 * m_nPIXELFOGTYPE ) + 0;
  448. }
  449. };
  450. #define shaderDynamicTest_character_ps20b psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_DYN_CSM_ENABLED + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + 0
  451. static const ShaderComboInformation_t s_DynamicComboArray_character_ps20b[5] =
  452. {
  453. { "NUM_LIGHTS", 0, 4 },
  454. { "DYN_CSM_ENABLED", 0, 1 },
  455. { "WRITE_DEPTH_TO_DESTALPHA", 0, 1 },
  456. { "WRITEWATERFOGTODESTALPHA", 0, 1 },
  457. { "PIXELFOGTYPE", 0, 1 },
  458. };
  459. static const ShaderComboInformation_t s_StaticComboArray_character_ps20b[10] =
  460. {
  461. { "MASKS1", 0, 1 },
  462. { "MASKS2", 0, 1 },
  463. { "FRESNELRANGESTEXTURE", 0, 1 },
  464. { "ENVMAP", 0, 1 },
  465. { "AMBIENTREFLECTION", 0, 1 },
  466. { "BASEALPHAENVMASK", 0, 1 },
  467. { "BUMPALPHAENVMASK", 0, 1 },
  468. { "BASEALPHASELFILLUMMASK", 0, 1 },
  469. { "FAKERIM", 0, 1 },
  470. { "CASCADED_SHADOW_MAPPING", 0, 1 },
  471. };
  472. static const ShaderComboSemantics_t character_ps20b_combos =
  473. {
  474. "character_ps20b", s_DynamicComboArray_character_ps20b, 5, s_StaticComboArray_character_ps20b, 10
  475. };
  476. class ConstructMe_character_ps20b
  477. {
  478. public:
  479. ConstructMe_character_ps20b()
  480. {
  481. GetShaderDLL()->AddShaderComboInformation( &character_ps20b_combos );
  482. }
  483. };
  484. static ConstructMe_character_ps20b s_ConstructMe_character_ps20b;