mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
Revert "- reworked fog uniforms to move the global fog mode setting to the viewpoint buffer."
This reverts commit 8b26b6dd1e
.
This was causing problems with light mode 2 because some edge cases were no longer handled properly.
This commit is contained in:
parent
4c13a8df6e
commit
bc1e659c7b
9 changed files with 32 additions and 19 deletions
|
@ -144,7 +144,6 @@ void GLViewpointBuffer::Set2D(int width, int height)
|
||||||
HWViewpointUniforms matrices;
|
HWViewpointUniforms matrices;
|
||||||
matrices.SetDefaults();
|
matrices.SetDefaults();
|
||||||
matrices.mProjectionMatrix.ortho(0, width, height, 0, -1.0f, 1.0f);
|
matrices.mProjectionMatrix.ortho(0, width, height, 0, -1.0f, 1.0f);
|
||||||
matrices.mFogEnabled = 3;
|
|
||||||
matrices.CalcDependencies();
|
matrices.CalcDependencies();
|
||||||
Map();
|
Map();
|
||||||
memcpy(mBufferPointer, &matrices, sizeof(matrices));
|
memcpy(mBufferPointer, &matrices, sizeof(matrices));
|
||||||
|
|
|
@ -119,7 +119,7 @@ bool FRenderState::ApplyShader()
|
||||||
static uint64_t firstFrame = 0;
|
static uint64_t firstFrame = 0;
|
||||||
// if firstFrame is not yet initialized, initialize it to current time
|
// if firstFrame is not yet initialized, initialize it to current time
|
||||||
// if we're going to overflow a float (after ~4.6 hours, or 24 bits), re-init to regain precision
|
// if we're going to overflow a float (after ~4.6 hours, or 24 bits), re-init to regain precision
|
||||||
if ((firstFrame == 0) || (screen->FrameTime - firstFrame >= 1 << 24) || level.ShaderStartTime >= firstFrame)
|
if ((firstFrame == 0) || (screen->FrameTime - firstFrame >= 1<<24) || level.ShaderStartTime >= firstFrame)
|
||||||
firstFrame = screen->FrameTime;
|
firstFrame = screen->FrameTime;
|
||||||
|
|
||||||
static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f };
|
static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f };
|
||||||
|
@ -133,15 +133,31 @@ bool FRenderState::ApplyShader()
|
||||||
activeShader->Bind();
|
activeShader->Bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fogset = 0;
|
||||||
|
|
||||||
|
if (mFogEnabled)
|
||||||
|
{
|
||||||
|
if (mFogEnabled == 2)
|
||||||
|
{
|
||||||
|
fogset = -3; // 2D rendering with 'foggy' overlay.
|
||||||
|
}
|
||||||
|
else if ((mFogColor & 0xffffff) == 0)
|
||||||
|
{
|
||||||
|
fogset = gl_fogmode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fogset = -gl_fogmode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glVertexAttrib4fv(VATTR_COLOR, mColor.vec);
|
glVertexAttrib4fv(VATTR_COLOR, mColor.vec);
|
||||||
glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec);
|
glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec);
|
||||||
|
|
||||||
activeShader->muDesaturation.Set(mDesaturation / 255.f);
|
activeShader->muDesaturation.Set(mDesaturation / 255.f);
|
||||||
|
activeShader->muFogEnabled.Set(fogset);
|
||||||
activeShader->muTextureMode.Set(mTextureMode == TM_MODULATE && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode);
|
activeShader->muTextureMode.Set(mTextureMode == TM_MODULATE && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode);
|
||||||
float fds = mLightParms[2];
|
|
||||||
if (!mFogEnabled) mLightParms[2] = 0;
|
|
||||||
activeShader->muLightParms.Set(mLightParms);
|
activeShader->muLightParms.Set(mLightParms);
|
||||||
mLightParms[2] = fds;
|
|
||||||
activeShader->muFogColor.Set(mFogColor);
|
activeShader->muFogColor.Set(mFogColor);
|
||||||
activeShader->muObjectColor.Set(mObjectColor);
|
activeShader->muObjectColor.Set(mObjectColor);
|
||||||
activeShader->muObjectColor2.Set(mObjectColor2);
|
activeShader->muObjectColor2.Set(mObjectColor2);
|
||||||
|
|
|
@ -375,7 +375,6 @@ void FDrawInfo::DrawEndScene2D(sector_t * viewsector)
|
||||||
HWViewpointUniforms vp = VPUniforms;
|
HWViewpointUniforms vp = VPUniforms;
|
||||||
vp.mViewMatrix.loadIdentity();
|
vp.mViewMatrix.loadIdentity();
|
||||||
vp.mProjectionMatrix = vrmode->GetHUDSpriteProjection();
|
vp.mProjectionMatrix = vrmode->GetHUDSpriteProjection();
|
||||||
vp.mFogEnabled = 0;
|
|
||||||
GLRenderer->mViewpoints->SetViewpoint(&vp);
|
GLRenderer->mViewpoints->SetViewpoint(&vp);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_MULTISAMPLE);
|
glDisable(GL_MULTISAMPLE);
|
||||||
|
|
|
@ -68,8 +68,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
int uViewHeight; // Software fuzz scaling
|
int uViewHeight; // Software fuzz scaling
|
||||||
float uClipHeight;
|
float uClipHeight;
|
||||||
float uClipHeightDirection;
|
float uClipHeightDirection;
|
||||||
int uFogEnabled;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
@ -100,6 +98,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
i_data += "#define uFogDensity uLightAttr.b\n";
|
i_data += "#define uFogDensity uLightAttr.b\n";
|
||||||
i_data += "#define uLightFactor uLightAttr.g\n";
|
i_data += "#define uLightFactor uLightAttr.g\n";
|
||||||
i_data += "#define uLightDist uLightAttr.r\n";
|
i_data += "#define uLightDist uLightAttr.r\n";
|
||||||
|
i_data += "uniform int uFogEnabled;\n";
|
||||||
|
|
||||||
// dynamic lights
|
// dynamic lights
|
||||||
i_data += "uniform int uLightIndex;\n";
|
i_data += "uniform int uLightIndex;\n";
|
||||||
|
@ -331,6 +330,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
|
|
||||||
|
|
||||||
muDesaturation.Init(hShader, "uDesaturationFactor");
|
muDesaturation.Init(hShader, "uDesaturationFactor");
|
||||||
|
muFogEnabled.Init(hShader, "uFogEnabled");
|
||||||
muTextureMode.Init(hShader, "uTextureMode");
|
muTextureMode.Init(hShader, "uTextureMode");
|
||||||
muLightParms.Init(hShader, "uLightAttr");
|
muLightParms.Init(hShader, "uLightAttr");
|
||||||
muClipSplit.Init(hShader, "uClipSplit");
|
muClipSplit.Init(hShader, "uClipSplit");
|
||||||
|
|
|
@ -242,6 +242,7 @@ class FShader
|
||||||
FName mName;
|
FName mName;
|
||||||
|
|
||||||
FBufferedUniform1f muDesaturation;
|
FBufferedUniform1f muDesaturation;
|
||||||
|
FBufferedUniform1i muFogEnabled;
|
||||||
FBufferedUniform1i muTextureMode;
|
FBufferedUniform1i muTextureMode;
|
||||||
FBufferedUniform4f muLightParms;
|
FBufferedUniform4f muLightParms;
|
||||||
FBufferedUniform2f muClipSplit;
|
FBufferedUniform2f muClipSplit;
|
||||||
|
|
|
@ -280,6 +280,5 @@ void HWViewpointUniforms::SetDefaults()
|
||||||
mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f;
|
mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f;
|
||||||
mPalLightLevels = static_cast<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8);
|
mPalLightLevels = static_cast<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8);
|
||||||
mClipLine.X = -10000000.0f;
|
mClipLine.X = -10000000.0f;
|
||||||
mFogEnabled = gl_fogmode;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ struct HWViewpointUniforms
|
||||||
int mViewHeight = 0;
|
int mViewHeight = 0;
|
||||||
float mClipHeight = 0.f;
|
float mClipHeight = 0.f;
|
||||||
float mClipHeightDirection = 0.f;
|
float mClipHeightDirection = 0.f;
|
||||||
int mFogEnabled = 0;
|
|
||||||
|
|
||||||
void CalcDependencies()
|
void CalcDependencies()
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ void main()
|
||||||
//
|
//
|
||||||
// calculate fog factor
|
// calculate fog factor
|
||||||
//
|
//
|
||||||
if (uFogEnabled == 1)
|
if (uFogEnabled == -1)
|
||||||
{
|
{
|
||||||
fogdist = pixelpos.w;
|
fogdist = pixelpos.w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,7 +358,7 @@ vec4 getLightColor(Material material, float fogdist, float fogfactor)
|
||||||
float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel);
|
float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel);
|
||||||
color.rgb *= newlightlevel;
|
color.rgb *= newlightlevel;
|
||||||
}
|
}
|
||||||
else if (uFogColor.rgb == vec3(0.0))
|
else if (uFogEnabled > 0)
|
||||||
{
|
{
|
||||||
// brightening around the player for light mode 2
|
// brightening around the player for light mode 2
|
||||||
if (fogdist < uLightDist)
|
if (fogdist < uLightDist)
|
||||||
|
@ -421,7 +421,7 @@ vec3 AmbientOcclusionColor()
|
||||||
//
|
//
|
||||||
// calculate fog factor
|
// calculate fog factor
|
||||||
//
|
//
|
||||||
if (uFogEnabled == 1)
|
if (uFogEnabled == -1)
|
||||||
{
|
{
|
||||||
fogdist = pixelpos.w;
|
fogdist = pixelpos.w;
|
||||||
}
|
}
|
||||||
|
@ -449,17 +449,17 @@ void main()
|
||||||
if (frag.a <= uAlphaThreshold) discard;
|
if (frag.a <= uAlphaThreshold) discard;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (uFogEnabled != 3) // check for special 2D 'fog' mode.
|
if (uFogEnabled != -3) // check for special 2D 'fog' mode.
|
||||||
{
|
{
|
||||||
float fogdist = 0.0;
|
float fogdist = 0.0;
|
||||||
float fogfactor = 1.0;
|
float fogfactor = 0.0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// calculate fog factor
|
// calculate fog factor
|
||||||
//
|
//
|
||||||
if (uFogEnabled != 0 && uFogDensity != 0)
|
if (uFogEnabled != 0)
|
||||||
{
|
{
|
||||||
if (uFogEnabled == 1)
|
if (uFogEnabled == 1 || uFogEnabled == -1)
|
||||||
{
|
{
|
||||||
fogdist = pixelpos.w;
|
fogdist = pixelpos.w;
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ void main()
|
||||||
//
|
//
|
||||||
// colored fog
|
// colored fog
|
||||||
//
|
//
|
||||||
if (uFogColor.rgb != vec3(0.0))
|
if (uFogEnabled < 0)
|
||||||
{
|
{
|
||||||
frag = applyFog(frag, fogfactor);
|
frag = applyFog(frag, fogfactor);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue