1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Set PrimDepth to gl_FragDepth when DepthSource set to Primitive.

This makes player's shadow solid in Tony Hawk's Pro Skater 2
This commit is contained in:
Sergey Lipskiy 2017-11-11 00:59:07 +07:00
parent 3c61198043
commit 591eda82ba
3 changed files with 34 additions and 4 deletions

View File

@ -716,6 +716,8 @@ public:
"uniform lowp int uCvgXAlpha; \n"
"uniform lowp int uAlphaCvgSel; \n"
"uniform lowp float uAlphaTestValue; \n"
"uniform lowp int uDepthSource; \n"
"uniform highp float uPrimDepth; \n"
"uniform mediump vec2 uScreenScale; \n"
;
@ -790,6 +792,8 @@ public:
"uniform lowp int uCvgXAlpha; \n"
"uniform lowp int uAlphaCvgSel; \n"
"uniform lowp float uAlphaTestValue; \n"
"uniform lowp int uDepthSource; \n"
"uniform highp float uPrimDepth; \n"
"uniform mediump vec2 uScreenScale; \n"
;
@ -1379,7 +1383,8 @@ public:
m_part =
"void writeDepth() \n"
"{ \n"
" gl_FragDepth = clamp((gl_FragCoord.z * 2.0 - 1.0) * uDepthScale.s + uDepthScale.t, 0.0, 1.0); \n"
" if (uDepthSource == 1) gl_FragDepth = uPrimDepth; \n"
" else gl_FragDepth = clamp((gl_FragCoord.z * 2.0 - 1.0) * uDepthScale.s + uDepthScale.t, 0.0, 1.0); \n"
"} \n"
;
}
@ -1763,7 +1768,6 @@ public:
if (config.frameBufferEmulation.N64DepthCompare != 0) {
m_part =
"uniform lowp int uDepthMode; \n"
"uniform lowp int uDepthSource; \n"
"uniform lowp int uEnableDepthUpdate; \n"
"uniform mediump float uDeltaZ; \n"
"bool depth_compare() \n"

View File

@ -554,6 +554,7 @@ public:
LocateUniform(uEnableDepthUpdate);
LocateUniform(uDepthMode);
LocateUniform(uDepthSource);
LocateUniform(uPrimDepth);
LocateUniform(uDeltaZ);
}
@ -575,8 +576,10 @@ public:
}
uDepthMode.set(gDP.otherMode.depthMode, _force);
uDepthSource.set(gDP.otherMode.depthSource, _force);
if (gDP.otherMode.depthSource == G_ZS_PRIM)
if (gDP.otherMode.depthSource == G_ZS_PRIM) {
uDeltaZ.set(gDP.primDepth.deltaZ, _force);
uPrimDepth.set((gDP.primDepth.z + 1.0f) * 0.5f, _force);
}
}
private:
@ -585,9 +588,30 @@ private:
iUniform uEnableDepthUpdate;
iUniform uDepthMode;
iUniform uDepthSource;
fUniform uPrimDepth;
fUniform uDeltaZ;
};
class UDepthSource : public UniformGroup
{
public:
UDepthSource(GLuint _program) {
LocateUniform(uDepthSource);
LocateUniform(uPrimDepth);
}
void update(bool _force) override
{
uDepthSource.set(gDP.otherMode.depthSource, _force);
if (gDP.otherMode.depthSource == G_ZS_PRIM)
uPrimDepth.set((gDP.primDepth.z + 1.0f) * 0.5f, _force);
}
private:
iUniform uDepthSource;
fUniform uPrimDepth;
};
class URenderTarget : public UniformGroup
{
public:
@ -871,6 +895,8 @@ void CombinerProgramUniformFactory::buildUniforms(GLuint _program,
if (config.frameBufferEmulation.N64DepthCompare != 0)
_uniforms.emplace_back(new UDepthInfo(_program));
else
_uniforms.emplace_back(new UDepthSource(_program));
if (config.generalEmulation.enableFragmentDepthWrite != 0 ||
config.frameBufferEmulation.N64DepthCompare != 0)

View File

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