- tweaked the fade ramp a bit.

For Duke Nukem and its direct offspring (Nam, WW2GI and Redneck Rampage) the ramp is not a linear fade from 0 to 1, it needs to be a little darker than that.
Unfortunately the proper factor needed here must be set manually, this cannot really be calculated from the lookup tables.
This commit is contained in:
Christoph Oelckers 2019-10-20 01:14:48 +02:00
parent 9437387b4a
commit 85d377647a
8 changed files with 37 additions and 14 deletions

View file

@ -354,6 +354,8 @@ static void sighandler(int signum)
#ifdef _WIN32 #ifdef _WIN32
FString currentGame; // Currently there is no global state for the current game. This is a temporary workaround because the video init code needs to do a few things based on the active game.
namespace Duke namespace Duke
{ {
extern GameInterface Interface; extern GameInterface Interface;
@ -376,6 +378,7 @@ GameInterface *CheckFrontend()
FILE* f = fopen("blood.rff", "rb"); FILE* f = fopen("blood.rff", "rb");
if (f) if (f)
{ {
currentGame = "Blood";
fclose(f); fclose(f);
return &Blood::Interface; return &Blood::Interface;
} }
@ -384,13 +387,26 @@ GameInterface *CheckFrontend()
f = fopen("redneck.grp", "rb"); f = fopen("redneck.grp", "rb");
if (f) if (f)
{ {
currentGame = "Redneck"; // RRRA is not separately covered
fclose(f); fclose(f);
return &Redneck::Interface; return &Redneck::Interface;
} }
else else
{ {
f = fopen("sw.grp", "rb"); f = fopen("sw.grp", "rb");
if (f) return &ShadowWarrior::Interface; if (f)
{
currentGame = "ShadowWarrior";
fclose(f);
return &ShadowWarrior::Interface;
}
f = fopen("fury.grp", "rb");
if (f)
{
currentGame = "Fury";
fclose(f);
}
else currentGame = "Duke"; // also covers Nam and WW2GI.
return &Duke::Interface; return &Duke::Interface;
} }
} }
@ -1341,11 +1357,12 @@ void sdlayer_setvideomode_opengl(void)
GLInterface.Deinit(); GLInterface.Deinit();
GLInterface.Init(); GLInterface.Init();
GLInterface.InitGLState(4, glmultisample); GLInterface.InitGLState(4, glmultisample);
#if 1 // I have no idea how to get this info from the lookup tables. Fortunately it is consistent per game.
GLInterface.mSamplers->SetTextureFilterMode(0, 1); if (!currentGame.Compare("Blood")) GLInterface.SetShadeDiv(62);
#else else if (!currentGame.Compare("Fury")) GLInterface.SetShadeDiv(30);
else GLInterface.SetShadeDiv(26);
GLInterface.mSamplers->SetTextureFilterMode(gltexfiltermode, glanisotropy); GLInterface.mSamplers->SetTextureFilterMode(gltexfiltermode, glanisotropy);
#endif
} }

View file

@ -421,10 +421,6 @@ void G_CacheMapData(void)
S_TryPlaySpecialMusic(MUS_LOADING); S_TryPlaySpecialMusic(MUS_LOADING);
#if defined EDUKE32_TOUCH_DEVICES && defined USE_OPENGL
polymost_glreset();
#endif
uint32_t const cacheStartTime = timerGetTicks(); uint32_t const cacheStartTime = timerGetTicks();
cacheFlaggedTiles(); cacheFlaggedTiles();

View file

@ -27,6 +27,7 @@ struct PolymostRenderState
{ {
float Shade; float Shade;
float NumShades = 64.f; float NumShades = 64.f;
float ShadeDiv = 62.f;
float VisFactor = 128.f; float VisFactor = 128.f;
int Flags = 0; int Flags = 0;
float NPOTEmulationFactor = 1.f; float NPOTEmulationFactor = 1.f;

View file

@ -137,6 +137,7 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
Flags.Init(hShader, "u_flags"); Flags.Init(hShader, "u_flags");
Shade.Init(hShader, "u_shade"); Shade.Init(hShader, "u_shade");
ShadeDiv.Init(hShader, "u_shadeDiv");
NumShades.Init(hShader, "u_numShades"); NumShades.Init(hShader, "u_numShades");
VisFactor.Init(hShader, "u_visFactor"); VisFactor.Init(hShader, "u_visFactor");
NPOTEmulationFactor.Init(hShader, "u_npotEmulationFactor"); NPOTEmulationFactor.Init(hShader, "u_npotEmulationFactor");

View file

@ -38,6 +38,7 @@ public:
FBufferedUniform1i Flags; FBufferedUniform1i Flags;
FBufferedUniform1f Shade; FBufferedUniform1f Shade;
FBufferedUniform1f NumShades; FBufferedUniform1f NumShades;
FBufferedUniform1f ShadeDiv;
FBufferedUniform1f VisFactor; FBufferedUniform1f VisFactor;
FBufferedUniform1f NPOTEmulationFactor; FBufferedUniform1f NPOTEmulationFactor;
FBufferedUniform1f NPOTEmulationXOffset; FBufferedUniform1f NPOTEmulationXOffset;

View file

@ -484,6 +484,7 @@ void PolymostRenderState::Apply(PolymostShader* shader)
shader->Flags.Set(Flags); shader->Flags.Set(Flags);
shader->Shade.Set(Shade); shader->Shade.Set(Shade);
shader->NumShades.Set(NumShades); shader->NumShades.Set(NumShades);
shader->ShadeDiv.Set(ShadeDiv);
shader->VisFactor.Set(VisFactor); shader->VisFactor.Set(VisFactor);
shader->Flags.Set(Flags); shader->Flags.Set(Flags);
shader->NPOTEmulationFactor.Set(NPOTEmulationFactor); shader->NPOTEmulationFactor.Set(NPOTEmulationFactor);

View file

@ -320,9 +320,14 @@ public:
renderState.NumShades = numshades; renderState.NumShades = numshades;
} }
void SetShadeDiv(int value)
{
renderState.ShadeDiv = 1.f / value; // There's 3 values here: Blood uses 62 with numShades = 64, Ion Fury uses 30 with NumShades = 32, the other games use 26 with NumShades = 32.
}
void SetVisibility(float visibility, float fviewingrange) void SetVisibility(float visibility, float fviewingrange)
{ {
renderState.VisFactor = visibility * fviewingrange * (1.f / (64.f * 65536.f)); renderState.VisFactor = visibility* fviewingrange* (1.f / (64.f * 65536.f));
} }
void UseColorOnly(bool yes) void UseColorOnly(bool yes)

View file

@ -30,6 +30,7 @@ uniform sampler2D s_glow;
uniform float u_shade; uniform float u_shade;
uniform float u_numShades; uniform float u_numShades;
uniform float u_shadeDiv;
uniform float u_visFactor; uniform float u_visFactor;
uniform int u_flags; uniform int u_flags;
@ -192,7 +193,7 @@ void main()
color.rgb *= detailColor.rgb; color.rgb *= detailColor.rgb;
if ((u_flags & RF_FogDisabled) == 0) if ((u_flags & RF_FogDisabled) == 0)
{ {
shade = clamp(shade / (u_numShades-2), 0.0, 1.0); shade = clamp(shade * u_shadeDiv, 0.0, 1.0); // u_shadeDiv is really 1/shadeDiv.
// Apply the shade as a linear depth fade ramp. // Apply the shade as a linear depth fade ramp.
color.rgb = mix(color.rgb, u_fogColor.rgb, shade); color.rgb = mix(color.rgb, u_fogColor.rgb, shade);
} }