shader.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WW3D *
  23. * *
  24. * $Archive:: /VSS_Sync/ww3d2/shader.h $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 10/26/01 2:56p $*
  29. * *
  30. * $Revision:: 17 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef SHADER_H
  39. #define SHADER_H
  40. #include "always.h"
  41. #if defined (SR_OS_SOLARIS)
  42. #undef PASS_MAX
  43. #endif
  44. class DX8Wrapper;
  45. struct W3dMaterial3Struct;
  46. // Re-written shader class
  47. // Hector Yee 1/24/01
  48. enum ShaderShiftConstants
  49. {
  50. SHIFT_DEPTHCOMPARE = 0, // bit shift for depth comparison setting
  51. SHIFT_DEPTHMASK = 3, // bit shift for depth mask setting
  52. SHIFT_COLORMASK = 4, // bit shift for color mask setting
  53. SHIFT_DSTBLEND = 5, // bit shift for destination blend setting
  54. SHIFT_FOG = 8, // bit shift for fog setting
  55. SHIFT_PRIGRADIENT = 10, // bit shift for primary gradient setting
  56. SHIFT_SECGRADIENT = 13, // bit shift for secondary gradient setting
  57. SHIFT_SRCBLEND = 14, // bit shift for source blend setting
  58. SHIFT_TEXTURING = 16, // bit shift for texturing setting (1 bit)
  59. SHIFT_NPATCHENABLE = 17, // bit shift for npatch enabling
  60. SHIFT_ALPHATEST = 18, // bit shift for alpha test setting
  61. SHIFT_CULLMODE = 19, // bit shift for cullmode setting
  62. SHIFT_POSTDETAILCOLORFUNC = 20, // bit shift for post-detail color function setting
  63. SHIFT_POSTDETAILALPHAFUNC = 24 // bit shift for post-detail alpha function setting
  64. };
  65. #define SHADE_CNST(depth_compare, depth_mask, color_mask, src_blend, dst_blend, fog, pri_grad, sec_grad, texture, alpha_test, cullmode, post_det_color, post_det_alpha) \
  66. ( (depth_compare) << SHIFT_DEPTHCOMPARE | (depth_mask) << SHIFT_DEPTHMASK | \
  67. (color_mask) << SHIFT_COLORMASK | (dst_blend) << SHIFT_DSTBLEND | (fog) << SHIFT_FOG | \
  68. (pri_grad) << SHIFT_PRIGRADIENT | (sec_grad) << SHIFT_SECGRADIENT | \
  69. (src_blend) << SHIFT_SRCBLEND | (texture) << SHIFT_TEXTURING | \
  70. (alpha_test) << SHIFT_ALPHATEST | (cullmode) << SHIFT_CULLMODE | \
  71. (post_det_color) << SHIFT_POSTDETAILCOLORFUNC | \
  72. (post_det_alpha) << SHIFT_POSTDETAILALPHAFUNC)
  73. class ShaderClass
  74. {
  75. friend DX8Wrapper;
  76. void Apply();
  77. public:
  78. enum AlphaTestType
  79. {
  80. ALPHATEST_DISABLE= 0,// disable alpha testing (default)
  81. ALPHATEST_ENABLE, // enable alpha testing
  82. ALPHATEST_MAX // end of enumeration
  83. };
  84. enum DepthCompareType
  85. {
  86. PASS_NEVER=0, // pass never
  87. PASS_LESS, // pass if incoming less than stored
  88. PASS_EQUAL, // pass if incoming equal to stored
  89. PASS_LEQUAL, // pass if incoming less than or equal to stored (default)
  90. PASS_GREATER, // pass if incoming greater than stored
  91. PASS_NOTEQUAL, // pass if incoming not equal to stored
  92. PASS_GEQUAL, // pass if incoming greater than or equal to stored
  93. PASS_ALWAYS, // pass always
  94. PASS_MAX // end of enumeration
  95. };
  96. enum DepthMaskType
  97. {
  98. DEPTH_WRITE_DISABLE=0, // disable depth buffer writes
  99. DEPTH_WRITE_ENABLE, // enable depth buffer writes (default)
  100. DEPTH_WRITE_MAX // end of enumeration
  101. };
  102. enum ColorMaskType
  103. {
  104. COLOR_WRITE_DISABLE=0, // disable color buffer writes
  105. COLOR_WRITE_ENABLE, // enable color buffer writes (default)
  106. COLOR_WRITE_MAX // end of enumeration
  107. };
  108. enum DetailAlphaFuncType
  109. {
  110. DETAILALPHA_DISABLE=0, // local (default)
  111. DETAILALPHA_DETAIL, // other
  112. DETAILALPHA_SCALE, // local * other
  113. DETAILALPHA_INVSCALE, // ~(~local * ~other) = local + (1-local)*other
  114. DETAILALPHA_MAX // end of enumeration
  115. };
  116. enum DetailColorFuncType
  117. {
  118. DETAILCOLOR_DISABLE=0, // 0000 local (default)
  119. DETAILCOLOR_DETAIL, // 0001 other
  120. DETAILCOLOR_SCALE, // 0010 local * other
  121. DETAILCOLOR_INVSCALE, // 0011 ~(~local * ~other) = local + (1-local)*other
  122. DETAILCOLOR_ADD, // 0100 local + other
  123. DETAILCOLOR_SUB, // 0101 local - other
  124. DETAILCOLOR_SUBR, // 0110 other - local
  125. DETAILCOLOR_BLEND, // 0111 (localAlpha)*local + (~localAlpha)*other
  126. DETAILCOLOR_DETAILBLEND, // 1000 (otherAlpha)*local + (~otherAlpha)*other
  127. DETAILCOLOR_MAX // end of enumeration
  128. };
  129. enum CullModeType
  130. {
  131. CULL_MODE_DISABLE=0,
  132. CULL_MODE_ENABLE,
  133. CULL_MODE_MAX
  134. };
  135. enum NPatchEnableType
  136. {
  137. NPATCH_DISABLE=0,
  138. NPATCH_ENABLE,
  139. NPATCH_TYPE_MAX
  140. };
  141. enum DstBlendFuncType
  142. {
  143. DSTBLEND_ZERO=0, // destination pixel doesn't affect blending (default)
  144. DSTBLEND_ONE, // destination pixel added unmodified
  145. DSTBLEND_SRC_COLOR, // destination pixel multiplied by fragment RGB components
  146. DSTBLEND_ONE_MINUS_SRC_COLOR, // destination pixel multiplied by one minus (i.e. inverse) fragment RGB components
  147. DSTBLEND_SRC_ALPHA, // destination pixel multiplied by fragment alpha component
  148. DSTBLEND_ONE_MINUS_SRC_ALPHA, // destination pixel multiplied by fragment inverse alpha
  149. DSTBLEND_MAX // end of enumeration
  150. };
  151. enum FogFuncType
  152. {
  153. FOG_DISABLE=0, // don't perform fogging (default)
  154. FOG_ENABLE, // apply fog, f*fogColor + (1-f)*fragment
  155. FOG_SCALE_FRAGMENT, // fog scalar value multiplies fragment, (1-f)*fragment
  156. FOG_WHITE, // fog scalar value replaces fragment, f*fogColor
  157. FOG_MAX // end of enumeration
  158. };
  159. enum PriGradientType
  160. {
  161. GRADIENT_DISABLE=0, // 000 disable primary gradient (same as OpenGL 'decal' texture blend)
  162. GRADIENT_MODULATE, // 001 modulate fragment ARGB by gradient ARGB (default)
  163. GRADIENT_ADD, // 010 add gradient RGB to fragment RGB, copy gradient A to fragment A
  164. GRADIENT_BUMPENVMAP, // 011
  165. GRADIENT_BUMPENVMAPLUMINANCE, // 100
  166. GRADIENT_DOTPRODUCT3, // 101
  167. GRADIENT_MAX // end of enumeration
  168. };
  169. enum SecGradientType
  170. {
  171. SECONDARY_GRADIENT_DISABLE=0, // don't draw secondary gradient (default)
  172. SECONDARY_GRADIENT_ENABLE, // add secondary gradient RGB to fragment RGB
  173. SECONDARY_GRADIENT_MAX // end of enumeration
  174. };
  175. enum SrcBlendFuncType
  176. {
  177. SRCBLEND_ZERO=0, // fragment not added to color buffer
  178. SRCBLEND_ONE, // fragment added unmodified to color buffer (default)
  179. SRCBLEND_SRC_ALPHA, // fragment RGB components multiplied by fragment A
  180. SRCBLEND_ONE_MINUS_SRC_ALPHA, // fragment RGB components multiplied by fragment inverse (one minus) A
  181. SRCBLEND_MAX // end of enumeration
  182. };
  183. enum TexturingType
  184. {
  185. TEXTURING_DISABLE=0, // no texturing (treat fragment initial color as 1,1,1,1)
  186. TEXTURING_ENABLE, // enable texturing
  187. TEXTURING_MAX // end of enumeration
  188. };
  189. enum StaticSortCategoryType
  190. {
  191. SSCAT_OPAQUE,
  192. SSCAT_ALPHA_TEST,
  193. SSCAT_ADDITIVE,
  194. SSCAT_OTHER
  195. };
  196. enum
  197. {
  198. MASK_DEPTHCOMPARE = (7<<0), // mask for depth comparison setting
  199. MASK_DEPTHMASK = (1<<3), // mask for depth mask setting
  200. MASK_COLORMASK = (1<<4), // mask for color mask setting
  201. MASK_DSTBLEND = (7<<5), // mask for destination blend setting
  202. MASK_FOG = (3<<8), // mask for fog setting
  203. MASK_PRIGRADIENT = (7<<10), // mask for primary gradient setting
  204. MASK_SECGRADIENT = (1<<13), // mask for secondary gradient setting
  205. MASK_SRCBLEND = (3<<14), // mask for source blend setting
  206. MASK_TEXTURING = (1<<16), // mask for texturing setting
  207. MASK_NPATCHENABLE = (1<<17), // mask for npatch enable
  208. MASK_ALPHATEST = (1<<18), // mask for alpha test enable
  209. MASK_CULLMODE = (1<<19), // mask for cullmode setting
  210. MASK_POSTDETAILCOLORFUNC= (15<<20), // mask for post detail color function setting
  211. MASK_POSTDETAILALPHAFUNC= (7<<24) // mask for post detail alpha function setting
  212. };
  213. ShaderClass(void)
  214. { Reset(); }
  215. ShaderClass(const ShaderClass & s)
  216. { ShaderBits=s.ShaderBits; }
  217. ShaderClass(const unsigned int d)
  218. { ShaderBits=d; }
  219. bool operator == (const ShaderClass & s) { return ShaderBits == s.ShaderBits; }
  220. bool operator != (const ShaderClass & s) { return ShaderBits != s.ShaderBits; }
  221. inline unsigned int Get_Bits(void) const
  222. { return ShaderBits; }
  223. inline int Uses_Alpha(void) const
  224. {
  225. // check if alpha test is enabled
  226. if (Get_Alpha_Test() != ALPHATEST_DISABLE)
  227. return true;
  228. DstBlendFuncType dst = Get_Dst_Blend_Func();
  229. if (dst == DSTBLEND_SRC_ALPHA || dst == DSTBLEND_ONE_MINUS_SRC_ALPHA)
  230. return true;
  231. SrcBlendFuncType src = Get_Src_Blend_Func();
  232. return (src == SRCBLEND_SRC_ALPHA || src == SRCBLEND_ONE_MINUS_SRC_ALPHA);
  233. }
  234. inline int Uses_Fog(void) const
  235. {
  236. return (Get_Fog_Func() != FOG_DISABLE);
  237. }
  238. inline int Uses_Primary_Gradient(void) const
  239. {
  240. return (Get_Primary_Gradient() != GRADIENT_DISABLE);
  241. }
  242. inline int Uses_Secondary_Gradient(void) const
  243. {
  244. return (Get_Secondary_Gradient() != SECONDARY_GRADIENT_DISABLE);
  245. }
  246. inline int Uses_Texture(void) const
  247. { return (Get_Texturing() != TEXTURING_DISABLE); }
  248. inline int Uses_Post_Detail_Texture(void) const
  249. {
  250. if (Get_Texturing() == TEXTURING_DISABLE)
  251. return false;
  252. return ((Get_Post_Detail_Color_Func() != DETAILCOLOR_DISABLE) || (Get_Post_Detail_Alpha_Func() != DETAILALPHA_DISABLE));
  253. }
  254. inline void Reset(void);
  255. inline DepthCompareType Get_Depth_Compare(void) const { return (DepthCompareType)(ShaderBits&MASK_DEPTHCOMPARE>>SHIFT_DEPTHCOMPARE); }
  256. inline DepthMaskType Get_Depth_Mask(void) const { return (DepthMaskType)((ShaderBits&MASK_DEPTHMASK)>>SHIFT_DEPTHMASK); }
  257. inline ColorMaskType Get_Color_Mask(void) const { return (ColorMaskType)((ShaderBits&MASK_COLORMASK)>>SHIFT_COLORMASK); }
  258. inline DetailAlphaFuncType Get_Post_Detail_Alpha_Func(void) const { return (DetailAlphaFuncType)((ShaderBits&MASK_POSTDETAILALPHAFUNC)>>SHIFT_POSTDETAILALPHAFUNC); }
  259. inline DetailColorFuncType Get_Post_Detail_Color_Func(void) const { return (DetailColorFuncType)((ShaderBits&MASK_POSTDETAILCOLORFUNC)>>SHIFT_POSTDETAILCOLORFUNC); }
  260. inline AlphaTestType Get_Alpha_Test(void) const { return (AlphaTestType)((ShaderBits&MASK_ALPHATEST)>>SHIFT_ALPHATEST); }
  261. inline CullModeType Get_Cull_Mode(void) const { return (CullModeType)((ShaderBits&MASK_CULLMODE)>>SHIFT_CULLMODE); }
  262. inline DstBlendFuncType Get_Dst_Blend_Func(void) const { return (DstBlendFuncType)((ShaderBits&MASK_DSTBLEND)>>SHIFT_DSTBLEND); }
  263. inline FogFuncType Get_Fog_Func(void) const { return (FogFuncType)((ShaderBits&MASK_FOG)>>SHIFT_FOG); }
  264. inline PriGradientType Get_Primary_Gradient(void) const { return (PriGradientType)((ShaderBits&MASK_PRIGRADIENT)>>SHIFT_PRIGRADIENT); }
  265. inline SecGradientType Get_Secondary_Gradient(void) const { return (SecGradientType)((ShaderBits&MASK_SECGRADIENT)>>SHIFT_SECGRADIENT); }
  266. inline SrcBlendFuncType Get_Src_Blend_Func(void) const { return (SrcBlendFuncType)((ShaderBits&MASK_SRCBLEND)>>SHIFT_SRCBLEND); }
  267. inline TexturingType Get_Texturing(void) const { return (TexturingType)((ShaderBits&MASK_TEXTURING)>>SHIFT_TEXTURING); }
  268. inline NPatchEnableType Get_NPatch_Enable(void) const { return (NPatchEnableType)((ShaderBits&MASK_NPATCHENABLE)>>SHIFT_NPATCHENABLE); }
  269. inline void Set_Depth_Compare(DepthCompareType x) { ShaderBits&=~MASK_DEPTHCOMPARE;ShaderBits|=(x<<SHIFT_DEPTHCOMPARE); }
  270. inline void Set_Depth_Mask(DepthMaskType x) { ShaderBits&=~MASK_DEPTHMASK; ShaderBits|=(x<<SHIFT_DEPTHMASK); }
  271. inline void Set_Color_Mask(ColorMaskType x) { ShaderBits&=~MASK_COLORMASK; ShaderBits|=(x<<SHIFT_COLORMASK); }
  272. inline void Set_Post_Detail_Alpha_Func(DetailAlphaFuncType x) { ShaderBits&=~MASK_POSTDETAILALPHAFUNC;ShaderBits|=(x<<SHIFT_POSTDETAILALPHAFUNC); }
  273. inline void Set_Post_Detail_Color_Func(DetailColorFuncType x) { ShaderBits&=~MASK_POSTDETAILCOLORFUNC;ShaderBits|=(x<<SHIFT_POSTDETAILCOLORFUNC); }
  274. inline void Set_Alpha_Test(AlphaTestType x) { ShaderBits&=~MASK_ALPHATEST; ShaderBits|=(x<<SHIFT_ALPHATEST); }
  275. inline void Set_Cull_Mode(CullModeType x) { ShaderBits&=~MASK_CULLMODE; ShaderBits|=(x<<SHIFT_CULLMODE); }
  276. inline void Set_Dst_Blend_Func(DstBlendFuncType x) { ShaderBits&=~MASK_DSTBLEND; ShaderBits|=(x<<SHIFT_DSTBLEND); }
  277. inline void Set_Fog_Func(FogFuncType x) { ShaderBits&=~MASK_FOG; ShaderBits|=(x<<SHIFT_FOG); }
  278. inline void Set_Primary_Gradient(PriGradientType x) { ShaderBits&=~MASK_PRIGRADIENT;ShaderBits|=(x<<SHIFT_PRIGRADIENT); }
  279. inline void Set_Secondary_Gradient(SecGradientType x) { ShaderBits&=~MASK_SECGRADIENT;ShaderBits|=(x<<SHIFT_SECGRADIENT); }
  280. inline void Set_Src_Blend_Func(SrcBlendFuncType x) { ShaderBits&=~MASK_SRCBLEND;ShaderBits|=(x<<SHIFT_SRCBLEND); }
  281. inline void Set_Texturing(TexturingType x) { ShaderBits&=~MASK_TEXTURING; ShaderBits|=(x<<SHIFT_TEXTURING); }
  282. inline void Set_NPatch_Enable(NPatchEnableType x) { ShaderBits&=~MASK_NPATCHENABLE; ShaderBits|=(x<<SHIFT_NPATCHENABLE); }
  283. void Init_From_Material3(const W3dMaterial3Struct & mat3);
  284. void Enable_Fog (const char *source);
  285. // helper function for static sort system
  286. StaticSortCategoryType Get_SS_Category(void) const;
  287. int Guess_Sort_Level(void) const;
  288. // DX 8 state management routines
  289. static inline void Invalidate() { ShaderDirty=true; }
  290. // Global backface culling invert. This interface can be used to globally invert all backface
  291. // culling. This is a global setting and will affect everything being rendered. Typically it
  292. // should be left alone at the default setting. Renegade uses this feature to render the entire
  293. // scene's backfacing polygons only; this is used in a VIS-debugging process. In order for this
  294. // to work, you will have to ww3d::Flush all rendering before changing the setting back.
  295. // NORMAL USERS SHOULD NEVER CALL THESE FUNCTIONS!
  296. static void Invert_Backface_Culling(bool onoff);
  297. static bool Is_Backface_Culling_Inverted(void);
  298. // These are a bunch of predefined shaders for common cases. None of them
  299. // have fogging since "no fog" is the surrender default and usage of fog
  300. // changes from app to app - if you want a fogging shader just grab one of
  301. // these and add fog to it.
  302. // Texturing, zbuffer, primary gradient, no blending
  303. static ShaderClass _PresetOpaqueShader;
  304. // Texturing, zbuffer, primary gradient, additive blending
  305. static ShaderClass _PresetAdditiveShader;
  306. // Texturing, zbuffer, primary gradient, additive blending, bumpenvmap
  307. static ShaderClass _PresetBumpenvmapShader;
  308. // Texturing, zbuffer, primary gradient, alpha blending
  309. static ShaderClass _PresetAlphaShader;
  310. // Texturing, zbuffer, primary gradient, multiplicative blending
  311. static ShaderClass _PresetMultiplicativeShader;
  312. // Texturing, no zbuffer reading/writing, no gradients, no blending, no
  313. // fogging - mostly for opaque 2D objects.
  314. static ShaderClass _PresetOpaque2DShader;
  315. // Texturing, default zbuffer reading, no zbuffer writing, no gradients, no blending, no
  316. // fogging - mostly for opaque sprites
  317. static ShaderClass _PresetOpaqueSpriteShader;
  318. // Texturing, no zbuffer reading/writing, no gradients, additive blending,
  319. // no fogging - mostly for additive 2D objects.
  320. static ShaderClass _PresetAdditive2DShader;
  321. // Texturing, no zbuffer reading/writing, no gradients, alpha blending, no
  322. // fogging - mostly for alpha-blended 2D objects.
  323. static ShaderClass _PresetAlpha2DShader;
  324. // Texturing, default zbuffer reading, no zbuffer writing, no gradients,
  325. // additive blending, no fogging - mostly for use in additive sprite
  326. // objects.
  327. static ShaderClass _PresetAdditiveSpriteShader;
  328. // Texturing, default zbuffer reading, no zbuffer writing, no gradients,
  329. // alpha blending, no fogging - mostly for use in alpha-blended sprite
  330. // objects.
  331. static ShaderClass _PresetAlphaSpriteShader;
  332. // No texturing, default zbuffer reading/writing, primary gradient, no
  333. // blending, no fogging - mostly for use in solid-colored opaque objects.
  334. static ShaderClass _PresetOpaqueSolidShader;
  335. // No texturing, default zbuffer reading, no zbuffer writing, primary
  336. // gradient, additive blending, no fogging - mostly for use in
  337. // solid-colored additive objects.
  338. static ShaderClass _PresetAdditiveSolidShader;
  339. // No texturing, default zbuffer reading, no zbuffer writing, primary
  340. // gradient, alpha blending, no fogging - mostly for use in solid-colored
  341. // alpha-blended objects.
  342. static ShaderClass _PresetAlphaSolidShader;
  343. // Texturing, no zbuffer reading/writing, no gradients, no blending, alpha
  344. // testing, no fogging - mostly for "pure" alpha-tested 2D objects.
  345. static ShaderClass _PresetATest2DShader;
  346. // Texturing, default zbuffer reading and writing, no gradients, no
  347. // blending, alpha testing, no fogging - mostly for "pure" alpha-tested
  348. // sprite objects.
  349. static ShaderClass _PresetATestSpriteShader;
  350. // Texturing, no zbuffer reading/writing, no gradients, alpha blending AND
  351. // alpha testing, no fogging - mostly for alpha-tested and blended 2D
  352. // objects.
  353. static ShaderClass _PresetATestBlend2DShader;
  354. // Texturing, default zbuffer reading and writing, no gradients, alpha
  355. // blending AND alpha testing, no fogging - mostly for use in alpha-tested
  356. // and blended sprite objects.
  357. static ShaderClass _PresetATestBlendSpriteShader;
  358. // Texturing, no zbuffer reading/writing, no gradients, screen blending,
  359. // no fogging - mostly for screen-blended 2D objects.
  360. static ShaderClass _PresetScreen2DShader;
  361. // Texturing, default zbuffer reading, no zbuffer writing, no gradients,
  362. // screen blending, no fogging - mostly for use in screen-blended sprite
  363. // objects.
  364. static ShaderClass _PresetScreenSpriteShader;
  365. // Texturing, no zbuffer reading/writing, no gradients, multiplicative
  366. // blending, no fogging - mostly for multiplicatively blended 2D objects.
  367. static ShaderClass _PresetMultiplicative2DShader;
  368. // Texturing, default zbuffer reading, no zbuffer writing, no gradients,
  369. // multiplicative blending, no fogging - mostly for use in multiplicatively
  370. // blended sprite objects.
  371. static ShaderClass _PresetMultiplicativeSpriteShader;
  372. protected:
  373. // Debug warning.
  374. void Report_Unable_To_Fog (const char *source);
  375. unsigned int ShaderBits;
  376. static bool ShaderDirty;
  377. static unsigned long CurrentShader;
  378. };
  379. inline void ShaderClass::Reset()
  380. {
  381. ShaderBits=0;
  382. Set_Depth_Compare(PASS_LEQUAL);
  383. Set_Depth_Mask(DEPTH_WRITE_ENABLE);
  384. Set_Color_Mask(COLOR_WRITE_ENABLE);
  385. Set_Dst_Blend_Func(DSTBLEND_ZERO);
  386. Set_Fog_Func(FOG_DISABLE);
  387. Set_Primary_Gradient(GRADIENT_MODULATE);
  388. Set_Secondary_Gradient(SECONDARY_GRADIENT_DISABLE);
  389. Set_Src_Blend_Func(SRCBLEND_ONE);
  390. Set_Texturing(TEXTURING_DISABLE);
  391. Set_Alpha_Test(ALPHATEST_DISABLE);
  392. Set_Cull_Mode(CULL_MODE_ENABLE);
  393. Set_Post_Detail_Color_Func(DETAILCOLOR_DISABLE);
  394. Set_Post_Detail_Alpha_Func(DETAILALPHA_DISABLE);
  395. Set_NPatch_Enable(NPATCH_DISABLE);
  396. }
  397. #endif //SHADER_H