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:
AtomicWalrus 2023-04-14 20:13:28 -06:00
parent c08fa359d2
commit 75625dc679
37 changed files with 91 additions and 57 deletions

View file

@ -160,6 +160,14 @@ bool MatrixF::fullInverse()
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
{
const F32 * mat = m;

View file

@ -123,6 +123,9 @@ public:
/// be used if the matrix has something other than (0,0,0,1) in the bottom row.
bool fullInverse();
/// Reverse depth for projection matrix
/// Simplifies reversal matrix mult to 4 subtractions
void reverseProjection();
/// Swaps rows and columns into matrix.
void transposeTo(F32 *matrix) const;

View file

@ -439,6 +439,7 @@ bool mProjectWorldToScreen( const Point3F &in,
const MatrixF &projection )
{
MatrixF worldProjection = projection;
worldProjection.reverseProjection();
worldProjection.mul(world);
return mProjectWorldToScreen( in, out, view, worldProjection );
@ -487,6 +488,7 @@ void mProjectScreenToWorld( const Point3F &in,
F32 znear )
{
MatrixF invWorldProjection = projection;
invWorldProjection.reverseProjection();
invWorldProjection.mul(world);
invWorldProjection.inverse();
@ -1472,7 +1474,7 @@ void makeProjection( MatrixF *outMatrix,
F32 farPlane,
bool gfxRotate)
{
const bool isGL = GFX->getAdapterType() == OpenGL;
const bool isGL = false; // No longer need special OGL case w/ reversed depth
Point4F row;
row.x = 2.0f * nearPlane / (right - left);
row.y = 0.0f;
@ -1502,6 +1504,7 @@ void makeProjection( MatrixF *outMatrix,
if (gfxRotate)
outMatrix->mul(sGFXProjRotMatrix);
outMatrix->reverseProjection();
}
//-----------------------------------------------------------------------------
@ -1545,6 +1548,7 @@ void makeOrthoProjection( MatrixF *outMatrix,
if ( gfxRotate )
outMatrix->mul( sGFXProjRotMatrix );
outMatrix->reverseProjection();
}
//-----------------------------------------------------------------------------