basicLightManager.h
Engine/source/lighting/basic/basicLightManager.h
Classes:
Public Defines
define
BLM() <>::instance()
Detailed Description
Public Defines
BLM() <>::instance()
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 _BASICLIGHTMANAGER_H_ 25#define _BASICLIGHTMANAGER_H_ 26 27#ifndef _LIGHTMANAGER_H_ 28#include "lighting/lightManager.h" 29#endif 30#ifndef _TDICTIONARY_H_ 31#include "core/util/tDictionary.h" 32#endif 33#ifndef _GFXSHADER_H_ 34#include "gfx/gfxShader.h" 35#endif 36#ifndef _SIMOBJECT_H_ 37#include "console/simObject.h" 38#endif 39#ifndef _TSINGLETON_H_ 40#include "core/util/tSingleton.h" 41#endif 42 43class AvailableSLInterfaces; 44class GFXShaderConstHandle; 45class RenderDeferredMgr; 46class PlatformTimer; 47 48class blTerrainSystem; 49 50class BasicLightManager : public LightManager 51{ 52 typedef LightManager Parent; 53 54 // For access to protected constructor. 55 friend class ManagedSingleton<BasicLightManager>; 56 57public: 58 59 // LightManager 60 virtual bool isCompatible() const; 61 virtual void activate( SceneManager *sceneManager ); 62 virtual void deactivate(); 63 virtual void setLightInfo(ProcessedMaterial* pmat, const Material* mat, const SceneData& sgData, const SceneRenderState *state, U32 pass, GFXShaderConstBuffer* shaderConsts); 64 virtual bool setTextureStage(const SceneData& sgData, const U32 currTexFlag, const U32 textureSlot, GFXShaderConstBuffer* shaderConsts, ShaderConstHandles* handles) { return false; } 65 66 static F32 getShadowFilterDistance() { return smProjectedShadowFilterDistance; } 67 68protected: 69 70 // LightManager 71 virtual void _addLightInfoEx( LightInfo *lightInfo ) { } 72 virtual void _initLightFields() { } 73 74 void _onPreRender( SceneManager *sceneManger, const SceneRenderState *state ); 75 76 // These are protected because we're a singleton and 77 // no one else should be creating us! 78 BasicLightManager(); 79 virtual ~BasicLightManager(); 80 81 SimObjectPtr<RenderDeferredMgr> mDeferredRenderBin; 82 83 struct LightingShaderConstants 84 { 85 bool mInit; 86 87 GFXShaderRef mShader; 88 89 GFXShaderConstHandle *mLightPosition; 90 GFXShaderConstHandle *mLightDiffuse; 91 GFXShaderConstHandle *mLightAmbient; 92 GFXShaderConstHandle *mLightConfigDataSC; 93 GFXShaderConstHandle *mLightSpotDir; 94 GFXShaderConstHandle *mLightSpotParamsSC; 95 96 GFXShaderConstHandle* mHasVectorLightSC; 97 GFXShaderConstHandle* mVectorLightDirectionSC; 98 GFXShaderConstHandle* mVectorLightColorSC; 99 GFXShaderConstHandle* mVectorLightBrightnessSC; 100 101 LightingShaderConstants(); 102 ~LightingShaderConstants(); 103 104 void init( GFXShader *shader ); 105 106 void _onShaderReload(); 107 }; 108 109 typedef Map<GFXShader*, LightingShaderConstants*> LightConstantMap; 110 111 LightConstantMap mConstantLookup; 112 GFXShaderRef mLastShader; 113 LightingShaderConstants* mLastConstants; 114 115 /// Statics used for light manager/projected shadow metrics. 116 static U32 smActiveShadowPlugins; 117 static U32 smShadowsUpdated; 118 static U32 smElapsedUpdateMs; 119 120 /// This is used to determine the distance 121 /// at which the shadow filtering PostEffect 122 /// will be enabled for ProjectedShadow. 123 static F32 smProjectedShadowFilterDistance; 124 125 /// A timer used for tracking update time. 126 PlatformTimer *mTimer; 127 128 blTerrainSystem* mTerrainSystem; 129 130public: 131 // For ManagedSingleton. 132 static const char* getSingletonName() { return "BasicLightManager"; } 133}; 134 135#define BLM ManagedSingleton<BasicLightManager>::instance() 136 137#endif // _BASICLIGHTMANAGER_H_ 138