mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- changed dynamic light setup so that it is completely in the processing pass, not the render pass.
# Conflicts: # src/gl/scene/gl_flats.cpp # src/hwrenderer/scene/hw_flats.cpp
This commit is contained in:
parent
4ac43dac36
commit
a9c8546ba3
10 changed files with 60 additions and 153 deletions
|
@ -84,7 +84,6 @@ FLightBuffer::~FLightBuffer()
|
|||
void FLightBuffer::Clear()
|
||||
{
|
||||
mIndex = 0;
|
||||
mIndices.Clear();
|
||||
mUploadIndex = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
class FLightBuffer
|
||||
{
|
||||
TArray<int> mIndices;
|
||||
unsigned int mBufferId;
|
||||
float * mBufferPointer;
|
||||
|
||||
|
@ -30,9 +29,6 @@ public:
|
|||
int BindUBO(unsigned int index);
|
||||
unsigned int GetBlockSize() const { return mBlockSize; }
|
||||
unsigned int GetBufferType() const { return mBufferType; }
|
||||
unsigned int GetIndexPtr() const { return mIndices.Size(); }
|
||||
void StoreIndex(int index) { mIndices.Push(index); }
|
||||
int GetIndex(int i) const { return mIndices[i]; }
|
||||
};
|
||||
|
||||
int gl_SetDynModelLight(AActor *self, int dynlightindex);
|
||||
|
|
|
@ -28,7 +28,6 @@ enum DrawListType
|
|||
enum Drawpasses
|
||||
{
|
||||
GLPASS_ALL, // Main pass with dynamic lights
|
||||
GLPASS_LIGHTSONLY, // only collect dynamic lights
|
||||
GLPASS_DECALS, // Draws a decal
|
||||
GLPASS_TRANSLUCENT, // Draws translucent objects
|
||||
};
|
||||
|
@ -76,10 +75,7 @@ struct FDrawInfo : public HWDrawInfo
|
|||
void DrawFlat(GLFlat *flat, int pass, bool trans) override; // trans only has meaning for GLPASS_LIGHTSONLY
|
||||
void DrawSkyboxSector(GLFlat *flat, int pass, bool processlights);
|
||||
void DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool istrans);
|
||||
void ProcessLights(GLFlat *flat, bool istrans);
|
||||
void DrawSubsector(GLFlat *flat, subsector_t * sub);
|
||||
void SetupSubsectorLights(GLFlat *flat, int pass, subsector_t * sub, int *dli);
|
||||
void SetupSectorLights(GLFlat *flat, int pass, int *dli);
|
||||
|
||||
// Sprite drawer
|
||||
void DrawSprite(GLSprite *sprite, int pass);
|
||||
|
|
|
@ -47,64 +47,6 @@
|
|||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Flats
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDrawInfo::SetupSubsectorLights(GLFlat *flat, int pass, subsector_t * sub, int *dli)
|
||||
{
|
||||
if (dli != NULL && *dli != -1)
|
||||
{
|
||||
if (flat->renderstyle == STYLE_Add && !level.lightadditivesurfaces) return; // no lights on additively blended surfaces.
|
||||
gl_RenderState.ApplyLightIndex(GLRenderer->mLights->GetIndex(*dli));
|
||||
(*dli)++;
|
||||
return;
|
||||
}
|
||||
if (flat->SetupSubsectorLights(pass, sub, lightdata))
|
||||
{
|
||||
int d = GLRenderer->mLights->UploadLights(lightdata);
|
||||
if (pass == GLPASS_LIGHTSONLY)
|
||||
{
|
||||
GLRenderer->mLights->StoreIndex(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_RenderState.ApplyLightIndex(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDrawInfo::SetupSectorLights(GLFlat *flat, int pass, int *dli)
|
||||
{
|
||||
if (dli != NULL && *dli != -1)
|
||||
{
|
||||
if (flat->renderstyle == STYLE_Add && !level.lightadditivesurfaces) return; // no lights on additively blended surfaces.
|
||||
gl_RenderState.ApplyLightIndex(GLRenderer->mLights->GetIndex(*dli));
|
||||
(*dli)++;
|
||||
return;
|
||||
}
|
||||
if (flat->SetupSectorLights(pass, flat->sector, lightdata))
|
||||
{
|
||||
int d = GLRenderer->mLights->UploadLights(lightdata);
|
||||
if (pass == GLPASS_LIGHTSONLY)
|
||||
{
|
||||
GLRenderer->mLights->StoreIndex(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_RenderState.ApplyLightIndex(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -156,49 +98,6 @@ void FDrawInfo::DrawSubsector(GLFlat *flat, subsector_t * sub)
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// this is only used by LM_DEFERRED
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDrawInfo::ProcessLights(GLFlat *flat, bool istrans)
|
||||
{
|
||||
flat->dynlightindex = GLRenderer->mLights->GetIndexPtr();
|
||||
|
||||
if (flat->sector->ibocount > 0 && !ClipLineShouldBeActive())
|
||||
{
|
||||
SetupSectorLights(flat, GLPASS_LIGHTSONLY, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw the subsectors belonging to this sector
|
||||
for (int i = 0; i < flat->sector->subsectorcount; i++)
|
||||
{
|
||||
subsector_t * sub = flat->sector->subsectors[i];
|
||||
if (ss_renderflags[sub->Index()] & flat->renderflags || istrans)
|
||||
{
|
||||
SetupSubsectorLights(flat, GLPASS_LIGHTSONLY, sub, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the subsectors assigned to it due to missing textures
|
||||
if (!(flat->renderflags&SSRF_RENDER3DPLANES))
|
||||
{
|
||||
gl_subsectorrendernode * node = (flat->renderflags&SSRF_RENDERFLOOR)?
|
||||
GetOtherFloorPlanes(flat->sector->sectornum) :
|
||||
GetOtherCeilingPlanes(flat->sector->sectornum);
|
||||
|
||||
while (node)
|
||||
{
|
||||
SetupSubsectorLights(flat, GLPASS_LIGHTSONLY, node->sub, nullptr);
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -213,11 +112,12 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
|
|||
gl_RenderState.Apply();
|
||||
auto iboindex = flat->iboindex;
|
||||
|
||||
if (processlights) gl_RenderState.ApplyLightIndex(flat->dynlightindex);
|
||||
|
||||
if (iboindex >= 0)
|
||||
{
|
||||
if (vcount > 0 && !ClipLineShouldBeActive())
|
||||
{
|
||||
if (processlights) SetupSectorLights(flat, GLPASS_ALL, &dli);
|
||||
drawcalls.Clock();
|
||||
glDrawElements(GL_TRIANGLES, vcount, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + iboindex);
|
||||
drawcalls.Unclock();
|
||||
|
@ -234,7 +134,6 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
|
|||
|
||||
if (ss_renderflags[sub->Index()] & flat->renderflags || istrans)
|
||||
{
|
||||
if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli);
|
||||
drawcalls.Clock();
|
||||
glDrawElements(GL_TRIANGLES, (sub->numlines - 2) * 3, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + index);
|
||||
drawcalls.Unclock();
|
||||
|
@ -253,7 +152,6 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
|
|||
subsector_t * sub = flat->sector->subsectors[i];
|
||||
if (ss_renderflags[sub->Index()]& flat->renderflags || istrans)
|
||||
{
|
||||
if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli);
|
||||
DrawSubsector(flat, sub);
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +166,7 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
|
|||
|
||||
while (node)
|
||||
{
|
||||
if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, node->sub, &dli);
|
||||
if (processlights) gl_RenderState.ApplyLightIndex(node->lightindex);
|
||||
DrawSubsector(flat, node->sub);
|
||||
node = node->next;
|
||||
}
|
||||
|
@ -328,13 +226,6 @@ void FDrawInfo::DrawFlat(GLFlat *flat, int pass, bool trans) // trans only has m
|
|||
gl_RenderState.SetObjectColor(0xffffffff);
|
||||
break;
|
||||
|
||||
case GLPASS_LIGHTSONLY:
|
||||
if ((!trans || flat->gltexture) && processLights)
|
||||
{
|
||||
ProcessLights(flat, trans);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLPASS_TRANSLUCENT:
|
||||
if (flat->renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
SetColor(flat->lightlevel, rel, flat->Colormap, flat->alpha);
|
||||
|
|
|
@ -163,18 +163,6 @@ void FDrawInfo::RenderScene(int recursion)
|
|||
drawlists[GLDL_MASKEDWALLSOFS].SortWalls();
|
||||
}
|
||||
|
||||
// if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front,
|
||||
// so that we don't have to do repeated map/unmap calls on the buffer.
|
||||
if (gl.lightmethod == LM_DEFERRED && level.HasDynamicLights && !isFullbrightScene())
|
||||
{
|
||||
GLRenderer->mLights->Begin();
|
||||
drawlists[GLDL_PLAINFLATS].DrawFlats(this, GLPASS_LIGHTSONLY);
|
||||
drawlists[GLDL_MASKEDFLATS].DrawFlats(this, GLPASS_LIGHTSONLY);
|
||||
drawlists[GLDL_TRANSLUCENTBORDER].Draw(this, GLPASS_LIGHTSONLY);
|
||||
drawlists[GLDL_TRANSLUCENT].Draw(this, GLPASS_LIGHTSONLY, true);
|
||||
GLRenderer->mLights->Finish();
|
||||
}
|
||||
|
||||
// Part 1: solid geometry. This is set up so that there are no transparent parts
|
||||
glDepthFunc(GL_LESS);
|
||||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||
|
|
|
@ -71,7 +71,7 @@ void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend
|
|||
|
||||
void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
||||
{
|
||||
if (pass == GLPASS_DECALS || pass == GLPASS_LIGHTSONLY) return;
|
||||
if (pass == GLPASS_DECALS) return;
|
||||
|
||||
auto RenderStyle = sprite->RenderStyle;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ struct gl_subsectorrendernode
|
|||
{
|
||||
gl_subsectorrendernode * next;
|
||||
subsector_t * sub;
|
||||
int lightindex;
|
||||
};
|
||||
|
||||
enum area_t : int;
|
||||
|
@ -160,6 +161,7 @@ private:
|
|||
void AddSpecialPortalLines(subsector_t * sub, sector_t * sector, line_t *line);
|
||||
void RenderThings(subsector_t * sub, sector_t * sector);
|
||||
void DoSubsector(subsector_t * sub);
|
||||
int SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &lightdata, const secplane_t *plane);
|
||||
public:
|
||||
|
||||
void SetCameraPos(const DVector3 &pos)
|
||||
|
|
|
@ -315,9 +315,7 @@ public:
|
|||
int dynlightindex;
|
||||
|
||||
void CreateSkyboxVertices(FFlatVertex *buffer);
|
||||
bool SetupLights(int pass, FLightNode *head, FDynLightData &lightdata, int portalgroup);
|
||||
bool SetupSubsectorLights(int pass, subsector_t * sub, FDynLightData &lightdata);
|
||||
bool SetupSectorLights(int pass, sector_t * sec, FDynLightData &lightdata);
|
||||
void SetupLights(HWDrawInfo *di, FLightNode *head, FDynLightData &lightdata, int portalgroup);
|
||||
|
||||
void PutFlat(HWDrawInfo *di, bool fog = false);
|
||||
void Process(HWDrawInfo *di, sector_t * model, int whichplane, bool notexture);
|
||||
|
|
|
@ -135,13 +135,15 @@ void GLFlat::CreateSkyboxVertices(FFlatVertex *vert)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool GLFlat::SetupLights(int pass, FLightNode * node, FDynLightData &lightdata, int portalgroup)
|
||||
void GLFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &lightdata, int portalgroup)
|
||||
{
|
||||
Plane p;
|
||||
|
||||
lightdata.Clear();
|
||||
if (renderstyle == STYLE_Add && !level.lightadditivesurfaces) return false; // no lights on additively blended surfaces.
|
||||
|
||||
if (renderstyle == STYLE_Add && !level.lightadditivesurfaces)
|
||||
{
|
||||
dynlightindex = -1;
|
||||
return; // no lights on additively blended surfaces.
|
||||
}
|
||||
while (node)
|
||||
{
|
||||
ADynamicLight * light = node->lightsource;
|
||||
|
@ -167,17 +169,7 @@ bool GLFlat::SetupLights(int pass, FLightNode * node, FDynLightData &lightdata,
|
|||
node = node->nextLight;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, FDynLightData &lightdata)
|
||||
{
|
||||
return SetupLights(pass, sub->lighthead, lightdata, sub->sector->PortalGroup);
|
||||
}
|
||||
|
||||
bool GLFlat::SetupSectorLights(int pass, sector_t * sec, FDynLightData &lightdata)
|
||||
{
|
||||
return SetupLights(pass, sec->lighthead, lightdata, sec->PortalGroup);
|
||||
dynlightindex = di->UploadLights(lightdata);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -190,11 +182,15 @@ bool GLFlat::SetupSectorLights(int pass, sector_t * sec, FDynLightData &lightdat
|
|||
|
||||
inline void GLFlat::PutFlat(HWDrawInfo *di, bool fog)
|
||||
{
|
||||
|
||||
if (di->isFullbrightScene())
|
||||
{
|
||||
Colormap.Clear();
|
||||
}
|
||||
dynlightindex = -1; // make sure this is always initialized to something proper.
|
||||
else if (level.HasDynamicLights && gltexture != nullptr)
|
||||
{
|
||||
SetupLights(di, sector->lighthead, lightdata, sector->PortalGroup);
|
||||
}
|
||||
di->AddFlat(this, fog);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,13 +29,52 @@
|
|||
#include "r_utility.h"
|
||||
#include "r_sky.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "a_dynlight.h"
|
||||
|
||||
#include "hw_drawinfo.h"
|
||||
#include "hw_drawstructs.h"
|
||||
#include "hwrenderer/utility/hw_clock.h"
|
||||
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
||||
|
||||
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// light setup for render hacks.
|
||||
// This can ignore many of the special checks because
|
||||
// this will never be translucent and never be part of a portal or a 3D floor
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int HWDrawInfo::SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &lightdata, const secplane_t *plane)
|
||||
{
|
||||
if (level.HasDynamicLights && !isFullbrightScene())
|
||||
{
|
||||
Plane p;
|
||||
FLightNode * node = sub->lighthead;
|
||||
|
||||
lightdata.Clear();
|
||||
while (node)
|
||||
{
|
||||
ADynamicLight * light = node->lightsource;
|
||||
|
||||
if (light->flags2&MF2_DORMANT)
|
||||
{
|
||||
node = node->nextLight;
|
||||
continue;
|
||||
}
|
||||
iter_dlightf++;
|
||||
|
||||
p.Set(plane->Normal(), plane->fD());
|
||||
lightdata.GetLight(sub->sector->PortalGroup, p, light, true);
|
||||
node = node->nextLight;
|
||||
}
|
||||
|
||||
return UploadLights(lightdata);
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Adds a subsector plane to a sector's render list
|
||||
|
@ -52,6 +91,7 @@ void HWDrawInfo::AddOtherFloorPlane(int sector, gl_subsectorrendernode * node)
|
|||
for(int i=oldcnt;i<=sector;i++) otherfloorplanes[i]=NULL;
|
||||
}
|
||||
node->next = otherfloorplanes[sector];
|
||||
node->lightindex = SetupLightsForOtherPlane(node->sub, lightdata, &node->sub->sector->floorplane);
|
||||
otherfloorplanes[sector] = node;
|
||||
}
|
||||
|
||||
|
@ -65,6 +105,7 @@ void HWDrawInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node)
|
|||
for(int i=oldcnt;i<=sector;i++) otherceilingplanes[i]=NULL;
|
||||
}
|
||||
node->next = otherceilingplanes[sector];
|
||||
node->lightindex = SetupLightsForOtherPlane(node->sub, lightdata, &node->sub->sector->ceilingplane);
|
||||
otherceilingplanes[sector] = node;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue