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.

365 lines
8.0 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_vs20_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 <= 0 );
  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 ) <= 0 );
  27. m_nSFM = i ? 1 : 0;
  28. #ifdef _DEBUG
  29. m_bSFM = true;
  30. #endif
  31. }
  32. private:
  33. int m_nWORLD_NORMAL;
  34. #ifdef _DEBUG
  35. bool m_bWORLD_NORMAL;
  36. #endif
  37. public:
  38. void SetWORLD_NORMAL( int i )
  39. {
  40. Assert( i >= 0 && i <= 0 );
  41. m_nWORLD_NORMAL = i;
  42. #ifdef _DEBUG
  43. m_bWORLD_NORMAL = true;
  44. #endif
  45. }
  46. void SetWORLD_NORMAL( bool i )
  47. {
  48. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  49. m_nWORLD_NORMAL = i ? 1 : 0;
  50. #ifdef _DEBUG
  51. m_bWORLD_NORMAL = true;
  52. #endif
  53. }
  54. private:
  55. int m_nFLATTEN_STATIC_CONTROL_FLOW;
  56. #ifdef _DEBUG
  57. bool m_bFLATTEN_STATIC_CONTROL_FLOW;
  58. #endif
  59. public:
  60. void SetFLATTEN_STATIC_CONTROL_FLOW( int i )
  61. {
  62. Assert( i >= 0 && i <= 0 );
  63. m_nFLATTEN_STATIC_CONTROL_FLOW = i;
  64. #ifdef _DEBUG
  65. m_bFLATTEN_STATIC_CONTROL_FLOW = true;
  66. #endif
  67. }
  68. void SetFLATTEN_STATIC_CONTROL_FLOW( bool i )
  69. {
  70. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  71. m_nFLATTEN_STATIC_CONTROL_FLOW = i ? 1 : 0;
  72. #ifdef _DEBUG
  73. m_bFLATTEN_STATIC_CONTROL_FLOW = true;
  74. #endif
  75. }
  76. private:
  77. int m_nDOPIXELFOG;
  78. #ifdef _DEBUG
  79. bool m_bDOPIXELFOG;
  80. #endif
  81. public:
  82. void SetDOPIXELFOG( int i )
  83. {
  84. Assert( i >= 0 && i <= 1 );
  85. m_nDOPIXELFOG = i;
  86. #ifdef _DEBUG
  87. m_bDOPIXELFOG = true;
  88. #endif
  89. }
  90. void SetDOPIXELFOG( bool i )
  91. {
  92. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  93. m_nDOPIXELFOG = i ? 1 : 0;
  94. #ifdef _DEBUG
  95. m_bDOPIXELFOG = true;
  96. #endif
  97. }
  98. private:
  99. int m_nHARDWAREFOGBLEND;
  100. #ifdef _DEBUG
  101. bool m_bHARDWAREFOGBLEND;
  102. #endif
  103. public:
  104. void SetHARDWAREFOGBLEND( int i )
  105. {
  106. Assert( i >= 0 && i <= 0 );
  107. m_nHARDWAREFOGBLEND = i;
  108. #ifdef _DEBUG
  109. m_bHARDWAREFOGBLEND = true;
  110. #endif
  111. }
  112. void SetHARDWAREFOGBLEND( bool i )
  113. {
  114. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  115. m_nHARDWAREFOGBLEND = i ? 1 : 0;
  116. #ifdef _DEBUG
  117. m_bHARDWAREFOGBLEND = true;
  118. #endif
  119. }
  120. public:
  121. // CONSTRUCTOR
  122. phong_vs20_Static_Index( IShaderShadow *pShaderShadow, IMaterialVar **params )
  123. {
  124. #ifdef _DEBUG
  125. m_bSFM = false;
  126. #endif // _DEBUG
  127. m_nSFM = 0;
  128. #ifdef _DEBUG
  129. m_bWORLD_NORMAL = false;
  130. #endif // _DEBUG
  131. m_nWORLD_NORMAL = 0;
  132. #ifdef _DEBUG
  133. m_bFLATTEN_STATIC_CONTROL_FLOW = false;
  134. #endif // _DEBUG
  135. m_nFLATTEN_STATIC_CONTROL_FLOW = 0;
  136. #ifdef _DEBUG
  137. m_bDOPIXELFOG = true;
  138. #endif // _DEBUG
  139. m_nDOPIXELFOG = ( g_pHardwareConfig->SupportsPixelShaders_2_b() && !IS_FLAG_SET( MATERIAL_VAR_VERTEXFOG ) ) ? 1 : 0 ;
  140. #ifdef _DEBUG
  141. m_bHARDWAREFOGBLEND = true;
  142. #endif // _DEBUG
  143. m_nHARDWAREFOGBLEND = 0 ;
  144. }
  145. int GetIndex()
  146. {
  147. // Asserts to make sure that we aren't using any skipped combinations.
  148. // Asserts to make sure that we are setting all of the combination vars.
  149. #ifdef _DEBUG
  150. bool bAllStaticVarsDefined = m_bSFM && m_bWORLD_NORMAL && m_bFLATTEN_STATIC_CONTROL_FLOW && m_bDOPIXELFOG && m_bHARDWAREFOGBLEND;
  151. Assert( bAllStaticVarsDefined );
  152. #endif // _DEBUG
  153. return ( 8 * m_nSFM ) + ( 8 * m_nWORLD_NORMAL ) + ( 8 * m_nFLATTEN_STATIC_CONTROL_FLOW ) + ( 8 * m_nDOPIXELFOG ) + ( 16 * m_nHARDWAREFOGBLEND ) + 0;
  154. }
  155. };
  156. #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 + 0
  157. class phong_vs20_Dynamic_Index
  158. {
  159. private:
  160. int m_nCOMPRESSED_VERTS;
  161. #ifdef _DEBUG
  162. bool m_bCOMPRESSED_VERTS;
  163. #endif
  164. public:
  165. void SetCOMPRESSED_VERTS( int i )
  166. {
  167. Assert( i >= 0 && i <= 1 );
  168. m_nCOMPRESSED_VERTS = i;
  169. #ifdef _DEBUG
  170. m_bCOMPRESSED_VERTS = true;
  171. #endif
  172. }
  173. void SetCOMPRESSED_VERTS( bool i )
  174. {
  175. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  176. m_nCOMPRESSED_VERTS = i ? 1 : 0;
  177. #ifdef _DEBUG
  178. m_bCOMPRESSED_VERTS = true;
  179. #endif
  180. }
  181. private:
  182. int m_nSKINNING;
  183. #ifdef _DEBUG
  184. bool m_bSKINNING;
  185. #endif
  186. public:
  187. void SetSKINNING( int i )
  188. {
  189. Assert( i >= 0 && i <= 1 );
  190. m_nSKINNING = i;
  191. #ifdef _DEBUG
  192. m_bSKINNING = true;
  193. #endif
  194. }
  195. void SetSKINNING( bool i )
  196. {
  197. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  198. m_nSKINNING = i ? 1 : 0;
  199. #ifdef _DEBUG
  200. m_bSKINNING = true;
  201. #endif
  202. }
  203. private:
  204. int m_nMORPHING;
  205. #ifdef _DEBUG
  206. bool m_bMORPHING;
  207. #endif
  208. public:
  209. void SetMORPHING( int i )
  210. {
  211. Assert( i >= 0 && i <= 0 );
  212. m_nMORPHING = i;
  213. #ifdef _DEBUG
  214. m_bMORPHING = true;
  215. #endif
  216. }
  217. void SetMORPHING( bool i )
  218. {
  219. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  220. m_nMORPHING = i ? 1 : 0;
  221. #ifdef _DEBUG
  222. m_bMORPHING = true;
  223. #endif
  224. }
  225. private:
  226. int m_nTESSELLATION;
  227. #ifdef _DEBUG
  228. bool m_bTESSELLATION;
  229. #endif
  230. public:
  231. void SetTESSELLATION( int i )
  232. {
  233. Assert( i >= 0 && i <= 0 );
  234. m_nTESSELLATION = i;
  235. #ifdef _DEBUG
  236. m_bTESSELLATION = true;
  237. #endif
  238. }
  239. void SetTESSELLATION( bool i )
  240. {
  241. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  242. m_nTESSELLATION = i ? 1 : 0;
  243. #ifdef _DEBUG
  244. m_bTESSELLATION = true;
  245. #endif
  246. }
  247. private:
  248. int m_nNUM_LIGHTS;
  249. #ifdef _DEBUG
  250. bool m_bNUM_LIGHTS;
  251. #endif
  252. public:
  253. void SetNUM_LIGHTS( int i )
  254. {
  255. Assert( i >= 0 && i <= 0 );
  256. m_nNUM_LIGHTS = i;
  257. #ifdef _DEBUG
  258. m_bNUM_LIGHTS = true;
  259. #endif
  260. }
  261. void SetNUM_LIGHTS( bool i )
  262. {
  263. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  264. m_nNUM_LIGHTS = i ? 1 : 0;
  265. #ifdef _DEBUG
  266. m_bNUM_LIGHTS = true;
  267. #endif
  268. }
  269. private:
  270. int m_nDOWATERFOG;
  271. #ifdef _DEBUG
  272. bool m_bDOWATERFOG;
  273. #endif
  274. public:
  275. void SetDOWATERFOG( int i )
  276. {
  277. Assert( i >= 0 && i <= 1 );
  278. m_nDOWATERFOG = i;
  279. #ifdef _DEBUG
  280. m_bDOWATERFOG = true;
  281. #endif
  282. }
  283. void SetDOWATERFOG( bool i )
  284. {
  285. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  286. m_nDOWATERFOG = i ? 1 : 0;
  287. #ifdef _DEBUG
  288. m_bDOWATERFOG = true;
  289. #endif
  290. }
  291. public:
  292. // CONSTRUCTOR
  293. phong_vs20_Dynamic_Index( IShaderDynamicAPI *pShaderAPI )
  294. {
  295. #ifdef _DEBUG
  296. m_bCOMPRESSED_VERTS = false;
  297. #endif // _DEBUG
  298. m_nCOMPRESSED_VERTS = 0;
  299. #ifdef _DEBUG
  300. m_bSKINNING = false;
  301. #endif // _DEBUG
  302. m_nSKINNING = 0;
  303. #ifdef _DEBUG
  304. m_bMORPHING = true;
  305. #endif // _DEBUG
  306. m_nMORPHING = false ;
  307. #ifdef _DEBUG
  308. m_bTESSELLATION = false;
  309. #endif // _DEBUG
  310. m_nTESSELLATION = 0;
  311. #ifdef _DEBUG
  312. m_bNUM_LIGHTS = false;
  313. #endif // _DEBUG
  314. m_nNUM_LIGHTS = 0;
  315. #ifdef _DEBUG
  316. m_bDOWATERFOG = true;
  317. #endif // _DEBUG
  318. m_nDOWATERFOG = ( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ;
  319. }
  320. int GetIndex()
  321. {
  322. // Asserts to make sure that we aren't using any skipped combinations.
  323. // Asserts to make sure that we are setting all of the combination vars.
  324. #ifdef _DEBUG
  325. bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING && m_bTESSELLATION && m_bNUM_LIGHTS && m_bDOWATERFOG;
  326. Assert( bAllDynamicVarsDefined );
  327. #endif // _DEBUG
  328. return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + ( 4 * m_nTESSELLATION ) + ( 4 * m_nNUM_LIGHTS ) + ( 4 * m_nDOWATERFOG ) + 0;
  329. }
  330. };
  331. #define shaderDynamicTest_phong_vs20 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 + 0
  332. static const ShaderComboInformation_t s_DynamicComboArray_phong_vs20[6] =
  333. {
  334. { "COMPRESSED_VERTS", 0, 1 },
  335. { "SKINNING", 0, 1 },
  336. { "MORPHING", 0, 0 },
  337. { "TESSELLATION", 0, 0 },
  338. { "NUM_LIGHTS", 0, 0 },
  339. { "DOWATERFOG", 0, 1 },
  340. };
  341. static const ShaderComboInformation_t s_StaticComboArray_phong_vs20[5] =
  342. {
  343. { "SFM", 0, 0 },
  344. { "WORLD_NORMAL", 0, 0 },
  345. { "FLATTEN_STATIC_CONTROL_FLOW", 0, 0 },
  346. { "DOPIXELFOG", 0, 1 },
  347. { "HARDWAREFOGBLEND", 0, 0 },
  348. };
  349. static const ShaderComboSemantics_t phong_vs20_combos =
  350. {
  351. "phong_vs20", s_DynamicComboArray_phong_vs20, 6, s_StaticComboArray_phong_vs20, 5
  352. };
  353. class ConstructMe_phong_vs20
  354. {
  355. public:
  356. ConstructMe_phong_vs20()
  357. {
  358. GetShaderDLL()->AddShaderComboInformation( &phong_vs20_combos );
  359. }
  360. };
  361. static ConstructMe_phong_vs20 s_ConstructMe_phong_vs20;