- fixed RRRA E2L1 fog.

This commit is contained in:
Christoph Oelckers 2020-06-07 08:24:12 +02:00
parent 3adfdfcac5
commit 353e3eb1fa
2 changed files with 27 additions and 5 deletions

View file

@ -533,7 +533,7 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState& oldState)
{ {
if (!FogColor.isBlack()) if (!FogColor.isBlack())
{ {
Flags &= ~RF_Brightmapping; //Flags &= ~RF_Brightmapping;
shader->muFogEnabled.Set(-1); shader->muFogEnabled.Set(-1);
} }
else else
@ -543,12 +543,17 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState& oldState)
} }
else shader->muFogEnabled.Set(0); 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->Flags.Set(Flags);
shader->TextureMode.Set(texturemode);
shader->NPOTEmulationFactor.Set(NPOTEmulationFactor); shader->NPOTEmulationFactor.Set(NPOTEmulationFactor);
shader->NPOTEmulationXOffset.Set(NPOTEmulationXOffset); shader->NPOTEmulationXOffset.Set(NPOTEmulationXOffset);
shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f); shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f);
shader->Brightness.Set(Brightness); 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 }; float lightattr[] = { ShadeDiv / (numshades - 2), VisFactor, (Flags & RF_MapFog) ? -5.f : 0.f , ShadeDiv >= 1 / 1000.f? Shade : 0 };
shader->muLightParms.Set(lightattr); shader->muLightParms.Set(lightattr);

View file

@ -6,6 +6,24 @@ const int RF_Brightmapping = 16;
const int RF_NPOTEmulation = 32; const int RF_NPOTEmulation = 32;
const int RF_ShadeInterpolate = 64; 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 //s_texture points to an indexed color texture
uniform sampler2D s_texture; uniform sampler2D s_texture;
//s_palswap is the palette swap texture where u is the color index and v is the shade //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. 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); float fogfactor = 0.55 + 0.3 * exp2 (uFogDensity * v_fogCoord / 1024.0);
color.rgb = vec3(0.6*(1.0-fogfactor)) + color.rgb * fogfactor;// mix(vec3(0.6), color.rgb, fogfactor); 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. 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; color.a *= v_color.a;
} }
else else