mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-21 12:25:30 +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
|
|
@ -37,6 +37,7 @@ public:
|
|||
virtual bool isDoubleSided() const = 0;
|
||||
virtual bool isLightmapped() const = 0;
|
||||
virtual bool castsShadows() const = 0;
|
||||
virtual bool castsDynamicShadows() const = 0;
|
||||
};
|
||||
|
||||
#endif // _BASEMATERIALDEFINITION_H_
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ Material::Material()
|
|||
mAlphaRef = 1;
|
||||
|
||||
mCastShadows = true;
|
||||
mCastDynamicShadows = true;
|
||||
|
||||
mPlanarReflection = false;
|
||||
|
||||
|
|
@ -288,7 +289,7 @@ void Material::initPersistFields()
|
|||
|
||||
addField( "useAnisotropic", TypeBool, Offset(mUseAnisotropic, Material), MAX_STAGES,
|
||||
"Use anisotropic filtering for the textures of this stage." );
|
||||
|
||||
|
||||
addField("envMap", TypeImageFilename, Offset(mEnvMapFilename, Material), MAX_STAGES,
|
||||
"The name of an environment map cube map to apply to this material." );
|
||||
|
||||
|
|
@ -390,6 +391,9 @@ void Material::initPersistFields()
|
|||
addField( "castShadows", TypeBool, Offset(mCastShadows, Material),
|
||||
"If set to false the lighting system will not cast shadows from this material." );
|
||||
|
||||
addField( "castDynamicShadows", TypeBool, Offset(mCastDynamicShadows, Material),
|
||||
"If set to false the lighting system will not cast dynamic shadows from this material." );
|
||||
|
||||
addField("planarReflection", TypeBool, Offset(mPlanarReflection, Material), "@internal" );
|
||||
|
||||
addField("translucent", TypeBool, Offset(mTranslucent, Material),
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ public:
|
|||
NormalizeCube,
|
||||
TexTarget,
|
||||
AccuMap,
|
||||
DynamicShadowMap,
|
||||
};
|
||||
|
||||
enum BlendOp
|
||||
|
|
@ -219,7 +220,7 @@ public:
|
|||
|
||||
/// The strength scalar for the detail normal map.
|
||||
F32 mDetailNormalMapStrength[MAX_STAGES];
|
||||
|
||||
|
||||
FileName mEnvMapFilename[MAX_STAGES];
|
||||
|
||||
/// This color is the diffuse color of the material
|
||||
|
|
@ -299,6 +300,7 @@ public:
|
|||
/// A generic setting which tells the system to skip
|
||||
/// generation of shadows from this material.
|
||||
bool mCastShadows;
|
||||
bool mCastDynamicShadows;
|
||||
|
||||
bool mAlphaTest;
|
||||
U32 mAlphaRef;
|
||||
|
|
@ -355,6 +357,7 @@ public:
|
|||
virtual void setAutoGenerated(bool isAutoGenerated) { mAutoGenerated = isAutoGenerated; }
|
||||
virtual bool isLightmapped() const;
|
||||
virtual bool castsShadows() const { return mCastShadows; }
|
||||
virtual bool castsDynamicShadows() const { return mCastDynamicShadows; }
|
||||
const String &getPath() const { return mPath; }
|
||||
|
||||
void flush();
|
||||
|
|
|
|||
|
|
@ -85,6 +85,14 @@ void ProcessedCustomMaterial::_setStageData()
|
|||
continue;
|
||||
}
|
||||
|
||||
if(filename.equal(String("$dynamicShadowMap"), String::NoCase))
|
||||
{
|
||||
rpd->mTexType[i] = Material::DynamicShadowMap;
|
||||
rpd->mSamplerNames[i] = mCustomMaterial->mSamplerNames[i];
|
||||
mMaxTex = i+1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(filename.equal(String("$dynamiclightmask"), String::NoCase))
|
||||
{
|
||||
rpd->mTexType[i] = Material::DynamicLightMask;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue