mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-03 20:40:35 +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
|
|
@ -73,6 +73,7 @@ void GFXD3D11EnumTranslate::init()
|
|||
GFXD3D11TextureFormat[GFXFormatD24S8] = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
GFXD3D11TextureFormat[GFXFormatD24FS8] = DXGI_FORMAT_UNKNOWN;
|
||||
GFXD3D11TextureFormat[GFXFormatD16] = DXGI_FORMAT_D16_UNORM;
|
||||
GFXD3D11TextureFormat[GFXFormatD32FS8X24] = DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
|
||||
//sRGB
|
||||
GFXD3D11TextureFormat[GFXFormatR8G8B8A8_SRGB] = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
||||
GFXD3D11TextureFormat[GFXFormatR8G8B8_SRGB] = DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;
|
||||
|
|
|
|||
|
|
@ -173,7 +173,12 @@ void GFXD3D11TextureManager::_innerCreateTexture( GFXD3D11TextureObject *retTex,
|
|||
desc.CPUAccessFlags = cpuFlags;
|
||||
//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
|
||||
if (format == GFXFormatD24S8)
|
||||
{
|
||||
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.SampleDesc.Count = antialiasLevel;
|
||||
desc.SampleDesc.Quality = numQualityLevels;
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ ImplementEnumType( GFXFormat,
|
|||
{ GFXFormatD24S8, "GFXFormatD24S8" },
|
||||
{ GFXFormatD24FS8, "GFXFormatD24FS8" },
|
||||
{ GFXFormatD16, "GFXFormatD16" },
|
||||
{ GFXFormatD32FS8X24, "GFXFormatD32FS8X24" },
|
||||
|
||||
{ GFXFormatR32G32B32A32F, "GFXFormatR32G32B32A32F" },
|
||||
{ GFXFormatR16G16B16A16F, "GFXFormatR16G16B16A16F" },
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ enum GFXFormat
|
|||
// 64 bit texture formats...
|
||||
GFXFormatR16G16B16A16,// first in group...
|
||||
GFXFormatR16G16B16A16F,
|
||||
GFXFormatD32FS8X24,
|
||||
|
||||
// 128 bit texture formats...
|
||||
GFXFormatR32G32B32A32F,// first in group...
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ GFXFormatInfo::Data GFXFormatInfo::smFormatInfos[ GFXFormat_COUNT ] =
|
|||
// 16 bit texture formats...
|
||||
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatR5G6B5
|
||||
GFXFormatInfo::Data( 2, true, false, false ), // GFXFormatR5G5B5A1
|
||||
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatR5G5B5X1
|
||||
GFXFormatInfo::Data( 2, true, false, false ), // GFXFormatA8L8
|
||||
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatL16
|
||||
GFXFormatInfo::Data( 2, false, false, false ), // GFXFormatR16F
|
||||
|
|
@ -46,22 +47,28 @@ GFXFormatInfo::Data GFXFormatInfo::smFormatInfos[ GFXFormat_COUNT ] =
|
|||
|
||||
// 24 bit texture formats...
|
||||
GFXFormatInfo::Data( 3, false, false, false ), // GFXFormatR8G8B8
|
||||
GFXFormatInfo::Data( 3, false, false, false ), // GFXFormatR8G8B8_SRGB
|
||||
|
||||
// 32 bit texture formats...
|
||||
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatR8G8B8A8
|
||||
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 ), // GFXFormatR16G16
|
||||
GFXFormatInfo::Data( 4, false, false, true ), // GFXFormatR16G16F
|
||||
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 ), // GFXFormatD24X8
|
||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD24S8
|
||||
GFXFormatInfo::Data( 4, false, false, false ), // GFXFormatD24FS8
|
||||
GFXFormatInfo::Data( 4, true, false, false ), // GFXFormatR8G8B8A8_LINEAR_FORCE
|
||||
|
||||
// 64 bit texture formats...
|
||||
GFXFormatInfo::Data( 8, true, false, false ), // GFXFormatR16G16B16A16
|
||||
GFXFormatInfo::Data( 8, true, false, true ), // GFXFormatR16G16B16A16F
|
||||
GFXFormatInfo::Data( 8, false, false, false ), // GFXFormatD32FS8X24
|
||||
|
||||
// 128 bit texture formats...
|
||||
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, false, true, false ), // GFXFormatBC4
|
||||
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;
|
||||
zEnable = true;
|
||||
zWriteEnable = true;
|
||||
zFunc = GFXCmpLessEqual;
|
||||
zFunc = GFXCmpGreaterEqual;
|
||||
zBias = 0;
|
||||
zSlopeBias = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ void GFXStringEnumTranslate::init()
|
|||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24S8 );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24FS8 );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD16 );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD32FS8X24 );
|
||||
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR32G32B32A32F );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR16G16B16A16F );
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ void GFXGLDevice::initGLState()
|
|||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
|
||||
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||
//enable sRGB
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
|
|
@ -794,38 +795,26 @@ void GFXGLDevice::setClipRect( const RectI &inRect )
|
|||
mClip = inRect;
|
||||
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;
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
// 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);
|
||||
setViewMatrix( mTempMatrix );
|
||||
setWorldMatrix( mTempMatrix );
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ void GFXGLEnumTranslate::init()
|
|||
GFXGLTextureInternalFormat[GFXFormatD32] = GL_DEPTH_COMPONENT32;
|
||||
GFXGLTextureInternalFormat[GFXFormatD24X8] = GL_DEPTH24_STENCIL8;
|
||||
GFXGLTextureInternalFormat[GFXFormatD24S8] = GL_DEPTH24_STENCIL8;
|
||||
GFXGLTextureInternalFormat[GFXFormatD32FS8X24] = GL_DEPTH32F_STENCIL8;
|
||||
GFXGLTextureInternalFormat[GFXFormatR16G16B16A16] = GL_RGBA16;
|
||||
GFXGLTextureInternalFormat[GFXFormatBC1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
GFXGLTextureInternalFormat[GFXFormatBC2] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||
|
|
@ -161,6 +162,7 @@ void GFXGLEnumTranslate::init()
|
|||
GFXGLTextureFormat[GFXFormatD32] = GL_DEPTH_COMPONENT;
|
||||
GFXGLTextureFormat[GFXFormatD24X8] = GL_DEPTH_STENCIL;
|
||||
GFXGLTextureFormat[GFXFormatD24S8] = GL_DEPTH_STENCIL;
|
||||
GFXGLTextureFormat[GFXFormatD32FS8X24] = GL_DEPTH_STENCIL;
|
||||
GFXGLTextureFormat[GFXFormatR16G16B16A16] = GL_RGBA;
|
||||
GFXGLTextureFormat[GFXFormatBC1] = GL_RGBA;
|
||||
GFXGLTextureFormat[GFXFormatBC2] = GL_RGBA;
|
||||
|
|
@ -190,6 +192,7 @@ void GFXGLEnumTranslate::init()
|
|||
GFXGLTextureType[GFXFormatD32] = GL_UNSIGNED_INT;
|
||||
GFXGLTextureType[GFXFormatD24X8] = 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[GFXFormatBC1] = GL_UNSIGNED_BYTE;
|
||||
GFXGLTextureType[GFXFormatBC2] = GL_UNSIGNED_BYTE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue