1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Rewrite primitive depth calculation.

Up shader storage version.

Fixed Star Wars Episode I - Racer: Overlapping #1911
This commit is contained in:
Sergey Lipskiy 2018-10-01 22:37:03 +07:00
parent b88c99302f
commit 9f1bbeab9f
3 changed files with 13 additions and 17 deletions

View File

@ -1535,20 +1535,20 @@ public:
} else {
if (_glinfo.isGLESX && _glinfo.noPerspective) {
m_part =
"highp float writeDepth() \n"
"{ \n"
" if (uClampMode == 1 && (vZCoord > 1.0)) discard; \n"
" highp float depth = uDepthSource == 0 ? (vZCoord - uPolygonOffset) : uPrimDepth; \n"
" return clamp(depth * uDepthScale.s + uDepthScale.t, 0.0, 1.0); \n"
"} \n"
"highp float writeDepth() \n"
"{ \n"
" if (uClampMode == 1 && (vZCoord > 1.0)) discard; \n"
" if (uDepthSource != 0) return uPrimDepth; \n"
" return clamp((vZCoord - uPolygonOffset) * uDepthScale.s + uDepthScale.t, 0.0, 1.0); \n"
"} \n"
;
} else {
m_part =
"highp float writeDepth() \n"
"{ \n"
" highp float depth = uDepthSource == 0 ? (gl_FragCoord.z * 2.0 - 1.0) : uPrimDepth; \n"
" return clamp(depth * uDepthScale.s + uDepthScale.t, 0.0, 1.0); \n"
"} \n"
"highp float writeDepth() \n"
"{ \n"
" if (uDepthSource != 0) return uPrimDepth; \n"
" return clamp((gl_FragCoord.z * 2.0 - 1.0) * uDepthScale.s + uDepthScale.t, 0.0, 1.0); \n"
"} \n"
;
}
}

View File

@ -20,7 +20,7 @@ namespace glsl {
bool _saveCombinerKeys(const graphics::Combiners & _combiners) const;
bool _loadFromCombinerKeys(graphics::Combiners & _combiners);
const u32 m_formatVersion = 0x21U;
const u32 m_formatVersion = 0x22U;
const u32 m_keysFormatVersion = 0x04;
const opengl::GLInfo & m_glinfo;
opengl::CachedUseProgram * m_useProgram;

View File

@ -69,12 +69,8 @@ void gDPSetOtherMode( u32 mode0, u32 mode1 )
void gDPSetPrimDepth( u16 z, u16 dz )
{
if (gSP.viewport.vscale[2] == 0)
gDP.primDepth.z = _FIXED2FLOAT(_SHIFTR(z, 0, 15), 15);
else
gDP.primDepth.z = min(1.0f, max(-1.0f, (_FIXED2FLOAT(_SHIFTR(z, 0, 15), 15) - gSP.viewport.vtrans[2]) / gSP.viewport.vscale[2]));
gDP.primDepth.z = _FIXED2FLOAT(_SHIFTR(z, 0, 15), 15);
gDP.primDepth.deltaZ = _FIXED2FLOAT(_SHIFTR(dz, 0, 15), 15);
DebugMsg( DEBUG_NORMAL, "gDPSetPrimDepth( %f, %f );\n", gDP.primDepth.z, gDP.primDepth.deltaZ);
}