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.

447 lines
10 KiB

  1. // ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!!
  2. // ( $SFM == 0 ) && ( $MORPHING )
  3. // ( $SFM == 0 ) && ( $TESSELLATION )
  4. // ( $FLATTEN_STATIC_CONTROL_FLOW == 0 ) && ( $NUM_LIGHTS > 0 ) [PC]
  5. // ( $MORPHING || $SKINNING || $COMPRESSED_VERTS ) && $TESSELLATION
  6. // ( $DOWATERFOG == 0 ) && ( $DOPIXELFOG && $HARDWAREFOGBLEND )
  7. // defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH
  8. #include "shaderlib/cshader.h"
  9. class phong_vs20_Static_Index
  10. {
  11. private:
  12. int m_nSFM;
  13. #ifdef _DEBUG
  14. bool m_bSFM;
  15. #endif
  16. public:
  17. void SetSFM( int i )
  18. {
  19. Assert( i >= 0 && i <= 0 );
  20. m_nSFM = i;
  21. #ifdef _DEBUG
  22. m_bSFM = true;
  23. #endif
  24. }
  25. void SetSFM( bool i )
  26. {
  27. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  28. m_nSFM = i ? 1 : 0;
  29. #ifdef _DEBUG
  30. m_bSFM = true;
  31. #endif
  32. }
  33. private:
  34. int m_nWORLD_NORMAL;
  35. #ifdef _DEBUG
  36. bool m_bWORLD_NORMAL;
  37. #endif
  38. public:
  39. void SetWORLD_NORMAL( int i )
  40. {
  41. Assert( i >= 0 && i <= 0 );
  42. m_nWORLD_NORMAL = i;
  43. #ifdef _DEBUG
  44. m_bWORLD_NORMAL = true;
  45. #endif
  46. }
  47. void SetWORLD_NORMAL( bool i )
  48. {
  49. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  50. m_nWORLD_NORMAL = i ? 1 : 0;
  51. #ifdef _DEBUG
  52. m_bWORLD_NORMAL = true;
  53. #endif
  54. }
  55. private:
  56. int m_nFLATTEN_STATIC_CONTROL_FLOW;
  57. #ifdef _DEBUG
  58. bool m_bFLATTEN_STATIC_CONTROL_FLOW;
  59. #endif
  60. public:
  61. void SetFLATTEN_STATIC_CONTROL_FLOW( int i )
  62. {
  63. Assert( i >= 0 && i <= 1 );
  64. m_nFLATTEN_STATIC_CONTROL_FLOW = i;
  65. #ifdef _DEBUG
  66. m_bFLATTEN_STATIC_CONTROL_FLOW = true;
  67. #endif
  68. }
  69. void SetFLATTEN_STATIC_CONTROL_FLOW( bool i )
  70. {
  71. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  72. m_nFLATTEN_STATIC_CONTROL_FLOW = i ? 1 : 0;
  73. #ifdef _DEBUG
  74. m_bFLATTEN_STATIC_CONTROL_FLOW = true;
  75. #endif
  76. }
  77. private:
  78. int m_nCASCADED_SHADOW_MAPPING;
  79. #ifdef _DEBUG
  80. bool m_bCASCADED_SHADOW_MAPPING;
  81. #endif
  82. public:
  83. void SetCASCADED_SHADOW_MAPPING( int i )
  84. {
  85. Assert( i >= 0 && i <= 1 );
  86. m_nCASCADED_SHADOW_MAPPING = i;
  87. #ifdef _DEBUG
  88. m_bCASCADED_SHADOW_MAPPING = true;
  89. #endif
  90. }
  91. void SetCASCADED_SHADOW_MAPPING( bool i )
  92. {
  93. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  94. m_nCASCADED_SHADOW_MAPPING = i ? 1 : 0;
  95. #ifdef _DEBUG
  96. m_bCASCADED_SHADOW_MAPPING = true;
  97. #endif
  98. }
  99. private:
  100. int m_nDOPIXELFOG;
  101. #ifdef _DEBUG
  102. bool m_bDOPIXELFOG;
  103. #endif
  104. public:
  105. void SetDOPIXELFOG( int i )
  106. {
  107. Assert( i >= 0 && i <= 1 );
  108. m_nDOPIXELFOG = i;
  109. #ifdef _DEBUG
  110. m_bDOPIXELFOG = true;
  111. #endif
  112. }
  113. void SetDOPIXELFOG( bool i )
  114. {
  115. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  116. m_nDOPIXELFOG = i ? 1 : 0;
  117. #ifdef _DEBUG
  118. m_bDOPIXELFOG = true;
  119. #endif
  120. }
  121. private:
  122. int m_nHARDWAREFOGBLEND;
  123. #ifdef _DEBUG
  124. bool m_bHARDWAREFOGBLEND;
  125. #endif
  126. public:
  127. void SetHARDWAREFOGBLEND( int i )
  128. {
  129. Assert( i >= 0 && i <= 1 );
  130. m_nHARDWAREFOGBLEND = i;
  131. #ifdef _DEBUG
  132. m_bHARDWAREFOGBLEND = true;
  133. #endif
  134. }
  135. void SetHARDWAREFOGBLEND( bool i )
  136. {
  137. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  138. m_nHARDWAREFOGBLEND = i ? 1 : 0;
  139. #ifdef _DEBUG
  140. m_bHARDWAREFOGBLEND = true;
  141. #endif
  142. }
  143. public:
  144. // CONSTRUCTOR
  145. phong_vs20_Static_Index( IShaderShadow *pShaderShadow, IMaterialVar **params )
  146. {
  147. #ifdef _DEBUG
  148. m_bSFM = false;
  149. #endif // _DEBUG
  150. m_nSFM = 0;
  151. #ifdef _DEBUG
  152. m_bWORLD_NORMAL = false;
  153. #endif // _DEBUG
  154. m_nWORLD_NORMAL = 0;
  155. #ifdef _DEBUG
  156. m_bFLATTEN_STATIC_CONTROL_FLOW = false;
  157. #endif // _DEBUG
  158. m_nFLATTEN_STATIC_CONTROL_FLOW = 0;
  159. #ifdef _DEBUG
  160. m_bCASCADED_SHADOW_MAPPING = false;
  161. #endif // _DEBUG
  162. m_nCASCADED_SHADOW_MAPPING = 0;
  163. #ifdef _DEBUG
  164. m_bDOPIXELFOG = true;
  165. #endif // _DEBUG
  166. m_nDOPIXELFOG = ( g_pHardwareConfig->SupportsPixelShaders_2_b() && !IS_FLAG_SET( MATERIAL_VAR_VERTEXFOG ) ) ? 1 : 0 ;
  167. #ifdef _DEBUG
  168. m_bHARDWAREFOGBLEND = true;
  169. #endif // _DEBUG
  170. m_nHARDWAREFOGBLEND = !g_pHardwareConfig->SupportsPixelShaders_2_b() ;
  171. }
  172. int GetIndex()
  173. {
  174. // Asserts to make sure that we aren't using any skipped combinations.
  175. // Asserts to make sure that we are setting all of the combination vars.
  176. #ifdef _DEBUG
  177. bool bAllStaticVarsDefined = m_bSFM && m_bWORLD_NORMAL && m_bFLATTEN_STATIC_CONTROL_FLOW && m_bCASCADED_SHADOW_MAPPING && m_bDOPIXELFOG && m_bHARDWAREFOGBLEND;
  178. Assert( bAllStaticVarsDefined );
  179. #endif // _DEBUG
  180. return ( 96 * m_nSFM ) + ( 96 * m_nWORLD_NORMAL ) + ( 96 * m_nFLATTEN_STATIC_CONTROL_FLOW ) + ( 192 * m_nCASCADED_SHADOW_MAPPING ) + ( 384 * m_nDOPIXELFOG ) + ( 768 * m_nHARDWAREFOGBLEND ) + 0;
  181. }
  182. };
  183. #define shaderStaticTest_phong_vs20 vsh_forgot_to_set_static_SFM + vsh_forgot_to_set_static_WORLD_NORMAL + vsh_forgot_to_set_static_FLATTEN_STATIC_CONTROL_FLOW + vsh_forgot_to_set_static_CASCADED_SHADOW_MAPPING + 0
  184. class phong_vs20_Dynamic_Index
  185. {
  186. private:
  187. int m_nCSM_VIEWMODELQUALITY;
  188. #ifdef _DEBUG
  189. bool m_bCSM_VIEWMODELQUALITY;
  190. #endif
  191. public:
  192. void SetCSM_VIEWMODELQUALITY( int i )
  193. {
  194. Assert( i >= 0 && i <= 1 );
  195. m_nCSM_VIEWMODELQUALITY = i;
  196. #ifdef _DEBUG
  197. m_bCSM_VIEWMODELQUALITY = true;
  198. #endif
  199. }
  200. void SetCSM_VIEWMODELQUALITY( bool i )
  201. {
  202. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  203. m_nCSM_VIEWMODELQUALITY = i ? 1 : 0;
  204. #ifdef _DEBUG
  205. m_bCSM_VIEWMODELQUALITY = true;
  206. #endif
  207. }
  208. private:
  209. int m_nCOMPRESSED_VERTS;
  210. #ifdef _DEBUG
  211. bool m_bCOMPRESSED_VERTS;
  212. #endif
  213. public:
  214. void SetCOMPRESSED_VERTS( int i )
  215. {
  216. Assert( i >= 0 && i <= 1 );
  217. m_nCOMPRESSED_VERTS = i;
  218. #ifdef _DEBUG
  219. m_bCOMPRESSED_VERTS = true;
  220. #endif
  221. }
  222. void SetCOMPRESSED_VERTS( bool i )
  223. {
  224. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  225. m_nCOMPRESSED_VERTS = i ? 1 : 0;
  226. #ifdef _DEBUG
  227. m_bCOMPRESSED_VERTS = true;
  228. #endif
  229. }
  230. private:
  231. int m_nSKINNING;
  232. #ifdef _DEBUG
  233. bool m_bSKINNING;
  234. #endif
  235. public:
  236. void SetSKINNING( int i )
  237. {
  238. Assert( i >= 0 && i <= 1 );
  239. m_nSKINNING = i;
  240. #ifdef _DEBUG
  241. m_bSKINNING = true;
  242. #endif
  243. }
  244. void SetSKINNING( bool i )
  245. {
  246. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  247. m_nSKINNING = i ? 1 : 0;
  248. #ifdef _DEBUG
  249. m_bSKINNING = true;
  250. #endif
  251. }
  252. private:
  253. int m_nMORPHING;
  254. #ifdef _DEBUG
  255. bool m_bMORPHING;
  256. #endif
  257. public:
  258. void SetMORPHING( int i )
  259. {
  260. Assert( i >= 0 && i <= 0 );
  261. m_nMORPHING = i;
  262. #ifdef _DEBUG
  263. m_bMORPHING = true;
  264. #endif
  265. }
  266. void SetMORPHING( bool i )
  267. {
  268. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  269. m_nMORPHING = i ? 1 : 0;
  270. #ifdef _DEBUG
  271. m_bMORPHING = true;
  272. #endif
  273. }
  274. private:
  275. int m_nTESSELLATION;
  276. #ifdef _DEBUG
  277. bool m_bTESSELLATION;
  278. #endif
  279. public:
  280. void SetTESSELLATION( int i )
  281. {
  282. Assert( i >= 0 && i <= 0 );
  283. m_nTESSELLATION = i;
  284. #ifdef _DEBUG
  285. m_bTESSELLATION = true;
  286. #endif
  287. }
  288. void SetTESSELLATION( bool i )
  289. {
  290. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  291. m_nTESSELLATION = i ? 1 : 0;
  292. #ifdef _DEBUG
  293. m_bTESSELLATION = true;
  294. #endif
  295. }
  296. private:
  297. int m_nNUM_LIGHTS;
  298. #ifdef _DEBUG
  299. bool m_bNUM_LIGHTS;
  300. #endif
  301. public:
  302. void SetNUM_LIGHTS( int i )
  303. {
  304. Assert( i >= 0 && i <= 2 );
  305. m_nNUM_LIGHTS = i;
  306. #ifdef _DEBUG
  307. m_bNUM_LIGHTS = true;
  308. #endif
  309. }
  310. void SetNUM_LIGHTS( bool i )
  311. {
  312. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 2 );
  313. m_nNUM_LIGHTS = i ? 1 : 0;
  314. #ifdef _DEBUG
  315. m_bNUM_LIGHTS = true;
  316. #endif
  317. }
  318. private:
  319. int m_nSTATICLIGHT3;
  320. #ifdef _DEBUG
  321. bool m_bSTATICLIGHT3;
  322. #endif
  323. public:
  324. void SetSTATICLIGHT3( int i )
  325. {
  326. Assert( i >= 0 && i <= 1 );
  327. m_nSTATICLIGHT3 = i;
  328. #ifdef _DEBUG
  329. m_bSTATICLIGHT3 = true;
  330. #endif
  331. }
  332. void SetSTATICLIGHT3( bool i )
  333. {
  334. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  335. m_nSTATICLIGHT3 = i ? 1 : 0;
  336. #ifdef _DEBUG
  337. m_bSTATICLIGHT3 = true;
  338. #endif
  339. }
  340. private:
  341. int m_nDOWATERFOG;
  342. #ifdef _DEBUG
  343. bool m_bDOWATERFOG;
  344. #endif
  345. public:
  346. void SetDOWATERFOG( int i )
  347. {
  348. Assert( i >= 0 && i <= 1 );
  349. m_nDOWATERFOG = i;
  350. #ifdef _DEBUG
  351. m_bDOWATERFOG = true;
  352. #endif
  353. }
  354. void SetDOWATERFOG( bool i )
  355. {
  356. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  357. m_nDOWATERFOG = i ? 1 : 0;
  358. #ifdef _DEBUG
  359. m_bDOWATERFOG = true;
  360. #endif
  361. }
  362. public:
  363. // CONSTRUCTOR
  364. phong_vs20_Dynamic_Index( IShaderDynamicAPI *pShaderAPI )
  365. {
  366. #ifdef _DEBUG
  367. m_bCSM_VIEWMODELQUALITY = false;
  368. #endif // _DEBUG
  369. m_nCSM_VIEWMODELQUALITY = 0;
  370. #ifdef _DEBUG
  371. m_bCOMPRESSED_VERTS = false;
  372. #endif // _DEBUG
  373. m_nCOMPRESSED_VERTS = 0;
  374. #ifdef _DEBUG
  375. m_bSKINNING = false;
  376. #endif // _DEBUG
  377. m_nSKINNING = 0;
  378. #ifdef _DEBUG
  379. m_bMORPHING = true;
  380. #endif // _DEBUG
  381. m_nMORPHING = false ;
  382. #ifdef _DEBUG
  383. m_bTESSELLATION = false;
  384. #endif // _DEBUG
  385. m_nTESSELLATION = 0;
  386. #ifdef _DEBUG
  387. m_bNUM_LIGHTS = false;
  388. #endif // _DEBUG
  389. m_nNUM_LIGHTS = 0;
  390. #ifdef _DEBUG
  391. m_bSTATICLIGHT3 = false;
  392. #endif // _DEBUG
  393. m_nSTATICLIGHT3 = 0;
  394. #ifdef _DEBUG
  395. m_bDOWATERFOG = true;
  396. #endif // _DEBUG
  397. m_nDOWATERFOG = ( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ;
  398. }
  399. int GetIndex()
  400. {
  401. // Asserts to make sure that we aren't using any skipped combinations.
  402. // Asserts to make sure that we are setting all of the combination vars.
  403. #ifdef _DEBUG
  404. bool bAllDynamicVarsDefined = m_bCSM_VIEWMODELQUALITY && m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING && m_bTESSELLATION && m_bNUM_LIGHTS && m_bSTATICLIGHT3 && m_bDOWATERFOG;
  405. Assert( bAllDynamicVarsDefined );
  406. #endif // _DEBUG
  407. return ( 1 * m_nCSM_VIEWMODELQUALITY ) + ( 2 * m_nCOMPRESSED_VERTS ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + ( 8 * m_nTESSELLATION ) + ( 8 * m_nNUM_LIGHTS ) + ( 24 * m_nSTATICLIGHT3 ) + ( 48 * m_nDOWATERFOG ) + 0;
  408. }
  409. };
  410. #define shaderDynamicTest_phong_vs20 vsh_forgot_to_set_dynamic_CSM_VIEWMODELQUALITY + vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_TESSELLATION + vsh_forgot_to_set_dynamic_NUM_LIGHTS + vsh_forgot_to_set_dynamic_STATICLIGHT3 + 0
  411. static const ShaderComboInformation_t s_DynamicComboArray_phong_vs20[8] =
  412. {
  413. { "CSM_VIEWMODELQUALITY", 0, 1 },
  414. { "COMPRESSED_VERTS", 0, 1 },
  415. { "SKINNING", 0, 1 },
  416. { "MORPHING", 0, 0 },
  417. { "TESSELLATION", 0, 0 },
  418. { "NUM_LIGHTS", 0, 2 },
  419. { "STATICLIGHT3", 0, 1 },
  420. { "DOWATERFOG", 0, 1 },
  421. };
  422. static const ShaderComboInformation_t s_StaticComboArray_phong_vs20[6] =
  423. {
  424. { "SFM", 0, 0 },
  425. { "WORLD_NORMAL", 0, 0 },
  426. { "FLATTEN_STATIC_CONTROL_FLOW", 0, 1 },
  427. { "CASCADED_SHADOW_MAPPING", 0, 1 },
  428. { "DOPIXELFOG", 0, 1 },
  429. { "HARDWAREFOGBLEND", 0, 1 },
  430. };
  431. static const ShaderComboSemantics_t phong_vs20_combos =
  432. {
  433. "phong_vs20", s_DynamicComboArray_phong_vs20, 8, s_StaticComboArray_phong_vs20, 6
  434. };
  435. class ConstructMe_phong_vs20
  436. {
  437. public:
  438. ConstructMe_phong_vs20()
  439. {
  440. GetShaderDLL()->AddShaderComboInformation( &phong_vs20_combos );
  441. }
  442. };
  443. static ConstructMe_phong_vs20 s_ConstructMe_phong_vs20;