- fixed most issues with palette emulation.

Brightness is now correct - I have no idea why this factor of 1/0.85 is needed - something must reduce the brightness of the entire scene but I have no idea what.
This commit is contained in:
Christoph Oelckers 2020-09-18 20:54:08 +02:00
parent 7b879f6fe7
commit 29a10cabcb
3 changed files with 10 additions and 11 deletions

View file

@ -119,8 +119,16 @@ IHardwareTexture* PaletteManager::GetLookup(int index)
{
auto p = screen->CreateHardwareTexture(1);
// Perform a 0<->255 index swap. The lookup tables are still the original data.
TArray<uint8_t> lookup(numshades * 256, true);
memcpy(lookup.Data(), lookups.getTable(index), lookup.Size());
for (int i = 0; i < numshades; i++)
{
auto p = &lookup[i * 256];
p[255] = p[0];
p[0] = 0;
for (int v = 1; v <= 255; v++) if (p[v] == 0) p[v] = 255;
}
p->CreateTexture(lookup.Data(), 256, numshades, 15, false, "PaletteLookup");
lookuptextures[index] = p;
}

View file

@ -17,15 +17,7 @@ vec4 ProcessTexel()
vec2 newCoord;
// z is the depth in view space, positive going into the screen
float z;
if (((uPalLightLevels >> 8) & 0xff) == 2)
{
z = distance(pixelpos.xyz, uCameraPos.xyz)*0.7;
}
else
{
z = pixelpos.w;
}
float z = abs(pixelpos.w);
// Coordinate adjustment for NPOT textures. It is somehow fitting that Build games exploited this texture wrapping quirk of the software rendering engine...
if (uNpotEmulation.y != 0.0)
@ -68,5 +60,5 @@ vec4 ProcessTexel()
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.
return color;
return vec4(color.rgb / 0.85, vColor.a);
}

View file

@ -161,7 +161,6 @@ const int Tex_Blend_Hardlight = 4;
vec4 getTexel(vec2 st)
{
vec4 texel = texture(tex, st);
//
// Apply texture modes
//