mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Reverse depth & 32F buffer format
-Adds reversed depth projection model, dramatically increasing depth buffer effective resolution. -Adds 32F depth 8U stencil format GFXFormatD32FS8X24 (following DX naming conventions). Note this is a 64-bit format, and likely not suitable for mobile platforms. Revert to GFXFormatD24S8 in renderManager.tscript for mobile & "ancient" platforms. -Corrects alignment of texture type details array.
This commit is contained in:
parent
c08fa359d2
commit
75625dc679
37 changed files with 91 additions and 57 deletions
|
|
@ -170,7 +170,7 @@ void CubeLightShadowMap::_render( RenderPassManager* renderPass,
|
|||
mTarget->attachTexture(GFXTextureTarget::Color0, mCubemap, i);
|
||||
mTarget->attachTexture(GFXTextureTarget::DepthStencil, _getDepthTarget( mTexSize, mTexSize ));
|
||||
GFX->setActiveRenderTarget(mTarget);
|
||||
GFX->clear( GFXClearTarget | GFXClearStencil | GFXClearZBuffer, ColorI(255,255,255,255), 1.0f, 0 );
|
||||
GFX->clear( GFXClearTarget | GFXClearStencil | GFXClearZBuffer, ColorI(255,255,255,255), 0.0f, 0 );
|
||||
|
||||
// Create scene state, prep it
|
||||
SceneManager* sceneManager = diffuseState->getSceneManager();
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ void DualParaboloidLightShadowMap::_render( RenderPassManager* renderPass,
|
|||
mTarget->attachTexture(GFXTextureTarget::Color0, mShadowMapTex);
|
||||
mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
|
||||
GFX->setActiveRenderTarget(mTarget);
|
||||
GFX->clear(GFXClearTarget | GFXClearStencil | GFXClearZBuffer, ColorI::WHITE, 1.0f, 0);
|
||||
GFX->clear(GFXClearTarget | GFXClearStencil | GFXClearZBuffer, ColorI::WHITE, 0.0f, 0);
|
||||
|
||||
const bool bUseSinglePassDPM = (p->shadowType == ShadowType_DualParaboloidSinglePass);
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ void ParaboloidLightShadowMap::_render( RenderPassManager* renderPass,
|
|||
mTarget->attachTexture( GFXTextureTarget::DepthStencil,
|
||||
_getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() ) );
|
||||
GFX->setActiveRenderTarget(mTarget);
|
||||
GFX->clear(GFXClearTarget | GFXClearStencil | GFXClearZBuffer, ColorI(255,255,255,255), 1.0f, 0);
|
||||
GFX->clear(GFXClearTarget | GFXClearStencil | GFXClearZBuffer, ColorI(255,255,255,255), 0.0f, 0);
|
||||
|
||||
// Create scene state, prep it
|
||||
SceneManager* sceneManager = diffuseState->getSceneManager();
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ void PSSMLightShadowMap::_roundProjection(const MatrixF& lightMat, const MatrixF
|
|||
{
|
||||
// Round to the nearest shadowmap texel, this helps reduce shimmering
|
||||
MatrixF currentProj = GFX->getProjectionMatrix();
|
||||
currentProj.reverseProjection();
|
||||
currentProj = cropMatrix * currentProj * lightMat;
|
||||
|
||||
// Project origin to screen.
|
||||
|
|
@ -226,13 +227,15 @@ void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
|
|||
mTarget->attachTexture( GFXTextureTarget::Color0, mShadowMapTex );
|
||||
mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
|
||||
GFX->setActiveRenderTarget( mTarget );
|
||||
GFX->clear( GFXClearStencil | GFXClearZBuffer | GFXClearTarget, ColorI(255,255,255), 1.0f, 0 );
|
||||
GFX->clear( GFXClearStencil | GFXClearZBuffer | GFXClearTarget, ColorI(255,255,255), 0.0f, 0 );
|
||||
|
||||
// Calculate our standard light matrices
|
||||
MatrixF lightMatrix;
|
||||
calcLightMatrices( lightMatrix, diffuseState->getCameraFrustum() );
|
||||
lightMatrix.inverse();
|
||||
MatrixF lightViewProj = GFX->getProjectionMatrix() * lightMatrix;
|
||||
MatrixF tempProjMat = GFX->getProjectionMatrix();
|
||||
tempProjMat.reverseProjection();
|
||||
MatrixF lightViewProj = tempProjMat * lightMatrix;
|
||||
|
||||
// TODO: This is just retrieving the near and far calculated
|
||||
// in calcLightMatrices... we should make that clear.
|
||||
|
|
@ -245,7 +248,7 @@ void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
|
|||
|
||||
_calcSplitPos(fullFrustum);
|
||||
|
||||
mWorldToLightProj = GFX->getProjectionMatrix() * toLightSpace;
|
||||
mWorldToLightProj = tempProjMat * toLightSpace;
|
||||
|
||||
// Apply the PSSM
|
||||
const F32 savedSmallestVisible = TSShapeInstance::smSmallestVisiblePixelSize;
|
||||
|
|
@ -320,7 +323,9 @@ void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
|
|||
|
||||
// Crop matrix multiply needs to be post-projection.
|
||||
MatrixF alightProj = GFX->getProjectionMatrix();
|
||||
alightProj.reverseProjection();
|
||||
alightProj = cropMatrix * alightProj;
|
||||
alightProj.reverseProjection();
|
||||
|
||||
// Set our new projection
|
||||
GFX->setProjectionMatrix(alightProj);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ void SingleLightShadowMap::_render( RenderPassManager* renderPass,
|
|||
mTarget->attachTexture( GFXTextureTarget::DepthStencil,
|
||||
_getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() ) );
|
||||
GFX->setActiveRenderTarget(mTarget);
|
||||
GFX->clear(GFXClearStencil | GFXClearZBuffer | GFXClearTarget, ColorI(255,255,255), 1.0f, 0);
|
||||
GFX->clear(GFXClearStencil | GFXClearZBuffer | GFXClearTarget, ColorI(255,255,255), 0.0f, 0);
|
||||
|
||||
SceneManager* sceneManager = diffuseState->getSceneManager();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue