- fixed brightmaps again - hopefully for real this time.

The lighting model being used here is not really good for implementing render effect.
This commit is contained in:
Christoph Oelckers 2019-11-11 23:54:09 +01:00
parent 3be9deb070
commit 022c074ece
4 changed files with 10 additions and 6 deletions

View file

@ -1162,7 +1162,6 @@ static void destroy_window_resources()
#endif #endif
} }
extern int globalShadeDiv;
void sdlayer_setvideomode_opengl(int y) void sdlayer_setvideomode_opengl(int y)
{ {
glsurface_destroy(); glsurface_destroy();
@ -1171,8 +1170,6 @@ void sdlayer_setvideomode_opengl(int y)
GLInterface.Deinit(); GLInterface.Deinit();
GLInterface.Init(y); GLInterface.Init(y);
GLInterface.InitGLState(4, glmultisample); GLInterface.InitGLState(4, glmultisample);
// I have no idea how to get this info from the lookup tables. Fortunately it is consistent per game.
GLInterface.SetShadeDiv(globalShadeDiv);
GLInterface.mSamplers->SetTextureFilterMode(hw_texfilter, hw_anisotropy); GLInterface.mSamplers->SetTextureFilterMode(hw_texfilter, hw_anisotropy);

View file

@ -1128,6 +1128,9 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
m->texid[globalpal] = gloadtex(m->mytex, m->mytexx, m->mytexy, m->is8bit, globalpal); m->texid[globalpal] = gloadtex(m->mytex, m->mytexx, m->mytexy, m->is8bit, globalpal);
GLInterface.BindTexture(0, m->texid[globalpal], -1); GLInterface.BindTexture(0, m->texid[globalpal], -1);
GLInterface.UseBrightmaps(false);
GLInterface.UseGlowMapping(false);
GLInterface.UseDetailMapping(false);
#endif #endif
auto data = GLInterface.AllocVertices(m->qcnt * 4); auto data = GLInterface.AllocVertices(m->qcnt * 4);

View file

@ -288,7 +288,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
else else
{ {
UseBrightmaps(true); UseBrightmaps(true);
BindTexture(5, mtex, sampler); BindTexture(5, htex, sampler);
} }
} }
} }

View file

@ -196,13 +196,17 @@ void main()
color.rgb *= detailColor.rgb; color.rgb *= detailColor.rgb;
vec3 lightcolor = v_color.rgb; vec3 lightcolor = v_color.rgb;
bool shadeIt = ((u_flags & RF_FogDisabled) == 0);
// The lighting model here does not really allow more than a simple on/off brightmap because anything more complex inteferes with the shade ramp... :( // 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) if ((u_flags & RF_Brightmapping) != 0)
{ {
vec4 brightcolor = texture2D(s_brightmap, v_texCoord.xy); vec4 brightcolor = texture2D(s_brightmap, v_texCoord.xy);
color.rgb *= clamp(brightcolor.rgb + v_color.rgb, 0.0, 1.0); if (grayscale(brightcolor) > 0.5)
{
shadeIt = false;
} }
else if ((u_flags & RF_FogDisabled) == 0) }
if (shadeIt)
{ {
color.rgb *= lightcolor; color.rgb *= lightcolor;
shade = clamp(shade * u_shadeDiv, 0.0, 1.0); // u_shadeDiv is really 1/shadeDiv. shade = clamp(shade * u_shadeDiv, 0.0, 1.0); // u_shadeDiv is really 1/shadeDiv.