Torque3D Documentation / _generateds / basicLightManager.h

basicLightManager.h

Engine/source/lighting/basic/basicLightManager.h

More...

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 RenderPrePassMgr;
 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<RenderPrePassMgr> mPrePassRenderBin;
 82
 83   struct LightingShaderConstants
 84   {
 85      bool mInit;
 86
 87      GFXShaderRef mShader;
 88
 89      GFXShaderConstHandle *mLightPosition;
 90      GFXShaderConstHandle *mLightDiffuse;
 91      GFXShaderConstHandle *mLightAmbient;
 92      GFXShaderConstHandle *mLightInvRadiusSq;
 93      GFXShaderConstHandle *mLightSpotDir;
 94      GFXShaderConstHandle *mLightSpotAngle;
 95     GFXShaderConstHandle *mLightSpotFalloff;
 96
 97      LightingShaderConstants();
 98      ~LightingShaderConstants();
 99
100      void init( GFXShader *shader );
101
102      void _onShaderReload();
103   };
104
105   typedef Map<GFXShader*, LightingShaderConstants*> LightConstantMap;
106
107   LightConstantMap mConstantLookup;
108   GFXShaderRef mLastShader;
109   LightingShaderConstants* mLastConstants;
110   
111   /// Statics used for light manager/projected shadow metrics.
112   static U32 smActiveShadowPlugins;
113   static U32 smShadowsUpdated;
114   static U32 smElapsedUpdateMs;
115
116   /// This is used to determine the distance
117   /// at which the shadow filtering PostEffect
118   /// will be enabled for ProjectedShadow.
119   static F32 smProjectedShadowFilterDistance;
120
121   /// A timer used for tracking update time.
122   PlatformTimer *mTimer;
123   
124   blTerrainSystem* mTerrainSystem;
125
126public:
127   // For ManagedSingleton.
128   static const char* getSingletonName() { return "BasicLightManager"; }   
129};
130
131#define BLM ManagedSingleton<BasicLightManager>::instance()
132
133#endif // _BASICLIGHTMANAGER_H_
134