- fixed cherry-picked commit so that modern OpenGL can still do the light setup in the render pass.

This commit is contained in:
Christoph Oelckers 2018-10-20 10:33:26 +02:00
parent a9c8546ba3
commit acb9505606
3 changed files with 17 additions and 6 deletions

View File

@ -112,7 +112,14 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
gl_RenderState.Apply(); gl_RenderState.Apply();
auto iboindex = flat->iboindex; auto iboindex = flat->iboindex;
if (processlights) gl_RenderState.ApplyLightIndex(flat->dynlightindex); if (processlights)
{
if (screen->hwcaps & RFL_BUFFER_STORAGE)
{
flat->SetupLights(this, flat->sector->lighthead, lightdata, flat->sector->PortalGroup);
}
gl_RenderState.ApplyLightIndex(flat->dynlightindex);
}
if (iboindex >= 0) if (iboindex >= 0)
{ {
@ -215,13 +222,13 @@ void FDrawInfo::DrawFlat(GLFlat *flat, int pass, bool trans) // trans only has m
{ {
gl_RenderState.SetMaterial(flat->gltexture, CLAMP_NONE, 0, -1, false); gl_RenderState.SetMaterial(flat->gltexture, CLAMP_NONE, 0, -1, false);
gl_RenderState.SetPlaneTextureRotation(&plane, flat->gltexture); gl_RenderState.SetPlaneTextureRotation(&plane, flat->gltexture);
DrawSubsectors(flat, pass, processLights && (gl.lightmethod == LM_DIRECT || flat->dynlightindex > -1), false); DrawSubsectors(flat, pass, processLights, false);
gl_RenderState.EnableTextureMatrix(false); gl_RenderState.EnableTextureMatrix(false);
} }
else else
{ {
gl_RenderState.SetMaterial(flat->gltexture, CLAMP_XY, 0, -1, false); gl_RenderState.SetMaterial(flat->gltexture, CLAMP_XY, 0, -1, false);
DrawSkyboxSector(flat, pass, processLights && (gl.lightmethod == LM_DIRECT || flat->dynlightindex > -1)); DrawSkyboxSector(flat, pass, processLights);
} }
gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.SetObjectColor(0xffffffff);
break; break;

View File

@ -139,6 +139,7 @@ void GLFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light
{ {
Plane p; Plane p;
lightdata.Clear();
if (renderstyle == STYLE_Add && !level.lightadditivesurfaces) if (renderstyle == STYLE_Add && !level.lightadditivesurfaces)
{ {
dynlightindex = -1; dynlightindex = -1;
@ -182,15 +183,17 @@ void GLFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light
inline void GLFlat::PutFlat(HWDrawInfo *di, bool fog) inline void GLFlat::PutFlat(HWDrawInfo *di, bool fog)
{ {
if (di->isFullbrightScene()) if (di->isFullbrightScene())
{ {
Colormap.Clear(); Colormap.Clear();
} }
else if (level.HasDynamicLights && gltexture != nullptr) else if (!(screen->hwcaps & RFL_BUFFER_STORAGE))
{
if (level.HasDynamicLights && gltexture != nullptr)
{ {
SetupLights(di, sector->lighthead, lightdata, sector->PortalGroup); SetupLights(di, sector->lighthead, lightdata, sector->PortalGroup);
} }
}
di->AddFlat(this, fog); di->AddFlat(this, fog);
} }

View File

@ -57,6 +57,7 @@ enum EHWCaps
RFL_SHADER_STORAGE_BUFFER = 4, RFL_SHADER_STORAGE_BUFFER = 4,
RFL_BUFFER_STORAGE = 8, RFL_BUFFER_STORAGE = 8,
RFL_NO_LIGHT_PREGENERATE = 16, // delays dynamic light creation until the render pass. With modern OpenGL this is faster because it can make use of the CPU while the GPU is rendering.
RFL_NO_CLIP_PLANES = 32, RFL_NO_CLIP_PLANES = 32,