mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24: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
|
|
@ -531,7 +531,7 @@ void renderFrame(GFXTextureTargetRef* target, MatrixF transform, Frustum frustum
|
||||||
|
|
||||||
// Clear the current viewport area
|
// Clear the current viewport area
|
||||||
GFX->setViewport(targetRect);
|
GFX->setViewport(targetRect);
|
||||||
GFX->clear(GFXClearZBuffer | GFXClearStencil | GFXClearTarget, canvasClearColor, 1.0f, 0);
|
GFX->clear(GFXClearZBuffer | GFXClearStencil | GFXClearTarget, canvasClearColor, 0.0f, 0);
|
||||||
|
|
||||||
// Make sure we have a clean matrix state
|
// Make sure we have a clean matrix state
|
||||||
// before we start rendering anything!
|
// before we start rendering anything!
|
||||||
|
|
@ -555,7 +555,7 @@ void renderFrame(GFXTextureTargetRef* target, MatrixF transform, Frustum frustum
|
||||||
GFXTargetRef origTarget = GFX->getActiveRenderTarget();
|
GFXTargetRef origTarget = GFX->getActiveRenderTarget();
|
||||||
|
|
||||||
// Clear the zBuffer so GUI doesn't hose object rendering accidentally
|
// Clear the zBuffer so GUI doesn't hose object rendering accidentally
|
||||||
GFX->clear(GFXClearZBuffer, ColorI(20, 20, 20), 1.0f, 0);
|
GFX->clear(GFXClearZBuffer, ColorI(20, 20, 20), 0.0f, 0);
|
||||||
|
|
||||||
GFX->setFrustum(frustum);
|
GFX->setFrustum(frustum);
|
||||||
MatrixF mSaveProjection = GFX->getProjectionMatrix();
|
MatrixF mSaveProjection = GFX->getProjectionMatrix();
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ void LightFlareData::prepRender(SceneRenderState *state, LightFlareState *flareS
|
||||||
lightPosSS *= oneOverViewportExtent;
|
lightPosSS *= oneOverViewportExtent;
|
||||||
lightPosSS = (lightPosSS * 2.0f) - Point3F::One;
|
lightPosSS = (lightPosSS * 2.0f) - Point3F::One;
|
||||||
lightPosSS.y = -lightPosSS.y;
|
lightPosSS.y = -lightPosSS.y;
|
||||||
lightPosSS.z = 0.0f;
|
lightPosSS.z = 1.0f;
|
||||||
|
|
||||||
// Determine the center of the current projection so we can converge there
|
// Determine the center of the current projection so we can converge there
|
||||||
Point3F centerProj(0);
|
Point3F centerProj(0);
|
||||||
|
|
|
||||||
|
|
@ -1104,7 +1104,7 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
||||||
z_buf->attachTexture(GFXTextureTarget::Color0, mDepthBuffer);
|
z_buf->attachTexture(GFXTextureTarget::Color0, mDepthBuffer);
|
||||||
|
|
||||||
GFX->setActiveRenderTarget(z_buf);
|
GFX->setActiveRenderTarget(z_buf);
|
||||||
GFX->clear(GFXClearStencil | GFXClearTarget , ColorI(0,0,0,0), 1.0f, 0);
|
GFX->clear(GFXClearStencil | GFXClearTarget , ColorI(0,0,0,0), 0.0f, 0);
|
||||||
|
|
||||||
GFX->drawPrimitive(0);
|
GFX->drawPrimitive(0);
|
||||||
z_buf->resolve();
|
z_buf->resolve();
|
||||||
|
|
@ -1112,7 +1112,7 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
||||||
//render frontside to target mFrontBuffer
|
//render frontside to target mFrontBuffer
|
||||||
z_buf->attachTexture(GFXTextureTarget::DepthStencil, GFXTextureTarget::sDefaultDepthStencil);
|
z_buf->attachTexture(GFXTextureTarget::DepthStencil, GFXTextureTarget::sDefaultDepthStencil);
|
||||||
z_buf->attachTexture(GFXTextureTarget::Color0, mFrontBuffer);
|
z_buf->attachTexture(GFXTextureTarget::Color0, mFrontBuffer);
|
||||||
GFX->clear(GFXClearStencil | GFXClearTarget, ColorI(0, 0, 0, 0), 1.0f, 0);
|
GFX->clear(GFXClearStencil | GFXClearTarget, ColorI(0, 0, 0, 0), 0.0f, 0);
|
||||||
|
|
||||||
GFX->setStateBlock(mStateblock_preF);
|
GFX->setStateBlock(mStateblock_preF);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -604,7 +604,7 @@ void SkyBox::_initMaterial()
|
||||||
desc.setCullMode( GFXCullNone );
|
desc.setCullMode( GFXCullNone );
|
||||||
desc.setBlend( true );
|
desc.setBlend( true );
|
||||||
desc.setZReadWrite( true, false );
|
desc.setZReadWrite( true, false );
|
||||||
desc.zFunc = GFXCmpLessEqual;
|
desc.zFunc = GFXCmpGreaterEqual;
|
||||||
mMatInstance->addStateBlockDesc( desc );
|
mMatInstance->addStateBlockDesc( desc );
|
||||||
|
|
||||||
// Also disable lighting on the skybox material by default.
|
// Also disable lighting on the skybox material by default.
|
||||||
|
|
|
||||||
|
|
@ -714,7 +714,7 @@ void WaterPlane::prepRenderImage( SceneRenderState *state )
|
||||||
mGenerateVB = false;
|
mGenerateVB = false;
|
||||||
|
|
||||||
MatrixF proj( true );
|
MatrixF proj( true );
|
||||||
MathUtils::getZBiasProjectionMatrix( 0.0001f, mFrustum, &proj );
|
MathUtils::getZBiasProjectionMatrix( 0.0f, mFrustum, &proj );
|
||||||
mMatrixSet->setSceneProjection(proj);
|
mMatrixSet->setSceneProjection(proj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ void GFXD3D11EnumTranslate::init()
|
||||||
GFXD3D11TextureFormat[GFXFormatD24S8] = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
GFXD3D11TextureFormat[GFXFormatD24S8] = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||||
GFXD3D11TextureFormat[GFXFormatD24FS8] = DXGI_FORMAT_UNKNOWN;
|
GFXD3D11TextureFormat[GFXFormatD24FS8] = DXGI_FORMAT_UNKNOWN;
|
||||||
GFXD3D11TextureFormat[GFXFormatD16] = DXGI_FORMAT_D16_UNORM;
|
GFXD3D11TextureFormat[GFXFormatD16] = DXGI_FORMAT_D16_UNORM;
|
||||||
|
GFXD3D11TextureFormat[GFXFormatD32FS8X24] = DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
|
||||||
//sRGB
|
//sRGB
|
||||||
GFXD3D11TextureFormat[GFXFormatR8G8B8A8_SRGB] = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
GFXD3D11TextureFormat[GFXFormatR8G8B8A8_SRGB] = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
||||||
GFXD3D11TextureFormat[GFXFormatR8G8B8_SRGB] = DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;
|
GFXD3D11TextureFormat[GFXFormatR8G8B8_SRGB] = DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,12 @@ void GFXD3D11TextureManager::_innerCreateTexture( GFXD3D11TextureObject *retTex,
|
||||||
desc.CPUAccessFlags = cpuFlags;
|
desc.CPUAccessFlags = cpuFlags;
|
||||||
//depth stencil must be a typeless format if it is bound on render target and shader resource simultaneously
|
//depth stencil must be a typeless format if it is bound on render target and shader resource simultaneously
|
||||||
// we'll send the real format for the creation of the views
|
// we'll send the real format for the creation of the views
|
||||||
|
if (format == GFXFormatD24S8)
|
||||||
|
{
|
||||||
desc.Format = DXGI_FORMAT_R24G8_TYPELESS;
|
desc.Format = DXGI_FORMAT_R24G8_TYPELESS;
|
||||||
|
}
|
||||||
|
else // Note: right now only GFXFormatD24S8 and GFXFormatD32FS8U24 are supported. Additional cases required to support 16-bit depth for mobile.
|
||||||
|
desc.Format = DXGI_FORMAT_R32G8X24_TYPELESS;
|
||||||
desc.MipLevels = numMipLevels;
|
desc.MipLevels = numMipLevels;
|
||||||
desc.SampleDesc.Count = antialiasLevel;
|
desc.SampleDesc.Count = antialiasLevel;
|
||||||
desc.SampleDesc.Quality = numQualityLevels;
|
desc.SampleDesc.Quality = numQualityLevels;
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,7 @@ ImplementEnumType( GFXFormat,
|
||||||
{ GFXFormatD24S8, "GFXFormatD24S8" },
|
{ GFXFormatD24S8, "GFXFormatD24S8" },
|
||||||
{ GFXFormatD24FS8, "GFXFormatD24FS8" },
|
{ GFXFormatD24FS8, "GFXFormatD24FS8" },
|
||||||
{ GFXFormatD16, "GFXFormatD16" },
|
{ GFXFormatD16, "GFXFormatD16" },
|
||||||
|
{ GFXFormatD32FS8X24, "GFXFormatD32FS8X24" },
|
||||||
|
|
||||||
{ GFXFormatR32G32B32A32F, "GFXFormatR32G32B32A32F" },
|
{ GFXFormatR32G32B32A32F, "GFXFormatR32G32B32A32F" },
|
||||||
{ GFXFormatR16G16B16A16F, "GFXFormatR16G16B16A16F" },
|
{ GFXFormatR16G16B16A16F, "GFXFormatR16G16B16A16F" },
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ enum GFXFormat
|
||||||
// 64 bit texture formats...
|
// 64 bit texture formats...
|
||||||
GFXFormatR16G16B16A16,// first in group...
|
GFXFormatR16G16B16A16,// first in group...
|
||||||
GFXFormatR16G16B16A16F,
|
GFXFormatR16G16B16A16F,
|
||||||
|
GFXFormatD32FS8X24,
|
||||||
|
|
||||||
// 128 bit texture formats...
|
// 128 bit texture formats...
|
||||||
GFXFormatR32G32B32A32F,// first in group...
|
GFXFormatR32G32B32A32F,// first in group...
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ GFXFormatInfo::Data GFXFormatInfo::smFormatInfos[ GFXFormat_COUNT ] =
|
||||||
// 16 bit texture formats...
|
// 16 bit texture formats...
|
||||||
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatR5G6B5
|
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatR5G6B5
|
||||||
GFXFormatInfo::Data( 2, true, false, false ), // GFXFormatR5G5B5A1
|
GFXFormatInfo::Data( 2, true, false, false ), // GFXFormatR5G5B5A1
|
||||||
|
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatR5G5B5X1
|
||||||
GFXFormatInfo::Data( 2, true, false, false ), // GFXFormatA8L8
|
GFXFormatInfo::Data( 2, true, false, false ), // GFXFormatA8L8
|
||||||
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatL16
|
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatL16
|
||||||
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatR16F
|
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatR16F
|
||||||
|
|
@ -46,22 +47,28 @@ GFXFormatInfo::Data GFXFormatInfo::smFormatInfos[ GFXFormat_COUNT ] =
|
||||||
|
|
||||||
// 24 bit texture formats...
|
// 24 bit texture formats...
|
||||||
GFXFormatInfo::Data( 3, false, false, false ), // GFXFormatR8G8B8
|
GFXFormatInfo::Data( 3, false, false, false ), // GFXFormatR8G8B8
|
||||||
|
GFXFormatInfo::Data( 3, false, false, false ), // GFXFormatR8G8B8_SRGB
|
||||||
|
|
||||||
// 32 bit texture formats...
|
// 32 bit texture formats...
|
||||||
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatR8G8B8A8
|
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatR8G8B8A8
|
||||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatR8G8B8X8
|
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatR8G8B8X8
|
||||||
|
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatB8G8R8A8
|
||||||
|
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatR8G8B8A8_SRGB
|
||||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatR32F
|
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatR32F
|
||||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatR16G16
|
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatR16G16
|
||||||
GFXFormatInfo::Data( 4, false, false, true ), // GFXFormatR16G16F
|
GFXFormatInfo::Data( 4, false, false, true ), // GFXFormatR16G16F
|
||||||
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatR10G10B10A2
|
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatR10G10B10A2
|
||||||
|
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatR11G11B10
|
||||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD32
|
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD32
|
||||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD24X8
|
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD24X8
|
||||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD24S8
|
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD24S8
|
||||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD24FS8
|
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD24FS8
|
||||||
|
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatR8G8B8A8_LINEAR_FORCE
|
||||||
|
|
||||||
// 64 bit texture formats...
|
// 64 bit texture formats...
|
||||||
GFXFormatInfo::Data( 8, true, false, false ), // GFXFormatR16G16B16A16
|
GFXFormatInfo::Data( 8, true, false, false ), // GFXFormatR16G16B16A16
|
||||||
GFXFormatInfo::Data( 8, true, false, true ), // GFXFormatR16G16B16A16F
|
GFXFormatInfo::Data( 8, true, false, true ), // GFXFormatR16G16B16A16F
|
||||||
|
GFXFormatInfo::Data( 8, false, false, false ), // GFXFormatD32FS8X24
|
||||||
|
|
||||||
// 128 bit texture formats...
|
// 128 bit texture formats...
|
||||||
GFXFormatInfo::Data( 16, true, false, true ), // GFXFormatR32G32B32A32F
|
GFXFormatInfo::Data( 16, true, false, true ), // GFXFormatR32G32B32A32F
|
||||||
|
|
@ -72,6 +79,9 @@ GFXFormatInfo::Data GFXFormatInfo::smFormatInfos[ GFXFormat_COUNT ] =
|
||||||
GFXFormatInfo::Data( 0, true, true, false ), // GFXFormatBC3
|
GFXFormatInfo::Data( 0, true, true, false ), // GFXFormatBC3
|
||||||
GFXFormatInfo::Data( 0, false, true, false ), // GFXFormatBC4
|
GFXFormatInfo::Data( 0, false, true, false ), // GFXFormatBC4
|
||||||
GFXFormatInfo::Data( 0, false, true, false ), // GFXFormatBC5
|
GFXFormatInfo::Data( 0, false, true, false ), // GFXFormatBC5
|
||||||
|
GFXFormatInfo::Data( 0, false, true, false ), // GFXFormatBC1_SRGB
|
||||||
|
GFXFormatInfo::Data( 0, false, true, false ), // GFXFormatBC2_SRGB
|
||||||
|
GFXFormatInfo::Data( 0, false, true, false ), // GFXFormatBC3_SRGB
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ GFXStateBlockDesc::GFXStateBlockDesc()
|
||||||
zDefined = false;
|
zDefined = false;
|
||||||
zEnable = true;
|
zEnable = true;
|
||||||
zWriteEnable = true;
|
zWriteEnable = true;
|
||||||
zFunc = GFXCmpLessEqual;
|
zFunc = GFXCmpGreaterEqual;
|
||||||
zBias = 0;
|
zBias = 0;
|
||||||
zSlopeBias = 0;
|
zSlopeBias = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ void GFXStringEnumTranslate::init()
|
||||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24S8 );
|
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24S8 );
|
||||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24FS8 );
|
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24FS8 );
|
||||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD16 );
|
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD16 );
|
||||||
|
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD32FS8X24 );
|
||||||
|
|
||||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR32G32B32A32F );
|
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR32G32B32A32F );
|
||||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR16G16B16A16F );
|
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR16G16B16A16F );
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ void GFXGLDevice::initGLState()
|
||||||
glGenVertexArrays(1, &vao);
|
glGenVertexArrays(1, &vao);
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
|
|
||||||
|
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||||
//enable sRGB
|
//enable sRGB
|
||||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
|
||||||
|
|
@ -794,38 +795,26 @@ void GFXGLDevice::setClipRect( const RectI &inRect )
|
||||||
mClip = inRect;
|
mClip = inRect;
|
||||||
mClip.intersect(maxRect);
|
mClip.intersect(maxRect);
|
||||||
|
|
||||||
// Create projection matrix. See http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/ortho.html
|
|
||||||
const F32 left = mClip.point.x;
|
|
||||||
const F32 right = mClip.point.x + mClip.extent.x;
|
|
||||||
const F32 bottom = mClip.extent.y;
|
|
||||||
const F32 top = 0.0f;
|
|
||||||
const F32 nearPlane = 0.0f;
|
|
||||||
const F32 farPlane = 1.0f;
|
|
||||||
|
|
||||||
const F32 tx = -(right + left)/(right - left);
|
|
||||||
const F32 ty = -(top + bottom)/(top - bottom);
|
|
||||||
const F32 tz = -(farPlane + nearPlane)/(farPlane - nearPlane);
|
|
||||||
|
|
||||||
static Point4F pt;
|
static Point4F pt;
|
||||||
pt.set(2.0f / (right - left), 0.0f, 0.0f, 0.0f);
|
F32 l = F32(mClip.point.x);
|
||||||
|
F32 r = F32(mClip.point.x + mClip.extent.x);
|
||||||
|
F32 b = F32(mClip.point.y + mClip.extent.y);
|
||||||
|
F32 t = F32(mClip.point.y);
|
||||||
|
|
||||||
|
// Set up projection matrix,
|
||||||
|
//static Point4F pt;
|
||||||
|
pt.set(2.0f / (r - l), 0.0f, 0.0f, 0.0f);
|
||||||
mProjectionMatrix.setColumn(0, pt);
|
mProjectionMatrix.setColumn(0, pt);
|
||||||
|
|
||||||
pt.set(0.0f, 2.0f/(top - bottom), 0.0f, 0.0f);
|
pt.set(0.0f, 2.0f / (t - b), 0.0f, 0.0f);
|
||||||
mProjectionMatrix.setColumn(1, pt);
|
mProjectionMatrix.setColumn(1, pt);
|
||||||
|
|
||||||
pt.set(0.0f, 0.0f, -2.0f/(farPlane - nearPlane), 0.0f);
|
pt.set(0.0f, 0.0f, 1.0f, 0.0f);
|
||||||
mProjectionMatrix.setColumn(2, pt);
|
mProjectionMatrix.setColumn(2, pt);
|
||||||
|
|
||||||
pt.set(tx, ty, tz, 1.0f);
|
pt.set((l + r) / (l - r), (t + b) / (b - t), 1.0f, 1.0f);
|
||||||
mProjectionMatrix.setColumn(3, pt);
|
mProjectionMatrix.setColumn(3, pt);
|
||||||
|
|
||||||
// Translate projection matrix.
|
|
||||||
static MatrixF translate(true);
|
|
||||||
pt.set(0.0f, -mClip.point.y, 0.0f, 1.0f);
|
|
||||||
translate.setColumn(3, pt);
|
|
||||||
|
|
||||||
mProjectionMatrix *= translate;
|
|
||||||
|
|
||||||
MatrixF mTempMatrix(true);
|
MatrixF mTempMatrix(true);
|
||||||
setViewMatrix( mTempMatrix );
|
setViewMatrix( mTempMatrix );
|
||||||
setWorldMatrix( mTempMatrix );
|
setWorldMatrix( mTempMatrix );
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ void GFXGLEnumTranslate::init()
|
||||||
GFXGLTextureInternalFormat[GFXFormatD32] = GL_DEPTH_COMPONENT32;
|
GFXGLTextureInternalFormat[GFXFormatD32] = GL_DEPTH_COMPONENT32;
|
||||||
GFXGLTextureInternalFormat[GFXFormatD24X8] = GL_DEPTH24_STENCIL8;
|
GFXGLTextureInternalFormat[GFXFormatD24X8] = GL_DEPTH24_STENCIL8;
|
||||||
GFXGLTextureInternalFormat[GFXFormatD24S8] = GL_DEPTH24_STENCIL8;
|
GFXGLTextureInternalFormat[GFXFormatD24S8] = GL_DEPTH24_STENCIL8;
|
||||||
|
GFXGLTextureInternalFormat[GFXFormatD32FS8X24] = GL_DEPTH32F_STENCIL8;
|
||||||
GFXGLTextureInternalFormat[GFXFormatR16G16B16A16] = GL_RGBA16;
|
GFXGLTextureInternalFormat[GFXFormatR16G16B16A16] = GL_RGBA16;
|
||||||
GFXGLTextureInternalFormat[GFXFormatBC1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
GFXGLTextureInternalFormat[GFXFormatBC1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||||
GFXGLTextureInternalFormat[GFXFormatBC2] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
GFXGLTextureInternalFormat[GFXFormatBC2] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||||
|
|
@ -161,6 +162,7 @@ void GFXGLEnumTranslate::init()
|
||||||
GFXGLTextureFormat[GFXFormatD32] = GL_DEPTH_COMPONENT;
|
GFXGLTextureFormat[GFXFormatD32] = GL_DEPTH_COMPONENT;
|
||||||
GFXGLTextureFormat[GFXFormatD24X8] = GL_DEPTH_STENCIL;
|
GFXGLTextureFormat[GFXFormatD24X8] = GL_DEPTH_STENCIL;
|
||||||
GFXGLTextureFormat[GFXFormatD24S8] = GL_DEPTH_STENCIL;
|
GFXGLTextureFormat[GFXFormatD24S8] = GL_DEPTH_STENCIL;
|
||||||
|
GFXGLTextureFormat[GFXFormatD32FS8X24] = GL_DEPTH_STENCIL;
|
||||||
GFXGLTextureFormat[GFXFormatR16G16B16A16] = GL_RGBA;
|
GFXGLTextureFormat[GFXFormatR16G16B16A16] = GL_RGBA;
|
||||||
GFXGLTextureFormat[GFXFormatBC1] = GL_RGBA;
|
GFXGLTextureFormat[GFXFormatBC1] = GL_RGBA;
|
||||||
GFXGLTextureFormat[GFXFormatBC2] = GL_RGBA;
|
GFXGLTextureFormat[GFXFormatBC2] = GL_RGBA;
|
||||||
|
|
@ -190,6 +192,7 @@ void GFXGLEnumTranslate::init()
|
||||||
GFXGLTextureType[GFXFormatD32] = GL_UNSIGNED_INT;
|
GFXGLTextureType[GFXFormatD32] = GL_UNSIGNED_INT;
|
||||||
GFXGLTextureType[GFXFormatD24X8] = GL_UNSIGNED_INT_24_8;
|
GFXGLTextureType[GFXFormatD24X8] = GL_UNSIGNED_INT_24_8;
|
||||||
GFXGLTextureType[GFXFormatD24S8] = GL_UNSIGNED_INT_24_8;
|
GFXGLTextureType[GFXFormatD24S8] = GL_UNSIGNED_INT_24_8;
|
||||||
|
GFXGLTextureType[GFXFormatD32FS8X24] = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
|
||||||
GFXGLTextureType[GFXFormatR16G16B16A16] = GL_UNSIGNED_SHORT;
|
GFXGLTextureType[GFXFormatR16G16B16A16] = GL_UNSIGNED_SHORT;
|
||||||
GFXGLTextureType[GFXFormatBC1] = GL_UNSIGNED_BYTE;
|
GFXGLTextureType[GFXFormatBC1] = GL_UNSIGNED_BYTE;
|
||||||
GFXGLTextureType[GFXFormatBC2] = GL_UNSIGNED_BYTE;
|
GFXGLTextureType[GFXFormatBC2] = GL_UNSIGNED_BYTE;
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ void GuiTSCtrl::_internalRender(RectI guiViewport, RectI renderViewport, Frustum
|
||||||
GFX->setViewport(renderViewport);
|
GFX->setViewport(renderViewport);
|
||||||
|
|
||||||
// Clear the zBuffer so GUI doesn't hose object rendering accidentally
|
// Clear the zBuffer so GUI doesn't hose object rendering accidentally
|
||||||
GFX->clear(GFXClearZBuffer, ColorI(20, 20, 20), 1.0f, 0);
|
GFX->clear(GFXClearZBuffer, ColorI(20, 20, 20), 0.0f, 0);
|
||||||
|
|
||||||
GFX->setFrustum(frustum);
|
GFX->setFrustum(frustum);
|
||||||
mSaveProjection = GFX->getProjectionMatrix();
|
mSaveProjection = GFX->getProjectionMatrix();
|
||||||
|
|
|
||||||
|
|
@ -1915,7 +1915,7 @@ void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */)
|
||||||
|
|
||||||
// Clear the current viewport area
|
// Clear the current viewport area
|
||||||
GFX->setViewport( screenRect );
|
GFX->setViewport( screenRect );
|
||||||
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, gCanvasClearColor, 1.0f, 0 );
|
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, gCanvasClearColor, 0.0f, 0 );
|
||||||
|
|
||||||
resetUpdateRegions();
|
resetUpdateRegions();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ void CubeLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
mTarget->attachTexture(GFXTextureTarget::Color0, mCubemap, i);
|
mTarget->attachTexture(GFXTextureTarget::Color0, mCubemap, i);
|
||||||
mTarget->attachTexture(GFXTextureTarget::DepthStencil, _getDepthTarget( mTexSize, mTexSize ));
|
mTarget->attachTexture(GFXTextureTarget::DepthStencil, _getDepthTarget( mTexSize, mTexSize ));
|
||||||
GFX->setActiveRenderTarget(mTarget);
|
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
|
// Create scene state, prep it
|
||||||
SceneManager* sceneManager = diffuseState->getSceneManager();
|
SceneManager* sceneManager = diffuseState->getSceneManager();
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ void DualParaboloidLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
mTarget->attachTexture(GFXTextureTarget::Color0, mShadowMapTex);
|
mTarget->attachTexture(GFXTextureTarget::Color0, mShadowMapTex);
|
||||||
mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
|
mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
|
||||||
GFX->setActiveRenderTarget(mTarget);
|
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);
|
const bool bUseSinglePassDPM = (p->shadowType == ShadowType_DualParaboloidSinglePass);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ void ParaboloidLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
mTarget->attachTexture( GFXTextureTarget::DepthStencil,
|
mTarget->attachTexture( GFXTextureTarget::DepthStencil,
|
||||||
_getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() ) );
|
_getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() ) );
|
||||||
GFX->setActiveRenderTarget(mTarget);
|
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
|
// Create scene state, prep it
|
||||||
SceneManager* sceneManager = diffuseState->getSceneManager();
|
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
|
// Round to the nearest shadowmap texel, this helps reduce shimmering
|
||||||
MatrixF currentProj = GFX->getProjectionMatrix();
|
MatrixF currentProj = GFX->getProjectionMatrix();
|
||||||
|
currentProj.reverseProjection();
|
||||||
currentProj = cropMatrix * currentProj * lightMat;
|
currentProj = cropMatrix * currentProj * lightMat;
|
||||||
|
|
||||||
// Project origin to screen.
|
// Project origin to screen.
|
||||||
|
|
@ -226,13 +227,15 @@ void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
mTarget->attachTexture( GFXTextureTarget::Color0, mShadowMapTex );
|
mTarget->attachTexture( GFXTextureTarget::Color0, mShadowMapTex );
|
||||||
mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
|
mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
|
||||||
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), 0.0f, 0 );
|
||||||
|
|
||||||
// Calculate our standard light matrices
|
// Calculate our standard light matrices
|
||||||
MatrixF lightMatrix;
|
MatrixF lightMatrix;
|
||||||
calcLightMatrices( lightMatrix, diffuseState->getCameraFrustum() );
|
calcLightMatrices( lightMatrix, diffuseState->getCameraFrustum() );
|
||||||
lightMatrix.inverse();
|
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
|
// TODO: This is just retrieving the near and far calculated
|
||||||
// in calcLightMatrices... we should make that clear.
|
// in calcLightMatrices... we should make that clear.
|
||||||
|
|
@ -245,7 +248,7 @@ void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
|
|
||||||
_calcSplitPos(fullFrustum);
|
_calcSplitPos(fullFrustum);
|
||||||
|
|
||||||
mWorldToLightProj = GFX->getProjectionMatrix() * toLightSpace;
|
mWorldToLightProj = tempProjMat * toLightSpace;
|
||||||
|
|
||||||
// Apply the PSSM
|
// Apply the PSSM
|
||||||
const F32 savedSmallestVisible = TSShapeInstance::smSmallestVisiblePixelSize;
|
const F32 savedSmallestVisible = TSShapeInstance::smSmallestVisiblePixelSize;
|
||||||
|
|
@ -320,7 +323,9 @@ void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
|
|
||||||
// Crop matrix multiply needs to be post-projection.
|
// Crop matrix multiply needs to be post-projection.
|
||||||
MatrixF alightProj = GFX->getProjectionMatrix();
|
MatrixF alightProj = GFX->getProjectionMatrix();
|
||||||
|
alightProj.reverseProjection();
|
||||||
alightProj = cropMatrix * alightProj;
|
alightProj = cropMatrix * alightProj;
|
||||||
|
alightProj.reverseProjection();
|
||||||
|
|
||||||
// Set our new projection
|
// Set our new projection
|
||||||
GFX->setProjectionMatrix(alightProj);
|
GFX->setProjectionMatrix(alightProj);
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ void SingleLightShadowMap::_render( RenderPassManager* renderPass,
|
||||||
mTarget->attachTexture( GFXTextureTarget::DepthStencil,
|
mTarget->attachTexture( GFXTextureTarget::DepthStencil,
|
||||||
_getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() ) );
|
_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), 0.0f, 0);
|
||||||
|
|
||||||
SceneManager* sceneManager = diffuseState->getSceneManager();
|
SceneManager* sceneManager = diffuseState->getSceneManager();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,14 @@ bool MatrixF::fullInverse()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MatrixF::reverseProjection()
|
||||||
|
{
|
||||||
|
m[idx(0, 2)] = m[idx(0, 3)] - m[idx(0, 2)];
|
||||||
|
m[idx(1, 2)] = m[idx(1, 3)] - m[idx(1, 2)];
|
||||||
|
m[idx(2, 2)] = m[idx(2, 3)] - m[idx(2, 2)];
|
||||||
|
m[idx(3, 2)] = m[idx(3, 3)] - m[idx(3, 2)];
|
||||||
|
}
|
||||||
|
|
||||||
EulerF MatrixF::toEuler() const
|
EulerF MatrixF::toEuler() const
|
||||||
{
|
{
|
||||||
const F32 * mat = m;
|
const F32 * mat = m;
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,9 @@ public:
|
||||||
/// be used if the matrix has something other than (0,0,0,1) in the bottom row.
|
/// be used if the matrix has something other than (0,0,0,1) in the bottom row.
|
||||||
bool fullInverse();
|
bool fullInverse();
|
||||||
|
|
||||||
|
/// Reverse depth for projection matrix
|
||||||
|
/// Simplifies reversal matrix mult to 4 subtractions
|
||||||
|
void reverseProjection();
|
||||||
/// Swaps rows and columns into matrix.
|
/// Swaps rows and columns into matrix.
|
||||||
void transposeTo(F32 *matrix) const;
|
void transposeTo(F32 *matrix) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -439,6 +439,7 @@ bool mProjectWorldToScreen( const Point3F &in,
|
||||||
const MatrixF &projection )
|
const MatrixF &projection )
|
||||||
{
|
{
|
||||||
MatrixF worldProjection = projection;
|
MatrixF worldProjection = projection;
|
||||||
|
worldProjection.reverseProjection();
|
||||||
worldProjection.mul(world);
|
worldProjection.mul(world);
|
||||||
|
|
||||||
return mProjectWorldToScreen( in, out, view, worldProjection );
|
return mProjectWorldToScreen( in, out, view, worldProjection );
|
||||||
|
|
@ -487,6 +488,7 @@ void mProjectScreenToWorld( const Point3F &in,
|
||||||
F32 znear )
|
F32 znear )
|
||||||
{
|
{
|
||||||
MatrixF invWorldProjection = projection;
|
MatrixF invWorldProjection = projection;
|
||||||
|
invWorldProjection.reverseProjection();
|
||||||
invWorldProjection.mul(world);
|
invWorldProjection.mul(world);
|
||||||
invWorldProjection.inverse();
|
invWorldProjection.inverse();
|
||||||
|
|
||||||
|
|
@ -1472,7 +1474,7 @@ void makeProjection( MatrixF *outMatrix,
|
||||||
F32 farPlane,
|
F32 farPlane,
|
||||||
bool gfxRotate)
|
bool gfxRotate)
|
||||||
{
|
{
|
||||||
const bool isGL = GFX->getAdapterType() == OpenGL;
|
const bool isGL = false; // No longer need special OGL case w/ reversed depth
|
||||||
Point4F row;
|
Point4F row;
|
||||||
row.x = 2.0f * nearPlane / (right - left);
|
row.x = 2.0f * nearPlane / (right - left);
|
||||||
row.y = 0.0f;
|
row.y = 0.0f;
|
||||||
|
|
@ -1502,6 +1504,7 @@ void makeProjection( MatrixF *outMatrix,
|
||||||
|
|
||||||
if (gfxRotate)
|
if (gfxRotate)
|
||||||
outMatrix->mul(sGFXProjRotMatrix);
|
outMatrix->mul(sGFXProjRotMatrix);
|
||||||
|
outMatrix->reverseProjection();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -1545,6 +1548,7 @@ void makeOrthoProjection( MatrixF *outMatrix,
|
||||||
|
|
||||||
if ( gfxRotate )
|
if ( gfxRotate )
|
||||||
outMatrix->mul( sGFXProjRotMatrix );
|
outMatrix->mul( sGFXProjRotMatrix );
|
||||||
|
outMatrix->reverseProjection();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ void RenderDeferredMgr::render( SceneRenderState *state )
|
||||||
const bool isRenderingToTarget = _onPreRender(state);
|
const bool isRenderingToTarget = _onPreRender(state);
|
||||||
|
|
||||||
// Clear z-buffer and g-buffer.
|
// Clear z-buffer and g-buffer.
|
||||||
GFX->clear(GFXClearZBuffer | GFXClearStencil, LinearColorF::ZERO, 1.0f, 0);
|
GFX->clear(GFXClearZBuffer | GFXClearStencil, LinearColorF::ZERO, 0.0f, 0);
|
||||||
GFX->clearColorAttachment(0, LinearColorF::ONE);//normdepth
|
GFX->clearColorAttachment(0, LinearColorF::ONE);//normdepth
|
||||||
GFX->clearColorAttachment(1, LinearColorF::ZERO);//albedo
|
GFX->clearColorAttachment(1, LinearColorF::ZERO);//albedo
|
||||||
GFX->clearColorAttachment(2, LinearColorF::ZERO);//matinfo
|
GFX->clearColorAttachment(2, LinearColorF::ZERO);//matinfo
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ void RenderFormatToken::process(SceneRenderState *state, RenderPassStateBin *cal
|
||||||
GFX->setViewport( mTarget.getViewport() );
|
GFX->setViewport( mTarget.getViewport() );
|
||||||
|
|
||||||
// Clear
|
// Clear
|
||||||
GFX->clear(GFXClearTarget | GFXClearZBuffer | GFXClearStencil, gCanvasClearColor, 1.0f, 0);
|
GFX->clear(GFXClearTarget | GFXClearZBuffer | GFXClearStencil, gCanvasClearColor, 0.0f, 0);
|
||||||
|
|
||||||
// Set active z target on render pass
|
// Set active z target on render pass
|
||||||
if(mTargetDepthStencilTexture[mTargetChainIdx].isValid())
|
if(mTargetDepthStencilTexture[mTargetChainIdx].isValid())
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ void CubeReflector::updateFace( const ReflectParams ¶ms, U32 faceidx, Point3
|
||||||
GFX->clearTextureStateImmediate(0);
|
GFX->clearTextureStateImmediate(0);
|
||||||
mRenderTarget->attachTexture( GFXTextureTarget::Color0, mCubemap, faceidx );
|
mRenderTarget->attachTexture( GFXTextureTarget::Color0, mCubemap, faceidx );
|
||||||
GFX->setActiveRenderTarget(mRenderTarget);
|
GFX->setActiveRenderTarget(mRenderTarget);
|
||||||
GFX->clear( GFXClearStencil | GFXClearTarget | GFXClearZBuffer, gCanvasClearColor, 1.0f, 0 );
|
GFX->clear( GFXClearStencil | GFXClearTarget | GFXClearZBuffer, gCanvasClearColor, 0.0f, 0 );
|
||||||
|
|
||||||
SceneRenderState reflectRenderState
|
SceneRenderState reflectRenderState
|
||||||
(
|
(
|
||||||
|
|
@ -624,7 +624,7 @@ void PlaneReflector::updateReflection( const ReflectParams ¶ms )
|
||||||
// render a skirt or something in its lower half.
|
// render a skirt or something in its lower half.
|
||||||
//
|
//
|
||||||
LinearColorF clearColor = gClientSceneGraph->getAmbientLightColor();
|
LinearColorF clearColor = gClientSceneGraph->getAmbientLightColor();
|
||||||
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, clearColor, 1.0f, 0 );
|
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, clearColor, 0.0f, 0 );
|
||||||
|
|
||||||
if(GFX->getCurrentRenderStyle() == GFXDevice::RS_StereoSideBySide)
|
if(GFX->getCurrentRenderStyle() == GFXDevice::RS_StereoSideBySide)
|
||||||
{
|
{
|
||||||
|
|
@ -845,6 +845,7 @@ MatrixF PlaneReflector::getFrustumClipProj( MatrixF &modelview )
|
||||||
// Manipulate projection matrix
|
// Manipulate projection matrix
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
MatrixF proj = GFX->getProjectionMatrix();
|
MatrixF proj = GFX->getProjectionMatrix();
|
||||||
|
proj.reverseProjection(); // convert back into normal depth space from reversed, otherwise we have to figure out how to convert this modification into inverted depth space
|
||||||
proj.mul( invRotMat ); // reverse rotation imposed by Torque
|
proj.mul( invRotMat ); // reverse rotation imposed by Torque
|
||||||
proj.transpose(); // switch to row-major order
|
proj.transpose(); // switch to row-major order
|
||||||
|
|
||||||
|
|
@ -862,14 +863,16 @@ MatrixF PlaneReflector::getFrustumClipProj( MatrixF &modelview )
|
||||||
|
|
||||||
Vector4F c = clipPlane * a;
|
Vector4F c = clipPlane * a;
|
||||||
|
|
||||||
|
// [ZREV] This was a hack to handle OGL using -1 to 1 as its Z range
|
||||||
// CodeReview [ags 1/23/08] Come up with a better way to deal with this.
|
// CodeReview [ags 1/23/08] Come up with a better way to deal with this.
|
||||||
if(GFX->getAdapterType() == OpenGL)
|
//if(GFX->getAdapterType() == OpenGL)
|
||||||
c.z += 1.0f;
|
// c.z += 1.0f;
|
||||||
|
|
||||||
// Replace the third column of the projection matrix
|
// Replace the third column of the projection matrix
|
||||||
proj.setColumn( 2, c );
|
proj.setColumn( 2, c );
|
||||||
proj.transpose(); // convert back to column major order
|
proj.transpose(); // convert back to column major order
|
||||||
proj.mul( rotMat ); // restore Torque rotation
|
proj.mul( rotMat ); // restore Torque rotation
|
||||||
|
|
||||||
|
proj.reverseProjection(); // convert back to reversed depth space
|
||||||
return proj;
|
return proj;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1735,7 +1735,7 @@ void VertPositionGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
outPosition, modelview, inPosition ) );
|
outPosition, modelview, inPosition ) );
|
||||||
if (fd.materialFeatures[MFT_isBackground])
|
if (fd.materialFeatures[MFT_isBackground])
|
||||||
{
|
{
|
||||||
meta->addStatement(new GenOp(" @ = @.xyww;\r\n", outPosition, outPosition));
|
meta->addStatement(new GenOp(" @.z = 0.0f;\r\n", outPosition));
|
||||||
}
|
}
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1781,7 +1781,7 @@ void VertPositionHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
||||||
if (fd.materialFeatures[MFT_isBackground])
|
if (fd.materialFeatures[MFT_isBackground])
|
||||||
{
|
{
|
||||||
meta->addStatement(new GenOp(" @ = @.xyww;\r\n", outPosition, outPosition));
|
meta->addStatement(new GenOp(" @.z = 0.0f;\r\n", outPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
output = meta;
|
output = meta;
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ void ImposterCapture::_renderToTexture( GFXTexHandle texHandle, GBitmap *outBitm
|
||||||
mRenderTarget->attachTexture( GFXTextureTarget::DepthStencil, mDepthBuffer );
|
mRenderTarget->attachTexture( GFXTextureTarget::DepthStencil, mDepthBuffer );
|
||||||
GFX->setActiveRenderTarget( mRenderTarget );
|
GFX->setActiveRenderTarget( mRenderTarget );
|
||||||
|
|
||||||
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, color, 1.0f, 0 );
|
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, color, 0.0f, 0 );
|
||||||
|
|
||||||
mShapeInstance->render( mRData, mDl, 1.0f );
|
mShapeInstance->render( mRData, mDl, 1.0f );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ function initRenderManager()
|
||||||
|
|
||||||
//When hdr is enabled this will be changed to the appropriate format
|
//When hdr is enabled this will be changed to the appropriate format
|
||||||
format = "GFXFormatR16G16B16A16F";
|
format = "GFXFormatR16G16B16A16F";
|
||||||
depthFormat = "GFXFormatD24S8";
|
depthFormat = "GFXFormatD32FS8X24"; // 64-bit depth format. Old 32-bit format was "GFXFormatD24S8"
|
||||||
aaLevel = 0; // -1 = match backbuffer
|
aaLevel = 0; // -1 = match backbuffer
|
||||||
|
|
||||||
// The contents of the back buffer before this format token is executed
|
// The contents of the back buffer before this format token is executed
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ ConnectData main( CloudVert IN )
|
||||||
ConnectData OUT;
|
ConnectData OUT;
|
||||||
|
|
||||||
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
|
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
|
||||||
OUT.hpos.z = OUT.hpos.w;
|
OUT.hpos.z = 0.0f; // OUT.hpos.w; // reverse depth -- put cloud layer in the far dist and let render order hints sort it out?
|
||||||
float2 uv = IN.uv0;
|
float2 uv = IN.uv0;
|
||||||
uv += texOffset;
|
uv += texOffset;
|
||||||
uv *= texScale;
|
uv *= texScale;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ ConnectData main( CloudVert IN )
|
||||||
ConnectData OUT;
|
ConnectData OUT;
|
||||||
|
|
||||||
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
|
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
|
||||||
OUT.hpos.z = OUT.hpos.w;
|
OUT.hpos.z = 0.0f; //OUT.hpos.w; // for reversed depth
|
||||||
// Offset the uv so we don't have a seam directly over our head.
|
// Offset the uv so we don't have a seam directly over our head.
|
||||||
float2 uv = IN.uv0 + float2( 0.5, 0.5 );
|
float2 uv = IN.uv0 + float2( 0.5, 0.5 );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ out vec2 texCoord;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = tMul(modelview, IN_pos);
|
gl_Position = tMul(modelview, IN_pos);
|
||||||
gl_Position.z = gl_Position.w;
|
gl_Position.z = 0.0; // gl_Position.w; // reverse depth -- put cloud layer in the far dist and let render order hints sort it out?
|
||||||
|
|
||||||
vec2 uv = IN_uv0;
|
vec2 uv = IN_uv0;
|
||||||
uv += texOffset;
|
uv += texOffset;
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ void main()
|
||||||
vec2 IN_uv0 = vTexCoord0.st;
|
vec2 IN_uv0 = vTexCoord0.st;
|
||||||
|
|
||||||
gl_Position = modelview * IN_pos;
|
gl_Position = modelview * IN_pos;
|
||||||
gl_Position.z = gl_Position.w;
|
gl_Position.z = 0.0;//gl_Position.w; // reversed depth -- put clouds in the far distance (0) with other sky-type objects
|
||||||
|
|
||||||
// Offset the uv so we don't have a seam directly over our head.
|
// Offset the uv so we don't have a seam directly over our head.
|
||||||
vec2 uv = IN_uv0 + vec2( 0.5, 0.5 );
|
vec2 uv = IN_uv0 + vec2( 0.5, 0.5 );
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ void main()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Save world space camera dist/depth of the outgoing pixel
|
// Save world space camera dist/depth of the outgoing pixel
|
||||||
OUT_rippleTexCoord2.z = OUT_hpos.z;
|
OUT_rippleTexCoord2.z = OUT_hpos.w; // for reversed depth
|
||||||
|
|
||||||
// Convert to reflection texture space
|
// Convert to reflection texture space
|
||||||
OUT_posPostWave = tMul( texGen, OUT_posPostWave );
|
OUT_posPostWave = tMul( texGen, OUT_posPostWave );
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ ConnectData main( VertData IN )
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Save world space camera dist/depth of the outgoing pixel
|
// Save world space camera dist/depth of the outgoing pixel
|
||||||
OUT.rippleTexCoord2.z = OUT.hpos.z;
|
OUT.rippleTexCoord2.z = OUT.hpos.w; // use the world-coordinate version of depth, this will work with either projection model
|
||||||
|
|
||||||
// Convert to reflection texture space
|
// Convert to reflection texture space
|
||||||
OUT.posPostWave = mul( texGen, OUT.posPostWave );
|
OUT.posPostWave = mul( texGen, OUT.posPostWave );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue