From 55d4c89753d96a226f739febf9e57e0fa2d7968d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 May 2014 14:58:37 +0200 Subject: [PATCH] - fixed: fog density calculation for fixed function was not correct. --- src/gl/renderer/gl_renderstate.cpp | 9 +++++---- src/gl/renderer/gl_renderstate.h | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 7efa1d30f3..746bbb1765 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -69,7 +69,7 @@ void FRenderState::Reset() ffTextureEnabled = ffFogEnabled = false; mSpecialEffect = ffSpecialEffect = EFF_NONE; mFogColor.d = ffFogColor.d = -1; - mFogDensity = ffFogDensity = 0; + ffFogDensity = 0; mTextureMode = ffTextureMode = -1; mDesaturation = 0; mSrcBlend = GL_SRC_ALPHA; @@ -316,10 +316,11 @@ void FRenderState::Apply(bool forcenoshader) GLfloat FogColor[4]={mFogColor.r/255.0f,mFogColor.g/255.0f,mFogColor.b/255.0f,0.0f}; glFogfv(GL_FOG_COLOR, FogColor); } - if (ffFogDensity != mFogDensity) + if (ffFogDensity != mLightParms[2]) { - glFogf(GL_FOG_DENSITY, mFogDensity/64000.f); - ffFogDensity=mFogDensity; + const float LOG2E = 1.442692f; // = 1/log(2) + glFogf(GL_FOG_DENSITY, -mLightParms[2] / LOG2E); + ffFogDensity = mLightParms[2]; } } if (mSpecialEffect != ffSpecialEffect) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index e8de712f6b..888ead0d73 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -65,7 +65,6 @@ class FRenderState PalEntry mFogColor; PalEntry mObjectColor; PalEntry mDynColor; - float mFogDensity; int mEffectState; int mColormapState;