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.

150 lines
5.2 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef SHADOWMGR_H
  9. #define SHADOWMGR_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "engine/ishadowmgr.h"
  14. #include "mathlib/vmatrix.h"
  15. #include "surfacehandle.h"
  16. #include "mathlib/ssemath.h"
  17. //-----------------------------------------------------------------------------
  18. // Forward declarations
  19. //-----------------------------------------------------------------------------
  20. class CDispInfo;
  21. //-----------------------------------------------------------------------------
  22. // Shadow decals are applied to a single surface
  23. //-----------------------------------------------------------------------------
  24. typedef unsigned short ShadowDecalHandle_t;
  25. enum
  26. {
  27. SHADOW_DECAL_HANDLE_INVALID = (ShadowDecalHandle_t)~0
  28. };
  29. //-----------------------------------------------------------------------------
  30. // This structure contains the vertex information for shadows
  31. //-----------------------------------------------------------------------------
  32. struct ShadowVertex_t
  33. {
  34. Vector m_Position;
  35. Vector m_ShadowSpaceTexCoord;
  36. };
  37. enum
  38. {
  39. SHADOW_VERTEX_TEMP_COUNT = 48
  40. };
  41. //-----------------------------------------------------------------------------
  42. // Used to clip the shadow decals
  43. //-----------------------------------------------------------------------------
  44. struct ShadowClipState_t
  45. {
  46. int m_CurrVert;
  47. int m_TempCount;
  48. int m_ClipCount;
  49. ShadowVertex_t m_pTempVertices[SHADOW_VERTEX_TEMP_COUNT];
  50. ShadowVertex_t* RESTRICT m_ppClipVertices[2][SHADOW_VERTEX_TEMP_COUNT];
  51. };
  52. //-----------------------------------------------------------------------------
  53. // This structure contains info to accelerate shadow darkness computation
  54. //-----------------------------------------------------------------------------
  55. struct ShadowDecalRenderInfo_t
  56. {
  57. Vector2D m_vTexOrigin;
  58. Vector2D m_vTexSize;
  59. float m_flFalloffOffset;
  60. float m_flOOZFalloffDist;
  61. float m_flFalloffAmount;
  62. float m_flFalloffBias;
  63. Vector m_vShadowFalloffParams; // params munged for use in the shader
  64. };
  65. //-----------------------------------------------------------------------------
  66. // Shadow-related functionality internal to the engine
  67. //-----------------------------------------------------------------------------
  68. abstract_class IShadowMgrInternal : public IShadowMgr
  69. {
  70. public:
  71. virtual void LevelInit( int nSurfCount ) = 0;
  72. virtual void LevelShutdown() = 0;
  73. // This surface has been rendered; and we'll want to render the shadows
  74. // on this surface
  75. virtual void AddShadowsOnSurfaceToRenderList( ShadowDecalHandle_t decalHandle ) = 0;
  76. // This will render all shadows that were previously added using
  77. // AddShadowsOnSurfaceToRenderList. If there's a model to world transform
  78. // for the shadow receiver, then send it in!
  79. // NOTE: This draws both shadows and projected textures.
  80. virtual void RenderProjectedTextures( IMatRenderContext *pRenderContext, VMatrix const* pModelToWorld = 0 ) = 0;
  81. // NOTE: This draws shadows
  82. virtual void RenderShadows( IMatRenderContext *pRenderContext, VMatrix const* pModelToWorld = 0 ) = 0;
  83. // NOTE: This draws flashlights
  84. virtual void RenderFlashlights( bool bDoMasking, bool bDoSimpleProjections, VMatrix const* pModelToWorld = 0 ) = 0;
  85. // Clears the list of shadows to render
  86. virtual void ClearShadowRenderList() = 0;
  87. // Projects + clips shadows
  88. // count + ppPosition describe an array of pointers to vertex positions
  89. // of the unclipped shadow
  90. // ppOutVertex is pointed to the head of an array of pointers to
  91. // clipped vertices the function returns the number of clipped vertices
  92. virtual int ProjectAndClipVertices( ShadowHandle_t handle, int count,
  93. Vector** ppPosition, ShadowVertex_t*** ppOutVertex ) = 0;
  94. // Computes information for rendering
  95. virtual void ComputeRenderInfo( ShadowDecalRenderInfo_t* pInfo, ShadowHandle_t handle ) const = 0;
  96. // Shadow state...
  97. virtual unsigned short InvalidShadowIndex( ) = 0;
  98. virtual void SetModelShadowState( ModelInstanceHandle_t instance ) = 0;
  99. virtual void SetNumWorldMaterialBuckets( int numMaterialSortBins ) = 0;
  100. virtual void DrawFlashlightDecals( IMatRenderContext *pRenderContext, int sortGroup, bool bDoMasking, float flFade = 1.0f ) = 0;
  101. virtual void DrawFlashlightDecalsOnSurfaceList( IMatRenderContext *pRenderContext, SurfaceHandle_t *pList, int listCount, bool bDoMasking ) = 0;
  102. virtual void DrawFlashlightOverlays( IMatRenderContext *pRenderContext, int nSortGroup, bool bDoMasking ) = 0;
  103. virtual void DrawFlashlightDepthTexture( ) = 0;
  104. virtual void DrawFlashlightDecalsOnDisplacements( IMatRenderContext *pRenderContext, int sortGroup, CDispInfo **visibleDisps, int nVisibleDisps, bool bDoMasking ) = 0;
  105. virtual void SetFlashlightStencilMasks( bool bDoMasking ) = 0;
  106. virtual bool ModelHasShadows( ModelInstanceHandle_t instance ) = 0;
  107. virtual int ProjectAndClipVerticesEx( ShadowHandle_t handle, int count,
  108. Vector** ppPosition, ShadowVertex_t*** ppOutVertex, ShadowClipState_t& clip ) = 0;
  109. };
  110. //-----------------------------------------------------------------------------
  111. // Singleton
  112. //-----------------------------------------------------------------------------
  113. #ifndef DEDICATED
  114. extern IShadowMgrInternal* g_pShadowMgr;
  115. #endif
  116. #endif