mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-09 13:44:32 +00:00
Merge db07f3d8d5 into 0b73e701ac
This commit is contained in:
commit
4fe95631e6
4 changed files with 212 additions and 149 deletions
|
|
@ -191,6 +191,16 @@ void PSSMLightShadowMap::_roundProjection(const MatrixF& lightMat, const MatrixF
|
|||
}
|
||||
|
||||
void PSSMLightShadowMap::_adjustScaleAndOffset(Box3F& clipAABB, Point3F& scale, Point3F& offset) {
|
||||
|
||||
const ShadowMapParams* params = mLight->getExtended<ShadowMapParams>();
|
||||
|
||||
F32 padding = params->shadowSoftness * (2.0f / (F32)mTexSize);
|
||||
|
||||
clipAABB.minExtents.x -= padding;
|
||||
clipAABB.minExtents.y -= padding;
|
||||
clipAABB.maxExtents.x += padding;
|
||||
clipAABB.maxExtents.y += padding;
|
||||
|
||||
scale.x = 2.0f / (clipAABB.maxExtents.x - clipAABB.minExtents.x);
|
||||
scale.y = 2.0f / (clipAABB.maxExtents.y - clipAABB.minExtents.y);
|
||||
scale.z = 1.0f;
|
||||
|
|
@ -469,7 +479,7 @@ void PSSMLightShadowMap::setShaderParameters(GFXShaderConstBuffer* params, Light
|
|||
params->setSafe( lsc->mOverDarkFactorPSSM, p->overDarkFactor);
|
||||
|
||||
// The softness is a factor of the texel size.
|
||||
params->setSafe( lsc->mShadowSoftnessConst, p->shadowSoftness * ( 1.0f / mTexSize ) );
|
||||
params->setSafe( lsc->mShadowSoftnessConst, p->shadowSoftness * ( 2.0f / mTexSize ) );
|
||||
}
|
||||
|
||||
void PSSMLightShadowMap::_calcPlanesCullForShadowCasters(Vector< Vector<PlaneF> > &out, const Frustum &viewFrustum, const Point3F &_ligthDir)
|
||||
|
|
|
|||
|
|
@ -112,6 +112,18 @@ void ShadowMaterialHook::init( BaseMatInstance *inMat )
|
|||
|
||||
mShadowMat[ShadowType_Spot] = newMat;
|
||||
|
||||
newMat = new ShadowMatInstance(shadowMat);
|
||||
newMat->setUserObject(inMat->getUserObject());
|
||||
newMat->getFeaturesDelegate().bind(&ShadowMaterialHook::_overrideFeatures);
|
||||
forced.setCullMode(GFXCullCW);
|
||||
forced.zBias = 1000.0f;
|
||||
forced.zSlopeBias = 1.0f;
|
||||
forced.setFillModeSolid();
|
||||
newMat->addStateBlockDesc(forced);
|
||||
forced.cullDefined = true;
|
||||
newMat->init(features, inMat->getVertexFormat());
|
||||
mShadowMat[ShadowType_PSSM] = newMat;
|
||||
|
||||
newMat = new ShadowMatInstance( shadowMat );
|
||||
newMat->setUserObject( inMat->getUserObject() );
|
||||
newMat->getFeaturesDelegate().bind( &ShadowMaterialHook::_overrideFeatures );
|
||||
|
|
@ -162,12 +174,6 @@ BaseMatInstance* ShadowMaterialHook::getShadowMat( ShadowType type ) const
|
|||
{
|
||||
AssertFatal( type < ShadowType_Count, "ShadowMaterialHook::getShadowMat() - Bad light type!" );
|
||||
|
||||
// The cubemap and pssm shadows use the same
|
||||
// spotlight material for shadows.
|
||||
if ( type == ShadowType_Spot ||
|
||||
type == ShadowType_PSSM )
|
||||
return mShadowMat[ShadowType_Spot];
|
||||
|
||||
// Get the specialized shadow material.
|
||||
return mShadowMat[type];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue