From 353e3eb1fa433d462e6e8aa35b249afbfd686914 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Jun 2020 08:24:12 +0200 Subject: [PATCH] - fixed RRRA E2L1 fog. --- source/glbackend/glbackend.cpp | 9 ++++++-- wadsrc/static/engine/shaders/glsl/polymost.fp | 23 ++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 8ccb4059c..15c8bd2c3 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -533,7 +533,7 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState& oldState) { if (!FogColor.isBlack()) { - Flags &= ~RF_Brightmapping; + //Flags &= ~RF_Brightmapping; shader->muFogEnabled.Set(-1); } else @@ -543,12 +543,17 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState& oldState) } else shader->muFogEnabled.Set(0); + int texturemode = 0; + if (Flags & RF_DetailMapping) texturemode |= 0x20000; + if (Flags & RF_Brightmapping) texturemode |= 0x10000; + if (Flags & RF_GlowMapping) texturemode |= 0x40000; shader->Flags.Set(Flags); + shader->TextureMode.Set(texturemode); shader->NPOTEmulationFactor.Set(NPOTEmulationFactor); shader->NPOTEmulationXOffset.Set(NPOTEmulationXOffset); shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f); shader->Brightness.Set(Brightness); - shader->FogColor.Set(FogColor); + shader->FogColor.Set((Flags& RF_MapFog)? PalEntry(0x999999) : FogColor); float lightattr[] = { ShadeDiv / (numshades - 2), VisFactor, (Flags & RF_MapFog) ? -5.f : 0.f , ShadeDiv >= 1 / 1000.f? Shade : 0 }; shader->muLightParms.Set(lightattr); diff --git a/wadsrc/static/engine/shaders/glsl/polymost.fp b/wadsrc/static/engine/shaders/glsl/polymost.fp index dc2a1759c..b6471b67c 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.fp +++ b/wadsrc/static/engine/shaders/glsl/polymost.fp @@ -6,6 +6,24 @@ const int RF_Brightmapping = 16; const int RF_NPOTEmulation = 32; const int RF_ShadeInterpolate = 64; + +struct Material +{ + vec4 Base; + vec4 Bright; + vec4 Glow; + vec3 Normal; + vec3 Specular; + float Glossiness; + float SpecularLevel; + float Metallic; + float Roughness; + float AO; +}; + +Material material; + + //s_texture points to an indexed color texture uniform sampler2D s_texture; //s_palswap is the palette swap texture where u is the color index and v is the shade @@ -221,11 +239,10 @@ void main() } if (uFogDensity != 0.0) // fog hack for RRRA E2L1. Needs to be done better, this is gross, but still preferable to the broken original implementation. { - float fogfactor = 0.55 + 0.3 * exp2 (uFogDensity * v_fogCoord); - color.rgb = vec3(0.6*(1.0-fogfactor)) + color.rgb * fogfactor;// mix(vec3(0.6), color.rgb, fogfactor); + float fogfactor = 0.55 + 0.3 * exp2 (uFogDensity * v_fogCoord / 1024.0); + color.rgb = uFogColor.rgb * (1.0-fogfactor) + color.rgb * fogfactor;// mix(vec3(0.6), color.rgb, fogfactor); } if (color.a < uAlphaThreshold) discard; // it's only here that we have the alpha value available to be able to perform the alpha test. - color.a *= v_color.a; } else