- fixed handling of FF_FADEWALLS on 3D floors. The problems with the old method became quite obvious in the demo map after the light list bug got fixed.

This commit is contained in:
Christoph Oelckers 2016-01-29 17:13:14 +01:00
parent d0b194563a
commit d037493ffe
10 changed files with 25 additions and 49 deletions

View file

@ -7,6 +7,7 @@
extern DWORD gl_fixedcolormap; extern DWORD gl_fixedcolormap;
struct lightlist_t;
enum EColorManipulation enum EColorManipulation
{ {
@ -64,6 +65,8 @@ struct FColormap
blendfactor = from->Color.a; blendfactor = from->Color.a;
} }
void CopyFrom3DLight(lightlist_t *light);
void Decolorize() // this for 'nocoloredspritelighting' and not the same as desaturation. The normal formula results in a value that's too dark. void Decolorize() // this for 'nocoloredspritelighting' and not the same as desaturation. The normal formula results in a value that's too dark.
{ {
int v = (LightColor.r + LightColor.g + LightColor.b) / 3; int v = (LightColor.r + LightColor.g + LightColor.b) / 3;

View file

@ -2,6 +2,7 @@
#define __GL_LIGHTDATA #define __GL_LIGHTDATA
#include "v_palette.h" #include "v_palette.h"
#include "p_3dfloors.h"
#include "r_data/renderstyle.h" #include "r_data/renderstyle.h"
#include "gl/renderer/gl_colormap.h" #include "gl/renderer/gl_colormap.h"
@ -49,4 +50,15 @@ extern int outsidefogdensity;
extern int skyfog; extern int skyfog;
inline void FColormap::CopyFrom3DLight(lightlist_t *light)
{
LightColor = light->extra_colormap->Color;
desaturation = light->extra_colormap->Desaturate;
blendfactor = light->extra_colormap->Color.a;
if (light->caster && (light->caster->flags&FF_FADEWALLS) && (light->extra_colormap->Fade & 0xffffff) != 0)
FadeColor = light->extra_colormap->Fade;
}
#endif #endif

View file

@ -466,7 +466,8 @@ void GLFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside)
lightlevel = *light->p_lightlevel; lightlevel = *light->p_lightlevel;
if (rover->flags & FF_FOG) Colormap.LightColor = (light->extra_colormap)->Fade; if (rover->flags & FF_FOG) Colormap.LightColor = (light->extra_colormap)->Fade;
else Colormap.CopyLightColor(light->extra_colormap); else Colormap.CopyFrom3DLight(light);
alpha = rover->alpha/255.0f; alpha = rover->alpha/255.0f;
renderstyle = rover->flags&FF_ADDITIVETRANS? STYLE_Add : STYLE_Translucent; renderstyle = rover->flags&FF_ADDITIVETRANS? STYLE_Add : STYLE_Translucent;
@ -546,13 +547,13 @@ void GLFlat::ProcessSector(sector_t * frontsector)
if (x.ffloors.Size()) if (x.ffloors.Size())
{ {
light = P_GetPlaneLight(sector, &frontsector->floorplane, false); light = P_GetPlaneLight(sector, &frontsector->floorplane, false);
if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || !light->fromsector) if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || light->lightsource == NULL)
&& (light->p_lightlevel != &frontsector->lightlevel)) && (light->p_lightlevel != &frontsector->lightlevel))
{ {
lightlevel = *light->p_lightlevel; lightlevel = *light->p_lightlevel;
} }
Colormap.CopyLightColor(light->extra_colormap); Colormap.CopyFrom3DLight(light);
} }
renderstyle = STYLE_Translucent; renderstyle = STYLE_Translucent;
if (alpha!=0.0f) Process(frontsector, false, false); if (alpha!=0.0f) Process(frontsector, false, false);
@ -604,7 +605,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
{ {
lightlevel = *light->p_lightlevel; lightlevel = *light->p_lightlevel;
} }
Colormap.CopyLightColor(light->extra_colormap); Colormap.CopyFrom3DLight(light);
} }
renderstyle = STYLE_Translucent; renderstyle = STYLE_Translucent;
if (alpha!=0.0f) Process(frontsector, true, false); if (alpha!=0.0f) Process(frontsector, true, false);

View file

@ -349,7 +349,7 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent)
{ {
copySprite=*this; copySprite=*this;
copySprite.lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel); copySprite.lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel);
copySprite.Colormap.CopyLightColor(lightlist[i].extra_colormap); copySprite.Colormap.CopyFrom3DLight(&lightlist[i]);
if (glset.nocoloredspritelighting) if (glset.nocoloredspritelighting)
{ {
@ -389,7 +389,7 @@ void GLSprite::SetSpriteColor(sector_t *sector, fixed_t center_y)
if (maplightbottom<center_y) if (maplightbottom<center_y)
{ {
lightlevel=*lightlist[i].p_lightlevel; lightlevel=*lightlist[i].p_lightlevel;
Colormap.CopyLightColor(lightlist[i].extra_colormap); Colormap.CopyFrom3DLight(&lightlist[i]);
if (glset.nocoloredspritelighting) if (glset.nocoloredspritelighting)
{ {

View file

@ -41,7 +41,6 @@ enum WallTypes
RENDERWALL_M2SNF, RENDERWALL_M2SNF,
RENDERWALL_COLOR, RENDERWALL_COLOR,
RENDERWALL_FFBLOCK, RENDERWALL_FFBLOCK,
RENDERWALL_COLORLAYER,
// Insert new types at the end! // Insert new types at the end!
}; };

View file

@ -118,7 +118,6 @@ void GLWall::PutWall(bool translucent)
2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog, used on mid texture lines with a fog boundary. 2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog, used on mid texture lines with a fog boundary.
3, //RENDERWALL_COLOR, // translucent 3, //RENDERWALL_COLOR, // translucent
2, //RENDERWALL_FFBLOCK // depends on render and texture settings 2, //RENDERWALL_FFBLOCK // depends on render and texture settings
4, //RENDERWALL_COLORLAYER // color layer needs special handling
}; };
if (gltexture && gltexture->GetTransparent() && passflag[type] == 2) if (gltexture && gltexture->GetTransparent() && passflag[type] == 2)
@ -162,10 +161,6 @@ void GLWall::PutWall(bool translucent)
} }
else switch (type) else switch (type)
{ {
case RENDERWALL_COLORLAYER:
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this);
break;
// portals don't go into the draw list. // portals don't go into the draw list.
// Instead they are added to the portal manager // Instead they are added to the portal manager
case RENDERWALL_HORIZON: case RENDERWALL_HORIZON:
@ -230,9 +225,6 @@ void GLWall::PutWall(bool translucent)
void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent)
{ {
bool fadewall = (!translucent && lightlist->caster && (lightlist->caster->flags&FF_FADEWALLS) &&
!gl_isBlack((lightlist->extra_colormap)->Fade)) && gl_isBlack(Colormap.FadeColor);
// only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects // only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects
if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel) if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel)
{ {
@ -240,23 +232,8 @@ void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent)
} }
// relative light won't get changed here. It is constant across the entire wall. // relative light won't get changed here. It is constant across the entire wall.
Colormap.CopyLightColor(lightlist->extra_colormap); Colormap.CopyFrom3DLight(lightlist);
if (fadewall) lightlevel=255;
PutWall(translucent); PutWall(translucent);
if (fadewall)
{
FMaterial *tex = gltexture;
type = RENDERWALL_COLORLAYER;
gltexture = NULL;
Colormap.LightColor = (lightlist->extra_colormap)->Fade;
alpha = (255-(*lightlist->p_lightlevel))/255.f*1.f;
if (alpha>0.f) PutWall(true);
type = RENDERWALL_FFBLOCK;
alpha = 1.0;
gltexture = tex;
}
} }
//========================================================================== //==========================================================================
@ -410,8 +387,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent)
int ll=lightlevel; int ll=lightlevel;
FColormap lc=Colormap; FColormap lc=Colormap;
if (i > 0) Put3DWall(&lightlist[i], translucent); Put3DWall(&lightlist[i], translucent);
else PutWall(translucent); // uppermost section does not alter light at all.
lightlevel=ll; lightlevel=ll;
Colormap=lc; Colormap=lc;

View file

@ -79,7 +79,6 @@ void GLWall::SetupLights()
case RENDERWALL_FOGBOUNDARY: case RENDERWALL_FOGBOUNDARY:
case RENDERWALL_MIRRORSURFACE: case RENDERWALL_MIRRORSURFACE:
case RENDERWALL_COLOR: case RENDERWALL_COLOR:
case RENDERWALL_COLORLAYER:
return; return;
} }
@ -429,13 +428,6 @@ void GLWall::Draw(int pass)
RenderFogBoundary(); RenderFogBoundary();
break; break;
case RENDERWALL_COLORLAYER:
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
RenderTranslucentWall();
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0, 0);
default: default:
RenderTranslucentWall(); RenderTranslucentWall();
break; break;

View file

@ -39,7 +39,6 @@
#include "v_palette.h" #include "v_palette.h"
#include "templates.h" #include "templates.h"
#include "gl/renderer/gl_lightdata.h"
#include "gl/textures/gl_translate.h" #include "gl/textures/gl_translate.h"
#include "gl/textures/gl_bitmap.h" #include "gl/textures/gl_bitmap.h"
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"

View file

@ -593,8 +593,6 @@ void P_Recalculate3DFloors(sector_t * sector)
lightlist[0].extra_colormap = sector->ColorMap; lightlist[0].extra_colormap = sector->ColorMap;
lightlist[0].blend = 0; lightlist[0].blend = 0;
lightlist[0].flags = 0; lightlist[0].flags = 0;
lightlist[0].fromsector = true;
resetlight = lightlist[0]; resetlight = lightlist[0];
@ -618,7 +616,6 @@ void P_Recalculate3DFloors(sector_t * sector)
newlight.extra_colormap = rover->GetColormap(); newlight.extra_colormap = rover->GetColormap();
newlight.blend = rover->GetBlend(); newlight.blend = rover->GetBlend();
newlight.flags = rover->flags; newlight.flags = rover->flags;
newlight.fromsector = false;
lightlist.Push(newlight); lightlist.Push(newlight);
} }
else else
@ -633,7 +630,6 @@ void P_Recalculate3DFloors(sector_t * sector)
lightlist[0].extra_colormap = rover->GetColormap(); lightlist[0].extra_colormap = rover->GetColormap();
lightlist[0].blend = rover->GetBlend(); lightlist[0].blend = rover->GetBlend();
lightlist[0].flags = rover->flags; lightlist[0].flags = rover->flags;
lightlist[0].fromsector = false;
} }
} }
if (!(rover->flags & (FF_DOUBLESHADOW | FF_RESET))) if (!(rover->flags & (FF_DOUBLESHADOW | FF_RESET)))
@ -660,7 +656,6 @@ void P_Recalculate3DFloors(sector_t * sector)
newlight.extra_colormap = resetlight.extra_colormap; newlight.extra_colormap = resetlight.extra_colormap;
newlight.blend = resetlight.blend; newlight.blend = resetlight.blend;
newlight.flags = rover->flags; newlight.flags = rover->flags;
newlight.fromsector = false;
lightlist.Push(newlight); lightlist.Push(newlight);
} }
} }

View file

@ -120,7 +120,6 @@ struct lightlist_t
int flags; int flags;
F3DFloor* lightsource; F3DFloor* lightsource;
F3DFloor* caster; F3DFloor* caster;
bool fromsector;
}; };