Skip to content

Commit

Permalink
Fix using wrong location for the light update
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Sep 10, 2024
1 parent f0c018f commit d96dd8e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/rendering/hwrenderer/doom_levelmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,9 @@ void DoomLevelMesh::SectorLightChanged(struct sector_t* sector)
UpdateFlat(sector->Index(), SurfaceUpdateType::LightsOnly);
for (line_t* line : sector->Lines)
{
if (line->frontsector == sector && line->sidedef[0])
if (line->sidedef[0] && line->sidedef[0]->sector == sector)
UpdateSide(line->sidedef[0]->Index(), SurfaceUpdateType::LightsOnly);
else if (line->sidedef[1])
else if (line->sidedef[1] && line->sidedef[1]->sector == sector)
UpdateSide(line->sidedef[1]->Index(), SurfaceUpdateType::LightsOnly);
}
}
Expand Down Expand Up @@ -788,6 +788,10 @@ void DoomLevelMesh::CreateWallSurface(side_t* side, HWWallDispatcher& disp, Mesh
UniformsAllocInfo uinfo = AllocUniforms(numUniforms);
SurfaceAllocInfo sinfo = AllocSurface();

SurfaceUniforms* curUniforms = uinfo.Uniforms;
SurfaceLightUniforms* curLightUniforms = uinfo.LightUniforms;
FMaterialState* curMaterial = uinfo.Materials;

int pipelineID = 0;
int uniformsIndex = uinfo.Start;
int vertIndex = ginfo.VertexStart;
Expand Down Expand Up @@ -817,14 +821,14 @@ void DoomLevelMesh::CreateWallSurface(side_t* side, HWWallDispatcher& disp, Mesh
}
}

*(uinfo.Uniforms++) = applyState.surfaceUniforms;
*(uinfo.Materials++) = applyState.material;
*(curUniforms++) = applyState.surfaceUniforms;
*(curMaterial++) = applyState.material;

uinfo.LightUniforms->uVertexColor = applyState.surfaceUniforms.uVertexColor;
uinfo.LightUniforms->uDesaturationFactor = applyState.surfaceUniforms.uDesaturationFactor;
uinfo.LightUniforms->uLightLevel = applyState.surfaceUniforms.uLightLevel;
uinfo.LightUniforms->uLightIndex = -1;
uinfo.LightUniforms++;
curLightUniforms->uVertexColor = applyState.surfaceUniforms.uVertexColor;
curLightUniforms->uDesaturationFactor = applyState.surfaceUniforms.uDesaturationFactor;
curLightUniforms->uLightLevel = applyState.surfaceUniforms.uLightLevel;
curLightUniforms->uLightIndex = -1;
curLightUniforms++;

uniformsIndex++;
}
Expand Down

0 comments on commit d96dd8e

Please sign in to comment.