From d037493ffe735566a30b7b22b5e0976307ae2852 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Jan 2016 17:13:14 +0100 Subject: [PATCH] - 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. --- src/gl/renderer/gl_colormap.h | 3 +++ src/gl/renderer/gl_lightdata.h | 12 ++++++++++++ src/gl/scene/gl_flats.cpp | 9 +++++---- src/gl/scene/gl_sprite.cpp | 6 +++--- src/gl/scene/gl_wall.h | 1 - src/gl/scene/gl_walls.cpp | 28 ++-------------------------- src/gl/scene/gl_walls_draw.cpp | 8 -------- src/gl/textures/gl_bitmap.cpp | 1 - src/p_3dfloors.cpp | 5 ----- src/p_3dfloors.h | 1 - 10 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index 8126cb5d4..2122b1248 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -7,6 +7,7 @@ extern DWORD gl_fixedcolormap; +struct lightlist_t; enum EColorManipulation { @@ -64,6 +65,8 @@ struct FColormap 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. { int v = (LightColor.r + LightColor.g + LightColor.b) / 3; diff --git a/src/gl/renderer/gl_lightdata.h b/src/gl/renderer/gl_lightdata.h index f76f732af..4cc7a7d04 100644 --- a/src/gl/renderer/gl_lightdata.h +++ b/src/gl/renderer/gl_lightdata.h @@ -2,6 +2,7 @@ #define __GL_LIGHTDATA #include "v_palette.h" +#include "p_3dfloors.h" #include "r_data/renderstyle.h" #include "gl/renderer/gl_colormap.h" @@ -49,4 +50,15 @@ extern int outsidefogdensity; 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 \ No newline at end of file diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 16b892b15..c747236d2 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -466,7 +466,8 @@ void GLFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside) lightlevel = *light->p_lightlevel; 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; renderstyle = rover->flags&FF_ADDITIVETRANS? STYLE_Add : STYLE_Translucent; @@ -546,13 +547,13 @@ void GLFlat::ProcessSector(sector_t * frontsector) if (x.ffloors.Size()) { 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)) { lightlevel = *light->p_lightlevel; } - Colormap.CopyLightColor(light->extra_colormap); + Colormap.CopyFrom3DLight(light); } renderstyle = STYLE_Translucent; if (alpha!=0.0f) Process(frontsector, false, false); @@ -604,7 +605,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) { lightlevel = *light->p_lightlevel; } - Colormap.CopyLightColor(light->extra_colormap); + Colormap.CopyFrom3DLight(light); } renderstyle = STYLE_Translucent; if (alpha!=0.0f) Process(frontsector, true, false); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 75e698762..2abfd47f7 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -349,8 +349,8 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) { copySprite=*this; copySprite.lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel); - copySprite.Colormap.CopyLightColor(lightlist[i].extra_colormap); - + copySprite.Colormap.CopyFrom3DLight(&lightlist[i]); + if (glset.nocoloredspritelighting) { int v = (copySprite.Colormap.LightColor.r + copySprite.Colormap.LightColor.g + copySprite.Colormap.LightColor.b )/3; @@ -389,7 +389,7 @@ void GLSprite::SetSpriteColor(sector_t *sector, fixed_t center_y) if (maplightbottomGetTransparent() && passflag[type] == 2) @@ -162,10 +161,6 @@ void GLWall::PutWall(bool translucent) } else switch (type) { - case RENDERWALL_COLORLAYER: - gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this); - break; - // portals don't go into the draw list. // Instead they are added to the portal manager case RENDERWALL_HORIZON: @@ -230,9 +225,6 @@ void GLWall::PutWall(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 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. - Colormap.CopyLightColor(lightlist->extra_colormap); - if (fadewall) lightlevel=255; + Colormap.CopyFrom3DLight(lightlist); 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; FColormap lc=Colormap; - if (i > 0) Put3DWall(&lightlist[i], translucent); - else PutWall(translucent); // uppermost section does not alter light at all. + Put3DWall(&lightlist[i], translucent); lightlevel=ll; Colormap=lc; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5cf321ec8..ce14e16d3 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -79,7 +79,6 @@ void GLWall::SetupLights() case RENDERWALL_FOGBOUNDARY: case RENDERWALL_MIRRORSURFACE: case RENDERWALL_COLOR: - case RENDERWALL_COLORLAYER: return; } @@ -429,13 +428,6 @@ void GLWall::Draw(int pass) RenderFogBoundary(); break; - case RENDERWALL_COLORLAYER: - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(-1.0f, -128.0f); - RenderTranslucentWall(); - glDisable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0, 0); - default: RenderTranslucentWall(); break; diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index 991ebc650..ee28e8911 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -39,7 +39,6 @@ #include "v_palette.h" #include "templates.h" -#include "gl/renderer/gl_lightdata.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_bitmap.h" #include "gl/system/gl_interface.h" diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index f915c3e0f..c4a057e63 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -593,8 +593,6 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = sector->ColorMap; lightlist[0].blend = 0; lightlist[0].flags = 0; - lightlist[0].fromsector = true; - resetlight = lightlist[0]; @@ -618,7 +616,6 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.extra_colormap = rover->GetColormap(); newlight.blend = rover->GetBlend(); newlight.flags = rover->flags; - newlight.fromsector = false; lightlist.Push(newlight); } else @@ -633,7 +630,6 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = rover->GetColormap(); lightlist[0].blend = rover->GetBlend(); lightlist[0].flags = rover->flags; - lightlist[0].fromsector = false; } } if (!(rover->flags & (FF_DOUBLESHADOW | FF_RESET))) @@ -660,7 +656,6 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.extra_colormap = resetlight.extra_colormap; newlight.blend = resetlight.blend; newlight.flags = rover->flags; - newlight.fromsector = false; lightlist.Push(newlight); } } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 93fd13d1b..5ddded3d3 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -120,7 +120,6 @@ struct lightlist_t int flags; F3DFloor* lightsource; F3DFloor* caster; - bool fromsector; };