shadowMapPass.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. /// ShadowMapPass, this is plugged into the SceneManager to generate
  46. /// ShadowMaps for the scene.
  47. class ShadowMapPass
  48. {
  49. public:
  50. ShadowMapPass() : mTimer(NULL), mLightManager(NULL), mShadowManager(NULL), mActiveLights(0), mPrevCamFov(90.0f) {} // Only called by ConsoleSystem
  51. ShadowMapPass(LightManager* LightManager, ShadowMapManager* ShadowManager);
  52. virtual ~ShadowMapPass();
  53. //
  54. // SceneRenderPass interface
  55. //
  56. /// Called to render a scene.
  57. void render( SceneManager *sceneGraph,
  58. const SceneRenderState *diffuseState,
  59. U32 objectMask );
  60. /// Return the type of pass this is
  61. virtual const String& getPassType() const { return PassTypeName; };
  62. /// Return our sort value. (Go first in order to have shadow maps available for RIT_Objects)
  63. virtual F32 getSortValue() const { return 0.0f; }
  64. virtual bool geometryOnly() const { return true; }
  65. static const String PassTypeName;
  66. /// Used to for debugging performance by disabling
  67. /// shadow updates and rendering.
  68. static bool smDisableShadows;
  69. static bool smDisableShadowsEditor;
  70. static bool smDisableShadowsPref;
  71. /// distance moved per frame before forcing a shadow update
  72. static F32 smShadowsTeleportDist;
  73. /// angle turned per frame before forcing a shadow update
  74. static F32 smShadowsTurnRate;
  75. private:
  76. static U32 smActiveShadowMaps;
  77. static U32 smUpdatedShadowMaps;
  78. static U32 smNearShadowMaps;
  79. static U32 smShadowMapsDrawCalls;
  80. static U32 smShadowMapPolyCount;
  81. static U32 smRenderTargetChanges;
  82. static U32 smShadowPoolTexturesCount;
  83. static F32 smShadowPoolMemory;
  84. /// The milliseconds alotted for shadow map updates
  85. /// on a per frame basis.
  86. static U32 smRenderBudgetMs;
  87. PlatformTimer *mTimer;
  88. LightInfoList mLights;
  89. U32 mActiveLights;
  90. SimObjectPtr<ShadowRenderPassManager> mShadowRPM;
  91. LightManager* mLightManager;
  92. ShadowMapManager* mShadowManager;
  93. Point3F mPrevCamPos;
  94. Point3F mPrevCamRot;
  95. F32 mPrevCamFov;
  96. };
  97. class ShadowRenderPassManager : public RenderPassManager
  98. {
  99. typedef RenderPassManager Parent;
  100. public:
  101. ShadowRenderPassManager() : Parent() {}
  102. /// Add a RenderInstance to the list
  103. virtual void addInst( RenderInst *inst );
  104. };
  105. #endif // _SHADOWMAPPASS_H_