- added dynamic light rendering with textures on flats

This commit is contained in:
Christoph Oelckers 2016-05-05 10:28:21 +02:00
parent c9d4c68039
commit 0b2821d696
3 changed files with 56 additions and 33 deletions

View file

@ -582,20 +582,12 @@ void GLWall::RenderFogBoundaryCompat()
// Flats // Flats
// //
//========================================================================== //==========================================================================
enum
{
LIGHTPASS_MULT,
LIGHTPASS_ADD,
LIGHTPASS_FOG
};
void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass)
{ {
Plane p; Plane p;
Vector nearPt, up, right, t1; Vector nearPt, up, right, t1;
float scale; float scale;
unsigned int k;
seg_t *v;
FLightNode * node = sub->lighthead; FLightNode * node = sub->lighthead;
gl_RenderState.Apply(); gl_RenderState.Apply();
@ -603,33 +595,13 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass)
{ {
ADynamicLight * light = node->lightsource; ADynamicLight * light = node->lightsource;
if (light->flags2&MF2_DORMANT) if (light->flags2&MF2_DORMANT ||
(pass == GLPASS_LIGHTTEX && light->IsAdditive()) ||
(pass == GLPASS_LIGHTTEX_ADDITIVE && !light->IsAdditive()))
{ {
node = node->nextLight; node = node->nextLight;
continue; continue;
} }
switch (pass)
{
case LIGHTPASS_MULT:
if (light->IsAdditive())
{
node = node->nextLight;
continue;
}
break;
case LIGHTPASS_ADD:
if (!light->IsAdditive())
{
node = node->nextLight;
continue;
}
break;
default:
break;
}
// we must do the side check here because gl_SetupLight needs the correct plane orientation // we must do the side check here because gl_SetupLight needs the correct plane orientation
// which we don't have for Legacy-style 3D-floors // which we don't have for Legacy-style 3D-floors
@ -666,6 +638,49 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass)
} }
} }
//==========================================================================
//
//
//
//==========================================================================
void GLFlat::DrawLightsCompat(int pass)
{
gl_RenderState.Apply();
if (sub)
{
// This represents a single subsector
DrawSubsectorLights(sub, pass);
}
else
{
// Draw the subsectors belonging to this sector
for (int i = 0; i<sector->subsectorcount; i++)
{
subsector_t * sub = sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub - subsectors] & renderflags)
{
DrawSubsectorLights(sub, pass);
}
}
// Draw the subsectors assigned to it due to missing textures
if (!(renderflags&SSRF_RENDER3DPLANES))
{
gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR) ?
gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum);
while (node)
{
DrawSubsectorLights(sub, pass);
node = node->next;
}
}
}
}
//========================================================================== //==========================================================================
// //
// //

View file

@ -443,6 +443,11 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG
} }
if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break; break;
case GLPASS_LIGHTTEX:
case GLPASS_LIGHTTEX_ADDITIVE:
DrawLightsCompat(pass);
break;
} }
} }

View file

@ -296,15 +296,18 @@ public:
int dynlightindex; int dynlightindex;
// compatibility fallback stuff.
void DrawSubsectorLights(subsector_t * sub, int pass);
void DrawLightsCompat(int pass);
bool PutFlatCompat(bool fog);
void SetupSubsectorLights(int pass, subsector_t * sub, int *dli = NULL); void SetupSubsectorLights(int pass, subsector_t * sub, int *dli = NULL);
void DrawSubsector(subsector_t * sub); void DrawSubsector(subsector_t * sub);
void DrawSubsectorLights(subsector_t * sub, int pass);
void DrawSkyboxSector(int pass, bool processlights); void DrawSkyboxSector(int pass, bool processlights);
void DrawSubsectors(int pass, bool processlights, bool istrans); void DrawSubsectors(int pass, bool processlights, bool istrans);
void ProcessLights(bool istrans); void ProcessLights(bool istrans);
void PutFlat(bool fog = false); void PutFlat(bool fog = false);
bool PutFlatCompat(bool fog);
void Process(sector_t * model, int whichplane, bool notexture); void Process(sector_t * model, int whichplane, bool notexture);
void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside); void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside);
void ProcessSector(sector_t * frontsector); void ProcessSector(sector_t * frontsector);