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.

208 lines
6.0 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef ISHADERSHADOW_H
  9. #define ISHADERSHADOW_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "shaderapi/shareddefs.h"
  14. #include <materialsystem/imaterial.h>
  15. //-----------------------------------------------------------------------------
  16. // forward declarations
  17. //-----------------------------------------------------------------------------
  18. class CMeshBuilder;
  19. class IMaterialVar;
  20. struct LightDesc_t;
  21. //-----------------------------------------------------------------------------
  22. // important enumerations
  23. //-----------------------------------------------------------------------------
  24. enum ShaderDepthFunc_t
  25. {
  26. SHADER_DEPTHFUNC_NEVER,
  27. SHADER_DEPTHFUNC_NEARER,
  28. SHADER_DEPTHFUNC_EQUAL,
  29. SHADER_DEPTHFUNC_NEAREROREQUAL,
  30. SHADER_DEPTHFUNC_FARTHER,
  31. SHADER_DEPTHFUNC_NOTEQUAL,
  32. SHADER_DEPTHFUNC_FARTHEROREQUAL,
  33. SHADER_DEPTHFUNC_ALWAYS
  34. };
  35. enum ShaderBlendFactor_t
  36. {
  37. SHADER_BLEND_ZERO,
  38. SHADER_BLEND_ONE,
  39. SHADER_BLEND_DST_COLOR,
  40. SHADER_BLEND_ONE_MINUS_DST_COLOR,
  41. SHADER_BLEND_SRC_ALPHA,
  42. SHADER_BLEND_ONE_MINUS_SRC_ALPHA,
  43. SHADER_BLEND_DST_ALPHA,
  44. SHADER_BLEND_ONE_MINUS_DST_ALPHA,
  45. SHADER_BLEND_SRC_ALPHA_SATURATE,
  46. SHADER_BLEND_SRC_COLOR,
  47. SHADER_BLEND_ONE_MINUS_SRC_COLOR
  48. };
  49. enum ShaderBlendOp_t
  50. {
  51. SHADER_BLEND_OP_ADD,
  52. SHADER_BLEND_OP_SUBTRACT,
  53. SHADER_BLEND_OP_REVSUBTRACT,
  54. SHADER_BLEND_OP_MIN,
  55. SHADER_BLEND_OP_MAX
  56. };
  57. enum ShaderAlphaFunc_t
  58. {
  59. SHADER_ALPHAFUNC_NEVER,
  60. SHADER_ALPHAFUNC_LESS,
  61. SHADER_ALPHAFUNC_EQUAL,
  62. SHADER_ALPHAFUNC_LEQUAL,
  63. SHADER_ALPHAFUNC_GREATER,
  64. SHADER_ALPHAFUNC_NOTEQUAL,
  65. SHADER_ALPHAFUNC_GEQUAL,
  66. SHADER_ALPHAFUNC_ALWAYS
  67. };
  68. enum ShaderTexChannel_t
  69. {
  70. SHADER_TEXCHANNEL_COLOR = 0,
  71. SHADER_TEXCHANNEL_ALPHA
  72. };
  73. enum ShaderPolyModeFace_t
  74. {
  75. SHADER_POLYMODEFACE_FRONT,
  76. SHADER_POLYMODEFACE_BACK,
  77. SHADER_POLYMODEFACE_FRONT_AND_BACK,
  78. };
  79. enum ShaderPolyMode_t
  80. {
  81. SHADER_POLYMODE_POINT,
  82. SHADER_POLYMODE_LINE,
  83. SHADER_POLYMODE_FILL
  84. };
  85. enum ShaderFogMode_t
  86. {
  87. SHADER_FOGMODE_DISABLED = 0,
  88. SHADER_FOGMODE_OO_OVERBRIGHT,
  89. SHADER_FOGMODE_BLACK,
  90. SHADER_FOGMODE_GREY,
  91. SHADER_FOGMODE_FOGCOLOR,
  92. SHADER_FOGMODE_WHITE,
  93. SHADER_FOGMODE_NUMFOGMODES
  94. };
  95. // m_ZBias has only two bits in ShadowState_t, so be careful extending this enum
  96. enum PolygonOffsetMode_t
  97. {
  98. SHADER_POLYOFFSET_DISABLE = 0x0,
  99. SHADER_POLYOFFSET_DECAL = 0x1,
  100. SHADER_POLYOFFSET_SHADOW_BIAS = 0x2,
  101. SHADER_POLYOFFSET_RESERVED = 0x3 // Reserved for future use
  102. };
  103. //-----------------------------------------------------------------------------
  104. // The Shader interface versions
  105. //-----------------------------------------------------------------------------
  106. #define SHADERSHADOW_INTERFACE_VERSION "ShaderShadow010"
  107. //-----------------------------------------------------------------------------
  108. // the shader API interface (methods called from shaders)
  109. //-----------------------------------------------------------------------------
  110. abstract_class IShaderShadow
  111. {
  112. public:
  113. // Sets the default *shadow* state
  114. virtual void SetDefaultState() = 0;
  115. // Methods related to depth buffering
  116. virtual void DepthFunc( ShaderDepthFunc_t depthFunc ) = 0;
  117. virtual void EnableDepthWrites( bool bEnable ) = 0;
  118. virtual void EnableDepthTest( bool bEnable ) = 0;
  119. virtual void EnablePolyOffset( PolygonOffsetMode_t nOffsetMode ) = 0;
  120. // Suppresses/activates color writing
  121. virtual void EnableColorWrites( bool bEnable ) = 0;
  122. virtual void EnableAlphaWrites( bool bEnable ) = 0;
  123. // Methods related to alpha blending
  124. virtual void EnableBlending( bool bEnable ) = 0;
  125. virtual void EnableBlendingForceOpaque( bool bEnable ) = 0; // enables alpha blending on a batch but does not force it to render with translucents
  126. virtual void BlendFunc( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor ) = 0;
  127. virtual void EnableBlendingSeparateAlpha( bool bEnable ) = 0;
  128. virtual void BlendFuncSeparateAlpha( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor ) = 0;
  129. // More below...
  130. // Alpha testing
  131. virtual void EnableAlphaTest( bool bEnable ) = 0;
  132. virtual void AlphaFunc( ShaderAlphaFunc_t alphaFunc, float alphaRef /* [0-1] */ ) = 0;
  133. // Wireframe/filled polygons
  134. virtual void PolyMode( ShaderPolyModeFace_t face, ShaderPolyMode_t polyMode ) = 0;
  135. // Back face culling
  136. virtual void EnableCulling( bool bEnable ) = 0;
  137. // Indicates the vertex format for use with a vertex shader
  138. // The flags to pass in here come from the VertexFormatFlags_t enum
  139. // If pTexCoordDimensions is *not* specified, we assume all coordinates
  140. // are 2-dimensional
  141. virtual void VertexShaderVertexFormat( unsigned int nFlags,
  142. int nTexCoordCount, int* pTexCoordDimensions, int nUserDataSize ) = 0;
  143. // Pixel and vertex shader methods
  144. virtual void SetVertexShader( const char* pFileName, int nStaticVshIndex ) = 0;
  145. virtual void SetPixelShader( const char* pFileName, int nStaticPshIndex = 0 ) = 0;
  146. // Convert from linear to gamma color space on writes to frame buffer.
  147. virtual void EnableSRGBWrite( bool bEnable ) = 0;
  148. // Convert from gamma to linear on texture fetch.
  149. virtual void EnableSRGBRead( Sampler_t sampler, bool bEnable ) = 0;
  150. // Per texture unit stuff
  151. virtual void EnableTexture( Sampler_t sampler, bool bEnable ) = 0;
  152. virtual void FogMode( ShaderFogMode_t fogMode, bool bVertexFog ) = 0;
  153. virtual void DisableFogGammaCorrection( bool bDisable ) = 0; //some blending modes won't work properly with corrected fog
  154. // Alpha to coverage
  155. virtual void EnableAlphaToCoverage( bool bEnable ) = 0;
  156. // Shadow map filtering
  157. //virtual void SetShadowDepthFiltering( Sampler_t stage ) = 0;
  158. // Per vertex texture unit stuff
  159. virtual void EnableVertexTexture( VertexTextureSampler_t sampler, bool bEnable ) = 0;
  160. // More alpha blending state
  161. virtual void BlendOp( ShaderBlendOp_t blendOp ) = 0;
  162. virtual void BlendOpSeparateAlpha( ShaderBlendOp_t blendOp ) = 0;
  163. virtual float GetLightMapScaleFactor( void ) const = 0;
  164. };
  165. // end class IShaderShadow
  166. #endif // ISHADERSHADOW_H