Visible surfaces are gathered in processing (gathering) render phase and lightmaps drawn before rendering

This commit is contained in:
RaveYard 2023-09-09 17:56:46 +02:00 committed by Magnus Norddahl
commit d96d1aeffc
4 changed files with 61 additions and 59 deletions

View file

@ -191,28 +191,6 @@ void HWFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
SetupLights(di, state, section->lighthead, lightdata, sector->PortalGroup);
}
state.SetLightIndex(dynlightindex);
const auto* lm = &sector->Level->levelMesh->Surfaces[0]; // temporay hack on top of a temporary hack
for (auto& subsector : section->subsectors)
{
if (auto lightmap = subsector->lightmap[ceiling ? 1 : 0][0])
{
state.PushVisibleSurface(lightmap - lm, lightmap);
}
}
if (auto subsectors = sector->Level->levelMesh->XFloorToSurface.CheckKey(sector))
{
for (auto* surface : *subsectors)
{
if (surface)
{
state.PushVisibleSurface(surface - lm, surface);
}
}
}
state.DrawIndexed(DT_Triangles, iboindex + section->vertexindex, section->vertexcount);
flatvertices += section->vertexcount;
flatprimitives++;
@ -523,6 +501,31 @@ void HWFlat::ProcessSector(HWDrawInfo *di, FRenderState& state, sector_t * front
uint8_t &srf = hacktype? sink : di->section_renderflags[di->Level->sections.SectionIndex(section)];
const auto &vp = di->Viewpoint;
//
// Lightmaps
//
const auto* lm = &sector->Level->levelMesh->Surfaces[0]; // temporay hack on top of a temporary hack
for (auto& subsector : section->subsectors)
{
if (auto lightmap = subsector->lightmap[ceiling ? 1 : 0][0])
{
state.PushVisibleSurface(lightmap - lm, lightmap);
}
}
if (auto subsectors = sector->Level->levelMesh->XFloorToSurface.CheckKey(sector))
{
for (auto* surface : *subsectors)
{
if (surface)
{
state.PushVisibleSurface(surface - lm, surface);
}
}
}
//
//
//