diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 2da0859e7..eba530d35 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1098,6 +1098,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) GLInterface.EnableBlend(true); // else GLInterface.EnableBlend(false); } else pc[3] = 1.f; + GLInterface.SetFadeDisable(true); // disable depth fading. The voxel code is somewhat broken and messes this up. + GLInterface.SetShade(0, numshades); //------------ //transform to Build coords @@ -1186,6 +1188,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) } VSMatrix identity(0); GLInterface.SetMatrix(Matrix_ModelView, &identity); + GLInterface.SetFadeDisable(false); GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255)); return 1; } diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 29443b355..da783174c 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -392,6 +392,11 @@ void GLInstance::SetFadeColor(PalEntry color) renderState.FogColor[2] = color.b * (1 / 255.f); }; +void GLInstance::SetFadeDisable(bool on) +{ + renderState.FogColor[3] = on; +} + void GLInstance::SetColorMask(bool on) { glColorMask(on, on, on, on); diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index e41c3277a..c9dc3e2b9 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -279,6 +279,7 @@ public: void SetDepthFunc(int func); void SetFadeColor(PalEntry color); + void SetFadeDisable(bool on); void SetColorMask(bool on); void SetDepthMask(bool on); void SetBlendFunc(int src, int dst); diff --git a/wadsrc/static/demolition/shaders/glsl/polymost.fp b/wadsrc/static/demolition/shaders/glsl/polymost.fp index ae4fb1a2d..1259d5f9e 100644 --- a/wadsrc/static/demolition/shaders/glsl/polymost.fp +++ b/wadsrc/static/demolition/shaders/glsl/polymost.fp @@ -183,10 +183,12 @@ void main() else { color.rgb *= detailColor.rgb; - shade = clamp(shade / (u_numShades-2), 0.0, 1.0); - // Apply the shade as a linear depth fade ramp. - color.rgb = mix(color.rgb, u_fogColor.rgb, shade); - + if (u_fogColor.a == 0.0) + { + shade = clamp(shade / (u_numShades-2), 0.0, 1.0); + // Apply the shade as a linear depth fade ramp. + color.rgb = mix(color.rgb, u_fogColor.rgb, shade); + } } if (fullbright == 0.0) color.rgb *= v_color.rgb; color.a *= v_color.a;