Implement additive colour on walls and sprites

Also, don't modify the alpha channel when adding the additive colour.
This commit is contained in:
Kevin Caccamo 2018-12-19 11:44:45 -05:00 committed by Christoph Oelckers
parent 80bcac48ef
commit 33723e8904
4 changed files with 7 additions and 1 deletions

View file

@ -159,6 +159,7 @@ void GLSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
: ThingColor.Modulate(cursec->SpecialColors[sector_t::sprites]); : ThingColor.Modulate(cursec->SpecialColors[sector_t::sprites]);
state.SetObjectColor(finalcol); state.SetObjectColor(finalcol);
state.SetAddColor(cursec->SpecialColors[sector_t::add]);
} }
state.SetColor(lightlevel, rel, di->isFullbrightScene(), Colormap, trans); state.SetColor(lightlevel, rel, di->isFullbrightScene(), Colormap, trans);
} }
@ -295,6 +296,7 @@ void GLSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
} }
state.SetObjectColor(0xffffffff); state.SetObjectColor(0xffffffff);
state.SetAddColor(0);
state.EnableTexture(true); state.EnableTexture(true);
state.SetDynLight(0, 0, 0); state.SetDynLight(0, 0, 0);
} }

View file

@ -174,6 +174,7 @@ void GLWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
PalEntry color2 = side->GetSpecialColor(tierndx, side_t::wallbottom, frontsector); PalEntry color2 = side->GetSpecialColor(tierndx, side_t::wallbottom, frontsector);
state.SetObjectColor(color1); state.SetObjectColor(color1);
state.SetObjectColor2(color2); state.SetObjectColor2(color2);
state.SetAddColor(seg->frontsector->SpecialColors[sector_t::add]);
if (color1 != color2) if (color1 != color2)
{ {
// Do gradient setup only if there actually is a gradient. // Do gradient setup only if there actually is a gradient.
@ -238,6 +239,7 @@ void GLWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
} }
state.SetObjectColor(0xffffffff); state.SetObjectColor(0xffffffff);
state.SetObjectColor2(0); state.SetObjectColor2(0);
state.SetAddColor(0);
state.SetTextureMode(tmode); state.SetTextureMode(tmode);
state.EnableGlow(false); state.EnableGlow(false);
state.EnableGradient(false); state.EnableGradient(false);

View file

@ -72,6 +72,7 @@ void HWDrawInfo::DrawPSprite(HUDSprite *huds, FRenderState &state)
state.SetRenderStyle(huds->RenderStyle); state.SetRenderStyle(huds->RenderStyle);
state.SetTextureMode(huds->RenderStyle); state.SetTextureMode(huds->RenderStyle);
state.SetObjectColor(huds->ObjectColor); state.SetObjectColor(huds->ObjectColor);
// state.SetAddColor(0);
state.SetDynLight(huds->dynrgb[0], huds->dynrgb[1], huds->dynrgb[2]); state.SetDynLight(huds->dynrgb[0], huds->dynrgb[1], huds->dynrgb[2]);
state.EnableBrightmap(!(huds->RenderStyle.Flags & STYLEF_ColorIsFixed)); state.EnableBrightmap(!(huds->RenderStyle.Flags & STYLEF_ColorIsFixed));
@ -94,6 +95,7 @@ void HWDrawInfo::DrawPSprite(HUDSprite *huds, FRenderState &state)
state.SetTextureMode(TM_NORMAL); state.SetTextureMode(TM_NORMAL);
state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold); state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
state.SetObjectColor(0xffffffff); state.SetObjectColor(0xffffffff);
state.SetAddColor(0);
state.SetDynLight(0, 0, 0); state.SetDynLight(0, 0, 0);
state.EnableBrightmap(false); state.EnableBrightmap(false);
} }

View file

@ -114,7 +114,7 @@ vec4 getTexel(vec2 st)
if (uObjectColor2.a == 0.0) texel *= uObjectColor; if (uObjectColor2.a == 0.0) texel *= uObjectColor;
else texel *= mix(uObjectColor, uObjectColor2, gradientdist.z); else texel *= mix(uObjectColor, uObjectColor2, gradientdist.z);
texel += uAddColor; texel.rgb += uAddColor.rgb;
return desaturate(texel); return desaturate(texel);
} }