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