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.

419 lines
9.1 KiB

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