advancedLightManager.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 _ADVANCEDLIGHTMANAGER_H_
  23. #define _ADVANCEDLIGHTMANAGER_H_
  24. #ifndef _SIMOBJECT_H_
  25. #include "console/simObject.h"
  26. #endif
  27. #ifndef _LIGHTMANAGER_H_
  28. #include "lighting/lightManager.h"
  29. #endif
  30. #ifndef _LIGHTINFO_H_
  31. #include "lighting/lightInfo.h"
  32. #endif
  33. #ifndef _GFXTEXTUREHANDLE_H_
  34. #include "gfx/gfxTextureHandle.h"
  35. #endif
  36. #ifndef _GFXTARGET_H_
  37. #include "gfx/gfxTarget.h"
  38. #endif
  39. #ifndef _TDICTIONARY_H_
  40. #include "core/util/tDictionary.h"
  41. #endif
  42. #ifndef _LIGHTSHADOWMAP_H_
  43. #include "lighting/shadowMap/lightShadowMap.h"
  44. #endif
  45. #ifndef _GFXPRIMITIVEBUFFER_H_
  46. #include "gfx/gfxPrimitiveBuffer.h"
  47. #endif
  48. #ifndef _GFXVERTEXBUFFER_H_
  49. #include "gfx/gfxVertexBuffer.h"
  50. #endif
  51. class AvailableSLInterfaces;
  52. class AdvancedLightBinManager;
  53. class RenderPrePassMgr;
  54. class BaseMatInstance;
  55. class MaterialParameters;
  56. class MaterialParameterHandle;
  57. class GFXShader;
  58. class GFXShaderConstHandle;
  59. class ShadowMapManager;
  60. class AdvancedLightManager : public LightManager
  61. {
  62. typedef LightManager Parent;
  63. public:
  64. /// Return the lightBinManager for this light manager.
  65. AdvancedLightBinManager* getLightBinManager() { return mLightBinManager; }
  66. // LightManager
  67. virtual bool isCompatible() const;
  68. virtual void activate( SceneManager *sceneManager );
  69. virtual void deactivate();
  70. virtual void registerGlobalLight(LightInfo *light, SimObject *obj);
  71. virtual void unregisterAllLights();
  72. virtual void setLightInfo( ProcessedMaterial *pmat,
  73. const Material *mat,
  74. const SceneData &sgData,
  75. const SceneRenderState *state,
  76. U32 pass,
  77. GFXShaderConstBuffer *shaderConsts );
  78. virtual bool setTextureStage( const SceneData &sgData,
  79. const U32 currTexFlag,
  80. const U32 textureSlot,
  81. GFXShaderConstBuffer *shaderConsts,
  82. ShaderConstHandles *handles );
  83. typedef GFXVertexPC LightVertex;
  84. GFXVertexBufferHandle<LightVertex> getSphereMesh(U32 &outNumPrimitives, GFXPrimitiveBuffer *&outPrimitives );
  85. GFXVertexBufferHandle<LightVertex> getConeMesh(U32 &outNumPrimitives, GFXPrimitiveBuffer *&outPrimitives );
  86. LightShadowMap* findShadowMapForObject( SimObject *object );
  87. protected:
  88. // LightManager
  89. virtual void _addLightInfoEx( LightInfo *lightInfo );
  90. virtual void _initLightFields();
  91. /// A simple protected singleton. Use LightManager::findByName()
  92. /// to access this light manager.
  93. /// @see LightManager::findByName()
  94. static AdvancedLightManager smSingleton;
  95. // These are protected because we're a singleton and
  96. // no one else should be creating us!
  97. AdvancedLightManager();
  98. virtual ~AdvancedLightManager();
  99. SimObjectPtr<AdvancedLightBinManager> mLightBinManager;
  100. SimObjectPtr<RenderPrePassMgr> mPrePassRenderBin;
  101. LightConstantMap mConstantLookup;
  102. GFXShaderRef mLastShader;
  103. LightingShaderConstants* mLastConstants;
  104. // Convex geometry for lights
  105. GFXVertexBufferHandle<LightVertex> mSphereGeometry;
  106. GFXPrimitiveBufferHandle mSphereIndices;
  107. U32 mSpherePrimitiveCount;
  108. GFXVertexBufferHandle<LightVertex> mConeGeometry;
  109. GFXPrimitiveBufferHandle mConeIndices;
  110. U32 mConePrimitiveCount;
  111. LightingShaderConstants* getLightingShaderConstants(GFXShaderConstBuffer* shader);
  112. };
  113. #endif // _ADVANCEDLIGHTMANAGER_H_