mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- made brightmaps operational.
The logic is not yet optimal but at least it works.
This commit is contained in:
parent
21ac5e87b5
commit
5fc81d1bd4
11 changed files with 50 additions and 13 deletions
|
@ -171,7 +171,6 @@ void ShutDown(void)
|
|||
{
|
||||
if (!in3dmode())
|
||||
return;
|
||||
G_SaveConfig();
|
||||
netDeinitialize();
|
||||
sndTerm();
|
||||
sfxTerm();
|
||||
|
|
|
@ -258,6 +258,7 @@ int GameMain()
|
|||
// Just let the rest of the function execute.
|
||||
r = exit.Reason();
|
||||
}
|
||||
G_SaveConfig();
|
||||
#ifndef NETCODE_DISABLE
|
||||
if (gHaveNetworking) enet_deinitialize();
|
||||
#endif
|
||||
|
|
|
@ -259,6 +259,7 @@ public:
|
|||
|
||||
int alphaThreshold = 128;
|
||||
picanm_t PicAnim = {};
|
||||
FixedBitArray<256> NoBrightmapFlag{ 0 };
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -1464,6 +1464,12 @@ class FixedBitArray
|
|||
|
||||
public:
|
||||
|
||||
FixedBitArray() = default;
|
||||
FixedBitArray(bool set)
|
||||
{
|
||||
memset(bytes, set ? -1 : 0, sizeof(bytes));
|
||||
}
|
||||
|
||||
bool operator[](size_t index) const
|
||||
{
|
||||
return !!(bytes[index >> 3] & (1 << (index & 7)));
|
||||
|
|
|
@ -5674,7 +5674,6 @@ static void G_Cleanup(void)
|
|||
|
||||
void G_Shutdown(void)
|
||||
{
|
||||
G_SaveConfig();
|
||||
S_SoundShutdown();
|
||||
S_MusicShutdown();
|
||||
CONTROL_Shutdown();
|
||||
|
|
|
@ -170,6 +170,8 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
|
|||
glUniform1i(SamplerLoc, 3);
|
||||
SamplerLoc = glGetUniformLocation(hShader, "s_glow");
|
||||
glUniform1i(SamplerLoc, 4);
|
||||
SamplerLoc = glGetUniformLocation(hShader, "s_brightmap");
|
||||
glUniform1i(SamplerLoc, 5);
|
||||
|
||||
glUseProgram(0);
|
||||
return true;
|
||||
|
|
|
@ -100,6 +100,7 @@ FHardwareTexture* GLInstance::CreateTrueColorTexture(FTexture* tex, int palid, b
|
|||
bool npoty = false;
|
||||
|
||||
auto palette = palid < 0? nullptr : palmanager.GetPaletteData(palid);
|
||||
if (palette == nullptr) return nullptr;
|
||||
auto texbuffer = tex->CreateTexBuffer(palette, CTF_ProcessData);
|
||||
// Check if the texture is fully transparent. When creating a brightmap such textures can be discarded.
|
||||
if (checkfulltransparency)
|
||||
|
@ -144,7 +145,7 @@ FHardwareTexture* GLInstance::LoadTexture(FTexture* tex, int textype, int palid)
|
|||
else
|
||||
hwtex = CreateTrueColorTexture(tex, textype == TT_HICREPLACE? -1 : palid, textype == TT_BRIGHTMAP, textype == TT_BRIGHTMAP);
|
||||
|
||||
tex->SetHardwareTexture(palid, hwtex);
|
||||
if (hwtex) tex->SetHardwareTexture(palid, hwtex);
|
||||
return hwtex;
|
||||
}
|
||||
|
||||
|
@ -177,7 +178,12 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
else
|
||||
{
|
||||
// Only look up the palette if we really want to use it (i.e. when creating a true color texture of an ART tile.)
|
||||
if (TextureType == TT_TRUECOLOR) lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false);
|
||||
if (TextureType == TT_TRUECOLOR)
|
||||
{
|
||||
/*lookuppal = palmanager.LookupPalette(usepalette, usepalswap, true);
|
||||
if (lookuppal< 0)*/ lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Load the main texture
|
||||
|
@ -191,6 +197,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
sampler = sampler + SamplerNoFilterRepeat - SamplerRepeat;
|
||||
}
|
||||
else renderState.Flags &= ~RF_UsePalette;
|
||||
UseBrightmaps(false);
|
||||
|
||||
BindTexture(0, mtex, sampler);
|
||||
if (rep && (rep->scale.x != 1.0f || rep->scale.y != 1.0f || xpanning != 0 || ypanning != 0))
|
||||
|
@ -251,7 +258,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
BindTexture(4, htex, SamplerRepeat);
|
||||
}
|
||||
}
|
||||
if (!(tex->PicAnim.sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT))
|
||||
if (!(tex->PicAnim.sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT) && !tex->NoBrightmapFlag[usepalswap])
|
||||
{
|
||||
if (TextureType == TT_HICREPLACE)
|
||||
{
|
||||
|
@ -259,9 +266,13 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
if (brep)
|
||||
{
|
||||
auto htex = LoadTexture(brep->faces[0], TT_HICREPLACE, 0);
|
||||
// UseBrightmapping(true);
|
||||
UseBrightmaps(true);
|
||||
BindTexture(5, mtex, sampler);
|
||||
}
|
||||
else
|
||||
{
|
||||
tex->PicAnim.sf |= PICANM_NOFULLBRIGHT_BIT;
|
||||
}
|
||||
}
|
||||
else if (TextureType == TT_TRUECOLOR)
|
||||
{
|
||||
|
@ -269,8 +280,16 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
|
|||
if (lookuppal >= 0)
|
||||
{
|
||||
auto htex = LoadTexture(tex, TT_BRIGHTMAP, lookuppal);
|
||||
// UseBrightmapping(true);
|
||||
BindTexture(5, mtex, sampler);
|
||||
if (htex == nullptr)
|
||||
{
|
||||
// Flag the texture as not being brightmapped for the given palette
|
||||
tex->NoBrightmapFlag.Set(usepalswap);
|
||||
}
|
||||
else
|
||||
{
|
||||
UseBrightmaps(true);
|
||||
BindTexture(5, mtex, sampler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -505,6 +505,8 @@ void GLInstance::DrawImGui(ImDrawData* data)
|
|||
|
||||
void PolymostRenderState::Apply(PolymostShader* shader)
|
||||
{
|
||||
// Disable brightmaps if non-black fog is used.
|
||||
if (!(Flags & RF_FogDisabled) && !FogColor.isBlack()) Flags &= ~RF_Brightmapping;
|
||||
shader->Flags.Set(Flags);
|
||||
shader->Shade.Set(Shade);
|
||||
shader->NumShades.Set(NumShades);
|
||||
|
|
|
@ -7066,7 +7066,6 @@ static void G_Cleanup(void)
|
|||
|
||||
void G_Shutdown(void)
|
||||
{
|
||||
G_SaveConfig();
|
||||
S_SoundShutdown();
|
||||
S_MusicShutdown();
|
||||
CONTROL_Shutdown();
|
||||
|
|
|
@ -664,7 +664,6 @@ TerminateGame(void)
|
|||
}
|
||||
|
||||
engineUnInit();
|
||||
G_SaveConfig();
|
||||
|
||||
//Terminate3DSounds(); // Kill the sounds linked list
|
||||
UnInitSound();
|
||||
|
@ -770,7 +769,6 @@ void MultiSharewareCheck(void)
|
|||
#endif
|
||||
//uninitmultiplayers();
|
||||
//uninitkeys();
|
||||
G_SaveConfig();
|
||||
engineUnInit();
|
||||
UnInitSound();
|
||||
timerUninit();
|
||||
|
|
|
@ -27,6 +27,7 @@ uniform sampler2D s_palette;
|
|||
|
||||
uniform sampler2D s_detail;
|
||||
uniform sampler2D s_glow;
|
||||
uniform sampler2D s_brightmap;
|
||||
|
||||
uniform float u_shade;
|
||||
uniform float u_numShades;
|
||||
|
@ -188,19 +189,29 @@ void main()
|
|||
palettedColor.a = c_one-floor(color.r);
|
||||
color = palettedColor;
|
||||
color.rgb *= detailColor.rgb; // with all this palettizing, this can only be applied afterward, even though it is wrong to do it this way.
|
||||
if (fullbright == 0.0) color.rgb *= v_color.rgb; // Well, this is dead wrong but unavoidable. For colored fog it applies the light to the fog as well...
|
||||
}
|
||||
else
|
||||
{
|
||||
color.rgb *= detailColor.rgb;
|
||||
if ((u_flags & RF_FogDisabled) == 0)
|
||||
|
||||
vec3 lightcolor = v_color.rgb;
|
||||
// The lighting model here does not really allow more than a simple on/off brightmap because anything more complex inteferes with the shade ramp... :(
|
||||
if ((u_flags & RF_Brightmapping) != 0)
|
||||
{
|
||||
vec4 brightcolor = texture2D(s_brightmap, v_texCoord.xy);
|
||||
color.rgb *= clamp(brightcolor.rgb + v_color.rgb, 0.0, 1.0);
|
||||
}
|
||||
else if ((u_flags & RF_FogDisabled) == 0)
|
||||
{
|
||||
color.rgb *= lightcolor;
|
||||
shade = clamp(shade * u_shadeDiv, 0.0, 1.0); // u_shadeDiv is really 1/shadeDiv.
|
||||
// Apply the shade as a linear depth fade ramp.
|
||||
color.rgb = mix(color.rgb, u_fogColor.rgb, shade);
|
||||
}
|
||||
}
|
||||
if (color.a < u_alphaThreshold) discard; // it's only here that we have the alpha value available to be able to perform the alpha test.
|
||||
if (fullbright == 0.0) color.rgb *= v_color.rgb;
|
||||
|
||||
color.a *= v_color.a;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue