mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 04:50:31 +00:00
shadow caching
SPECIAL NOTE: highly suggest https://github.com/GarageGames/Torque3D/pull/1441 or a variation thereof to prevent debug spew and false-postives for occlusion results. With significant research, development and prototyping assistance from both @andr3wmac (shaders and partial hook work), and @LuisAntonRebollo (additional culling) System operates as follows: 1) materials are given an additional castDynamicShadows boolean entry. (Default at time of writing is true by request. Personal usage at time of writing defaults to false. value is default-initialized in materialDefinition.cpp. script/gui exposed) 2) lights are given a staticRefreshFreq and dynamicRefreshFreq (in milliseconds). script/gui exposed 3) materials are (effectively) sorted into dynamic and static shadowmap render lists based on flag. (see shadowMapPass.cpp) 4) initial shadowmaps are generated for each light and 'list'. 5) as each refreshFreq times out, the relevant shadowmap for a given light is refreshed. Special notes: dynamicRefreshFreq for all lights is set to a (script exposed) 8MS refresh timer. StaticRefreshFreq for the lions share of lights defaults to 250 MS (1/4 of a second) scattersky's embedded light, which is intended to operate in a mobile manner, defaults to 8 to reiterate, these are all customizable per-light via script/inspector gui in the case of alternate project needs.
This commit is contained in:
parent
2044b2691e
commit
2753f562e8
54 changed files with 1477 additions and 464 deletions
|
|
@ -47,6 +47,9 @@
|
|||
#ifndef _GFXSHADER_H_
|
||||
#include "gfx/gfxShader.h"
|
||||
#endif
|
||||
#ifndef _PLATFORM_PLATFORMTIMER_H_
|
||||
#include "platform/platformTimer.h"
|
||||
#endif
|
||||
|
||||
class ShadowMapManager;
|
||||
class SceneManager;
|
||||
|
|
@ -88,20 +91,13 @@ struct LightingShaderConstants
|
|||
GFXShaderConstHandle *mLightSpotFalloffSC;
|
||||
|
||||
GFXShaderConstHandle* mShadowMapSC;
|
||||
GFXShaderConstHandle* mDynamicShadowMapSC;
|
||||
GFXShaderConstHandle* mShadowMapSizeSC;
|
||||
|
||||
GFXShaderConstHandle* mCookieMapSC;
|
||||
|
||||
GFXShaderConstHandle* mRandomDirsConst;
|
||||
GFXShaderConstHandle* mShadowSoftnessConst;
|
||||
|
||||
GFXShaderConstHandle* mWorldToLightProjSC;
|
||||
GFXShaderConstHandle* mViewToLightProjSC;
|
||||
|
||||
GFXShaderConstHandle* mScaleXSC;
|
||||
GFXShaderConstHandle* mScaleYSC;
|
||||
GFXShaderConstHandle* mOffsetXSC;
|
||||
GFXShaderConstHandle* mOffsetYSC;
|
||||
GFXShaderConstHandle* mAtlasXOffsetSC;
|
||||
GFXShaderConstHandle* mAtlasYOffsetSC;
|
||||
GFXShaderConstHandle* mAtlasScaleSC;
|
||||
|
|
@ -109,11 +105,28 @@ struct LightingShaderConstants
|
|||
// fadeStartLength.x = Distance in eye space to start fading shadows
|
||||
// fadeStartLength.y = 1 / Length of fade
|
||||
GFXShaderConstHandle* mFadeStartLength;
|
||||
GFXShaderConstHandle* mFarPlaneScalePSSM;
|
||||
GFXShaderConstHandle* mOverDarkFactorPSSM;
|
||||
|
||||
GFXShaderConstHandle* mTapRotationTexSC;
|
||||
|
||||
// Static Specific:
|
||||
GFXShaderConstHandle* mWorldToLightProjSC;
|
||||
GFXShaderConstHandle* mViewToLightProjSC;
|
||||
GFXShaderConstHandle* mScaleXSC;
|
||||
GFXShaderConstHandle* mScaleYSC;
|
||||
GFXShaderConstHandle* mOffsetXSC;
|
||||
GFXShaderConstHandle* mOffsetYSC;
|
||||
GFXShaderConstHandle* mFarPlaneScalePSSM;
|
||||
|
||||
// Dynamic Specific:
|
||||
GFXShaderConstHandle* mDynamicWorldToLightProjSC;
|
||||
GFXShaderConstHandle* mDynamicViewToLightProjSC;
|
||||
GFXShaderConstHandle* mDynamicScaleXSC;
|
||||
GFXShaderConstHandle* mDynamicScaleYSC;
|
||||
GFXShaderConstHandle* mDynamicOffsetXSC;
|
||||
GFXShaderConstHandle* mDynamicOffsetYSC;
|
||||
GFXShaderConstHandle* mDynamicFarPlaneScalePSSM;
|
||||
|
||||
LightingShaderConstants();
|
||||
~LightingShaderConstants();
|
||||
|
||||
|
|
@ -147,7 +160,8 @@ public:
|
|||
virtual ~LightShadowMap();
|
||||
|
||||
void render( RenderPassManager* renderPass,
|
||||
const SceneRenderState *diffuseState );
|
||||
const SceneRenderState *diffuseState,
|
||||
bool _dynamic);
|
||||
|
||||
U32 getLastUpdate() const { return mLastUpdate; }
|
||||
|
||||
|
|
@ -237,6 +251,8 @@ protected:
|
|||
|
||||
/// The time this shadow was last updated.
|
||||
U32 mLastUpdate;
|
||||
PlatformTimer *mStaticRefreshTimer;
|
||||
PlatformTimer *mDynamicRefreshTimer;
|
||||
|
||||
/// The time this shadow was last culled and prioritized.
|
||||
U32 mLastCull;
|
||||
|
|
@ -274,6 +290,13 @@ protected:
|
|||
/// The callback used to get texture events.
|
||||
/// @see GFXTextureManager::addEventDelegate
|
||||
void _onTextureEvent( GFXTexCallbackCode code );
|
||||
|
||||
bool mIsDynamic;
|
||||
public:
|
||||
|
||||
bool isDynamic() { return mIsDynamic; }
|
||||
void setDynamic(bool value) { mIsDynamic = value; }
|
||||
|
||||
};
|
||||
|
||||
GFX_DeclareTextureProfile( ShadowMapProfile );
|
||||
|
|
@ -296,9 +319,9 @@ public:
|
|||
virtual void packUpdate( BitStream *stream ) const;
|
||||
virtual void unpackUpdate( BitStream *stream );
|
||||
|
||||
LightShadowMap* getShadowMap() const { return mShadowMap; }
|
||||
LightShadowMap* getShadowMap(bool _isDynamic = false) const { return _isDynamic ? mDynamicShadowMap : mShadowMap; }
|
||||
|
||||
LightShadowMap* getOrCreateShadowMap();
|
||||
LightShadowMap* getOrCreateShadowMap(bool _isDynamic = false);
|
||||
|
||||
bool hasCookieTex() const { return cookie.isNotEmpty(); }
|
||||
|
||||
|
|
@ -315,6 +338,7 @@ protected:
|
|||
|
||||
///
|
||||
LightShadowMap *mShadowMap;
|
||||
LightShadowMap *mDynamicShadowMap;
|
||||
|
||||
LightInfo *mLight;
|
||||
|
||||
|
|
@ -376,6 +400,7 @@ public:
|
|||
bool lastSplitTerrainOnly;
|
||||
|
||||
/// @}
|
||||
bool isDynamic;
|
||||
};
|
||||
|
||||
#endif // _LIGHTSHADOWMAP_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue