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.

338 lines
7.4 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. public:
  99. // CONSTRUCTOR
  100. phong_vs20_Static_Index( IShaderShadow *pShaderShadow, IMaterialVar **params )
  101. {
  102. #ifdef _DEBUG
  103. m_bSFM = false;
  104. #endif // _DEBUG
  105. m_nSFM = 0;
  106. #ifdef _DEBUG
  107. m_bWORLD_NORMAL = false;
  108. #endif // _DEBUG
  109. m_nWORLD_NORMAL = 0;
  110. #ifdef _DEBUG
  111. m_bFLATTEN_STATIC_CONTROL_FLOW = false;
  112. #endif // _DEBUG
  113. m_nFLATTEN_STATIC_CONTROL_FLOW = 0;
  114. #ifdef _DEBUG
  115. m_bDOPIXELFOG = true;
  116. #endif // _DEBUG
  117. m_nDOPIXELFOG = ( g_pHardwareConfig->SupportsPixelShaders_2_b() && !IS_FLAG_SET( MATERIAL_VAR_VERTEXFOG ) ) ? 1 : 0 ;
  118. }
  119. int GetIndex()
  120. {
  121. // Asserts to make sure that we aren't using any skipped combinations.
  122. // Asserts to make sure that we are setting all of the combination vars.
  123. #ifdef _DEBUG
  124. bool bAllStaticVarsDefined = m_bSFM && m_bWORLD_NORMAL && m_bFLATTEN_STATIC_CONTROL_FLOW && m_bDOPIXELFOG;
  125. Assert( bAllStaticVarsDefined );
  126. #endif // _DEBUG
  127. return ( 8 * m_nSFM ) + ( 8 * m_nWORLD_NORMAL ) + ( 8 * m_nFLATTEN_STATIC_CONTROL_FLOW ) + ( 8 * m_nDOPIXELFOG ) + 0;
  128. }
  129. };
  130. #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
  131. class phong_vs20_Dynamic_Index
  132. {
  133. private:
  134. int m_nCOMPRESSED_VERTS;
  135. #ifdef _DEBUG
  136. bool m_bCOMPRESSED_VERTS;
  137. #endif
  138. public:
  139. void SetCOMPRESSED_VERTS( int i )
  140. {
  141. Assert( i >= 0 && i <= 1 );
  142. m_nCOMPRESSED_VERTS = i;
  143. #ifdef _DEBUG
  144. m_bCOMPRESSED_VERTS = true;
  145. #endif
  146. }
  147. void SetCOMPRESSED_VERTS( bool i )
  148. {
  149. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  150. m_nCOMPRESSED_VERTS = i ? 1 : 0;
  151. #ifdef _DEBUG
  152. m_bCOMPRESSED_VERTS = true;
  153. #endif
  154. }
  155. private:
  156. int m_nSKINNING;
  157. #ifdef _DEBUG
  158. bool m_bSKINNING;
  159. #endif
  160. public:
  161. void SetSKINNING( int i )
  162. {
  163. Assert( i >= 0 && i <= 1 );
  164. m_nSKINNING = i;
  165. #ifdef _DEBUG
  166. m_bSKINNING = true;
  167. #endif
  168. }
  169. void SetSKINNING( bool i )
  170. {
  171. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  172. m_nSKINNING = i ? 1 : 0;
  173. #ifdef _DEBUG
  174. m_bSKINNING = true;
  175. #endif
  176. }
  177. private:
  178. int m_nMORPHING;
  179. #ifdef _DEBUG
  180. bool m_bMORPHING;
  181. #endif
  182. public:
  183. void SetMORPHING( int i )
  184. {
  185. Assert( i >= 0 && i <= 0 );
  186. m_nMORPHING = i;
  187. #ifdef _DEBUG
  188. m_bMORPHING = true;
  189. #endif
  190. }
  191. void SetMORPHING( bool i )
  192. {
  193. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  194. m_nMORPHING = i ? 1 : 0;
  195. #ifdef _DEBUG
  196. m_bMORPHING = true;
  197. #endif
  198. }
  199. private:
  200. int m_nTESSELLATION;
  201. #ifdef _DEBUG
  202. bool m_bTESSELLATION;
  203. #endif
  204. public:
  205. void SetTESSELLATION( int i )
  206. {
  207. Assert( i >= 0 && i <= 0 );
  208. m_nTESSELLATION = i;
  209. #ifdef _DEBUG
  210. m_bTESSELLATION = true;
  211. #endif
  212. }
  213. void SetTESSELLATION( bool i )
  214. {
  215. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  216. m_nTESSELLATION = i ? 1 : 0;
  217. #ifdef _DEBUG
  218. m_bTESSELLATION = true;
  219. #endif
  220. }
  221. private:
  222. int m_nNUM_LIGHTS;
  223. #ifdef _DEBUG
  224. bool m_bNUM_LIGHTS;
  225. #endif
  226. public:
  227. void SetNUM_LIGHTS( int i )
  228. {
  229. Assert( i >= 0 && i <= 0 );
  230. m_nNUM_LIGHTS = i;
  231. #ifdef _DEBUG
  232. m_bNUM_LIGHTS = true;
  233. #endif
  234. }
  235. void SetNUM_LIGHTS( bool i )
  236. {
  237. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 0 );
  238. m_nNUM_LIGHTS = i ? 1 : 0;
  239. #ifdef _DEBUG
  240. m_bNUM_LIGHTS = true;
  241. #endif
  242. }
  243. private:
  244. int m_nDOWATERFOG;
  245. #ifdef _DEBUG
  246. bool m_bDOWATERFOG;
  247. #endif
  248. public:
  249. void SetDOWATERFOG( int i )
  250. {
  251. Assert( i >= 0 && i <= 1 );
  252. m_nDOWATERFOG = i;
  253. #ifdef _DEBUG
  254. m_bDOWATERFOG = true;
  255. #endif
  256. }
  257. void SetDOWATERFOG( bool i )
  258. {
  259. Assert( ( i ? 1 : 0 ) >= 0 && ( i ? 1 : 0 ) <= 1 );
  260. m_nDOWATERFOG = i ? 1 : 0;
  261. #ifdef _DEBUG
  262. m_bDOWATERFOG = true;
  263. #endif
  264. }
  265. public:
  266. // CONSTRUCTOR
  267. phong_vs20_Dynamic_Index( IShaderDynamicAPI *pShaderAPI )
  268. {
  269. #ifdef _DEBUG
  270. m_bCOMPRESSED_VERTS = false;
  271. #endif // _DEBUG
  272. m_nCOMPRESSED_VERTS = 0;
  273. #ifdef _DEBUG
  274. m_bSKINNING = false;
  275. #endif // _DEBUG
  276. m_nSKINNING = 0;
  277. #ifdef _DEBUG
  278. m_bMORPHING = true;
  279. #endif // _DEBUG
  280. m_nMORPHING = false ;
  281. #ifdef _DEBUG
  282. m_bTESSELLATION = false;
  283. #endif // _DEBUG
  284. m_nTESSELLATION = 0;
  285. #ifdef _DEBUG
  286. m_bNUM_LIGHTS = false;
  287. #endif // _DEBUG
  288. m_nNUM_LIGHTS = 0;
  289. #ifdef _DEBUG
  290. m_bDOWATERFOG = true;
  291. #endif // _DEBUG
  292. m_nDOWATERFOG = ( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ;
  293. }
  294. int GetIndex()
  295. {
  296. // Asserts to make sure that we aren't using any skipped combinations.
  297. // Asserts to make sure that we are setting all of the combination vars.
  298. #ifdef _DEBUG
  299. bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING && m_bTESSELLATION && m_bNUM_LIGHTS && m_bDOWATERFOG;
  300. Assert( bAllDynamicVarsDefined );
  301. #endif // _DEBUG
  302. return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + ( 4 * m_nTESSELLATION ) + ( 4 * m_nNUM_LIGHTS ) + ( 4 * m_nDOWATERFOG ) + 0;
  303. }
  304. };
  305. #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
  306. static const ShaderComboInformation_t s_DynamicComboArray_phong_vs20[6] =
  307. {
  308. { "COMPRESSED_VERTS", 0, 1 },
  309. { "SKINNING", 0, 1 },
  310. { "MORPHING", 0, 0 },
  311. { "TESSELLATION", 0, 0 },
  312. { "NUM_LIGHTS", 0, 0 },
  313. { "DOWATERFOG", 0, 1 },
  314. };
  315. static const ShaderComboInformation_t s_StaticComboArray_phong_vs20[4] =
  316. {
  317. { "SFM", 0, 0 },
  318. { "WORLD_NORMAL", 0, 0 },
  319. { "FLATTEN_STATIC_CONTROL_FLOW", 0, 0 },
  320. { "DOPIXELFOG", 0, 1 },
  321. };
  322. static const ShaderComboSemantics_t phong_vs20_combos =
  323. {
  324. "phong_vs20", s_DynamicComboArray_phong_vs20, 6, s_StaticComboArray_phong_vs20, 4
  325. };
  326. class ConstructMe_phong_vs20
  327. {
  328. public:
  329. ConstructMe_phong_vs20()
  330. {
  331. GetShaderDLL()->AddShaderComboInformation( &phong_vs20_combos );
  332. }
  333. };
  334. static ConstructMe_phong_vs20 s_ConstructMe_phong_vs20;