shadowMapPass.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _SHADOWMAPPASS_H_
  23. #define _SHADOWMAPPASS_H_
  24. #ifndef _RENDERPASSMANAGER_H_
  25. #include "renderInstance/renderPassManager.h"
  26. #endif
  27. #ifndef _RENDERMESHMGR_H_
  28. #include "renderInstance/renderMeshMgr.h"
  29. #endif
  30. #ifndef _LIGHTINFO_H_
  31. #include "lighting/lightInfo.h"
  32. #endif
  33. #ifndef _SHADOW_COMMON_H_
  34. #include "lighting/shadowMap/shadowCommon.h"
  35. #endif
  36. class RenderMeshMgr;
  37. class LightShadowMap;
  38. class LightManager;
  39. class ShadowMapManager;
  40. class BaseMatInstance;
  41. class RenderObjectMgr;
  42. class RenderTerrainMgr;
  43. class PlatformTimer;
  44. class ShadowRenderPassManager;
  45. class DynamicShadowRenderPassManager;
  46. /// ShadowMapPass, this is plugged into the SceneManager to generate
  47. /// ShadowMaps for the scene.
  48. class ShadowMapPass
  49. {
  50. public:
  51. ShadowMapPass() {} // Only called by ConsoleSystem
  52. ShadowMapPass(LightManager* LightManager, ShadowMapManager* ShadowManager);
  53. virtual ~ShadowMapPass();
  54. //
  55. // SceneRenderPass interface
  56. //
  57. /// Called to render a scene.
  58. void render( SceneManager *sceneGraph,
  59. const SceneRenderState *diffuseState,
  60. U32 objectMask );
  61. /// Return the type of pass this is
  62. virtual const String& getPassType() const { return PassTypeName; };
  63. /// Return our sort value. (Go first in order to have shadow maps available for RIT_Objects)
  64. virtual F32 getSortValue() const { return 0.0f; }
  65. virtual bool geometryOnly() const { return true; }
  66. static const String PassTypeName;
  67. /// Used to for debugging performance by disabling
  68. /// shadow updates and rendering.
  69. static bool smDisableShadows;
  70. static bool smDisableShadowsEditor;
  71. static bool smDisableShadowsPref;
  72. /// distance moved per frame before forcing a shadow update
  73. static F32 smShadowsTeleportDist;
  74. /// angle turned per frame before forcing a shadow update
  75. static F32 smShadowsTurnRate;
  76. private:
  77. static U32 smActiveShadowMaps;
  78. static U32 smUpdatedShadowMaps;
  79. static U32 smNearShadowMaps;
  80. static U32 smShadowMapsDrawCalls;
  81. static U32 smShadowMapPolyCount;
  82. static U32 smRenderTargetChanges;
  83. static U32 smShadowPoolTexturesCount;
  84. static F32 smShadowPoolMemory;
  85. /// The milliseconds alotted for shadow map updates
  86. /// on a per frame basis.
  87. static U32 smRenderBudgetMs;
  88. PlatformTimer *mTimer;
  89. LightInfoList mLights;
  90. U32 mActiveLights;
  91. SimObjectPtr<ShadowRenderPassManager> mShadowRPM;
  92. SimObjectPtr<DynamicShadowRenderPassManager> mDynamicShadowRPM;
  93. LightManager* mLightManager;
  94. ShadowMapManager* mShadowManager;
  95. Point3F mPrevCamPos;
  96. Point3F mPrevCamRot;
  97. F32 mPrevCamFov;
  98. };
  99. class ShadowRenderPassManager : public RenderPassManager
  100. {
  101. typedef RenderPassManager Parent;
  102. public:
  103. ShadowRenderPassManager() : Parent() {}
  104. /// Add a RenderInstance to the list
  105. virtual void addInst( RenderInst *inst );
  106. };
  107. class DynamicShadowRenderPassManager : public RenderPassManager
  108. {
  109. typedef RenderPassManager Parent;
  110. public:
  111. DynamicShadowRenderPassManager() : Parent() {}
  112. /// Add a RenderInstance to the list
  113. virtual void addInst(RenderInst *inst);
  114. };
  115. #endif // _SHADOWMAPPASS_H_