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:
Azaezel 2015-10-13 18:12:19 -05:00
parent 2044b2691e
commit 2753f562e8
54 changed files with 1477 additions and 464 deletions

View file

@ -106,6 +106,9 @@ class SceneCullingState
/// The root culling frustum, which may be different from the camera frustum
Frustum mCullingFrustum;
/// Extra planes for culling.
PlaneSetF mExtraPlanesCull;
/// Occluders that have been added to this render state. Adding an occluder does not
/// necessarily result in an occluder volume being added. To not repeatedly try to
/// process the same occluder object, all objects that are added are recorded here.
@ -301,6 +304,21 @@ class SceneCullingState
/// (or, if no zone is selected, all volumes in the outdoor zone) to the debug drawer.
void debugRenderCullingVolumes() const;
/// Set planes for extra culling
void setExtraPlanesCull( const PlaneSetF &cull) { mExtraPlanesCull = cull; }
/// Clear planes for extra culling.
void clearExtraPlanesCull() { mExtraPlanesCull = PlaneSetF(NULL, 0); }
/// Check extra planes culling
bool isOccludedWithExtraPlanesCull(const Box3F &box) const
{
if(mExtraPlanesCull.getNumPlanes())
return mExtraPlanesCull.testPotentialIntersection( box ) == GeometryOutside;
return false;
}
private:
typedef SceneZoneCullingState::CullingTestResult CullingTestResult;