mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Reduce innecesary changes on Render Target textures.
This commit is contained in:
parent
c354f59b72
commit
c0b2e6536b
7 changed files with 29 additions and 9 deletions
|
|
@ -59,6 +59,7 @@ void DualParaboloidLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
mShadowMapTex.set( mTexSize * 2, mTexSize,
|
mShadowMapTex.set( mTexSize * 2, mTexSize,
|
||||||
ShadowMapFormat, &ShadowMapProfile,
|
ShadowMapFormat, &ShadowMapProfile,
|
||||||
"DualParaboloidLightShadowMap" );
|
"DualParaboloidLightShadowMap" );
|
||||||
|
mShadowMapDepth = _getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() );
|
||||||
}
|
}
|
||||||
|
|
||||||
GFXFrustumSaver frustSaver;
|
GFXFrustumSaver frustSaver;
|
||||||
|
|
@ -68,8 +69,7 @@ void DualParaboloidLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
GFX->pushActiveRenderTarget();
|
GFX->pushActiveRenderTarget();
|
||||||
|
|
||||||
mTarget->attachTexture(GFXTextureTarget::Color0, mShadowMapTex);
|
mTarget->attachTexture(GFXTextureTarget::Color0, mShadowMapTex);
|
||||||
mTarget->attachTexture( GFXTextureTarget::DepthStencil,
|
mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
|
||||||
_getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() ) );
|
|
||||||
GFX->setActiveRenderTarget(mTarget);
|
GFX->setActiveRenderTarget(mTarget);
|
||||||
GFX->clear(GFXClearTarget | GFXClearStencil | GFXClearZBuffer, ColorI::WHITE, 1.0f, 0);
|
GFX->clear(GFXClearTarget | GFXClearStencil | GFXClearZBuffer, ColorI::WHITE, 1.0f, 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,7 @@ protected:
|
||||||
GFXTextureTargetRef mTarget;
|
GFXTextureTargetRef mTarget;
|
||||||
U32 mTexSize;
|
U32 mTexSize;
|
||||||
GFXTexHandle mShadowMapTex;
|
GFXTexHandle mShadowMapTex;
|
||||||
|
GFXTexHandle mShadowMapDepth;
|
||||||
|
|
||||||
// The light we are rendering.
|
// The light we are rendering.
|
||||||
LightInfo *mLight;
|
LightInfo *mLight;
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,10 @@ void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
if ( mShadowMapTex.isNull() ||
|
if ( mShadowMapTex.isNull() ||
|
||||||
mNumSplits != params->numSplits ||
|
mNumSplits != params->numSplits ||
|
||||||
mTexSize != texSize )
|
mTexSize != texSize )
|
||||||
|
{
|
||||||
_setNumSplits( params->numSplits, texSize );
|
_setNumSplits( params->numSplits, texSize );
|
||||||
|
mShadowMapDepth = _getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() );
|
||||||
|
}
|
||||||
mLogWeight = params->logWeight;
|
mLogWeight = params->logWeight;
|
||||||
|
|
||||||
Frustum fullFrustum( diffuseState->getCameraFrustum() );
|
Frustum fullFrustum( diffuseState->getCameraFrustum() );
|
||||||
|
|
@ -216,8 +219,7 @@ void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
// Set our render target
|
// Set our render target
|
||||||
GFX->pushActiveRenderTarget();
|
GFX->pushActiveRenderTarget();
|
||||||
mTarget->attachTexture( GFXTextureTarget::Color0, mShadowMapTex );
|
mTarget->attachTexture( GFXTextureTarget::Color0, mShadowMapTex );
|
||||||
mTarget->attachTexture( GFXTextureTarget::DepthStencil,
|
mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
|
||||||
_getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() ) );
|
|
||||||
GFX->setActiveRenderTarget( mTarget );
|
GFX->setActiveRenderTarget( mTarget );
|
||||||
GFX->clear( GFXClearStencil | GFXClearZBuffer | GFXClearTarget, ColorI(255,255,255), 1.0f, 0 );
|
GFX->clear( GFXClearStencil | GFXClearZBuffer | GFXClearTarget, ColorI(255,255,255), 1.0f, 0 );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -218,24 +218,35 @@ void RenderFormatToken::_updateTargets()
|
||||||
// Update color target
|
// Update color target
|
||||||
if(mColorFormat != GFXFormat_COUNT)
|
if(mColorFormat != GFXFormat_COUNT)
|
||||||
{
|
{
|
||||||
|
// try reuse of old color texture
|
||||||
|
if( !mTargetColorTexture[i] || mTargetColorTexture[i].getFormat() != mColorFormat
|
||||||
|
|| mTargetColorTexture[i].getWidthHeight() != rtSize)
|
||||||
|
{
|
||||||
mTargetColorTexture[i].set( rtSize.x, rtSize.y, mColorFormat,
|
mTargetColorTexture[i].set( rtSize.x, rtSize.y, mColorFormat,
|
||||||
&GFXDefaultRenderTargetProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ),
|
&GFXDefaultRenderTargetProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ),
|
||||||
1, mTargetAALevel );
|
1, mTargetAALevel );
|
||||||
mTargetChain[i]->attachTexture( GFXTextureTarget::Color0, mTargetColorTexture[i] );
|
mTargetChain[i]->attachTexture( GFXTextureTarget::Color0, mTargetColorTexture[i] );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mTargetChain[i]->attachTexture( GFXTextureTarget::Color0, mTargetColorTexture[i] );
|
|
||||||
|
|
||||||
|
|
||||||
// Update depth target
|
// Update depth target
|
||||||
if(mDepthFormat != GFXFormat_COUNT)
|
if(mDepthFormat != GFXFormat_COUNT)
|
||||||
{
|
{
|
||||||
|
// try reuse of old depth texture
|
||||||
|
if( !mTargetDepthStencilTexture[i] || mTargetDepthStencilTexture[i].getFormat() != mColorFormat
|
||||||
|
|| mTargetDepthStencilTexture[i].getWidthHeight() != rtSize)
|
||||||
|
{
|
||||||
mTargetDepthStencilTexture[i].set( rtSize.x, rtSize.y, mDepthFormat,
|
mTargetDepthStencilTexture[i].set( rtSize.x, rtSize.y, mDepthFormat,
|
||||||
&GFXDefaultZTargetProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ),
|
&GFXDefaultZTargetProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ),
|
||||||
1, mTargetAALevel );
|
1, mTargetAALevel );
|
||||||
|
mTargetChain[i]->attachTexture( GFXTextureTarget::DepthStencil, mTargetDepthStencilTexture[i] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mTargetChain[i]->attachTexture( GFXTextureTarget::DepthStencil, mTargetDepthStencilTexture[i] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,11 +166,16 @@ bool RenderTexTargetBinManager::_updateTargets()
|
||||||
|
|
||||||
for( U32 j = 0; j < mNumRenderTargets; j++ )
|
for( U32 j = 0; j < mNumRenderTargets; j++ )
|
||||||
{
|
{
|
||||||
|
// try reuse of old color texture
|
||||||
|
if( mTargetChainTextures[i][j].getWidthHeight() != mTargetSize
|
||||||
|
|| mTargetChainTextures[i][j].getFormat() != mTargetFormat)
|
||||||
|
{
|
||||||
ret &= mTargetChainTextures[i][j].set( mTargetSize.x, mTargetSize.y, mTargetFormat,
|
ret &= mTargetChainTextures[i][j].set( mTargetSize.x, mTargetSize.y, mTargetFormat,
|
||||||
&GFXDefaultRenderTargetProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ),
|
&GFXDefaultRenderTargetProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ),
|
||||||
1, GFXTextureManager::AA_MATCH_BACKBUFFER );
|
1, GFXTextureManager::AA_MATCH_BACKBUFFER );
|
||||||
|
|
||||||
mTargetChain[i]->attachTexture( GFXTextureTarget::RenderSlot(GFXTextureTarget::Color0 + j), mTargetChainTextures[i][j] );
|
mTargetChain[i]->attachTexture( GFXTextureTarget::RenderSlot(GFXTextureTarget::Color0 + j), mTargetChainTextures[i][j] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -539,9 +539,10 @@ void PlaneReflector::updateReflection( const ReflectParams ¶ms )
|
||||||
if ( texResize ||
|
if ( texResize ||
|
||||||
reflectTex.isNull() ||
|
reflectTex.isNull() ||
|
||||||
reflectTex->getFormat() != REFLECTMGR->getReflectFormat() )
|
reflectTex->getFormat() != REFLECTMGR->getReflectFormat() )
|
||||||
|
{
|
||||||
reflectTex = REFLECTMGR->allocRenderTarget( texSize );
|
reflectTex = REFLECTMGR->allocRenderTarget( texSize );
|
||||||
|
depthBuff = LightShadowMap::_getDepthTarget( texSize.x, texSize.y );
|
||||||
GFXTexHandle depthBuff = LightShadowMap::_getDepthTarget( texSize.x, texSize.y );
|
}
|
||||||
|
|
||||||
// store current matrices
|
// store current matrices
|
||||||
GFXTransformSaver saver;
|
GFXTransformSaver saver;
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GFXTextureTargetRef reflectTarget;
|
GFXTextureTargetRef reflectTarget;
|
||||||
GFXTexHandle reflectTex;
|
GFXTexHandle reflectTex, depthBuff;;
|
||||||
PlaneF refplane;
|
PlaneF refplane;
|
||||||
bool objectSpace;
|
bool objectSpace;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue