fix minor culling issues

also multiply liquid light by liquid level to fix pop-in problems
This commit is contained in:
Kae 2023-06-20 23:04:36 +10:00
parent a330802d37
commit 9b75bd8eb2
2 changed files with 7 additions and 4 deletions

View File

@ -412,8 +412,10 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
return a->entityId() < b->entityId();
});
RectI lightRange = m_clientState.window();
RectI tileRange = lightRange.padded(bufferTiles);
RectI window = m_clientState.window();
RectI tileRange = window.padded(bufferTiles);
RectI lightRange = window.padded(1);
//Kae: Padded by one to fix light spread issues at the edges of the frame.
renderData.tileMinPosition = tileRange.min();
renderData.lightMinPosition = lightRange.min();
@ -461,7 +463,7 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
auto& tile = column[y];
Vec3F light = materialDatabase->radiantLight(tile.foreground, tile.foregroundMod);
light += liquidsDatabase->radiantLight(tile.liquid);
light += liquidsDatabase->radiantLight(tile.liquid) * tile.liquid.level;
if (tile.foregroundLightTransparent) {
light += materialDatabase->radiantLight(tile.background, tile.backgroundMod);
if (tile.backgroundLightTransparent && pos[1] + y > undergroundLevel)

View File

@ -62,7 +62,8 @@ void TilePainter::setup(WorldCamera const& camera, WorldRenderData& renderData)
m_cameraPan = renderData.geometry.diff(cameraCenter, *m_lastCameraCenter);
m_lastCameraCenter = cameraCenter;
RectI chunkRange = RectI::integral(RectF(camera.worldTileRect()).scaled(1.0f / RenderChunkSize));
//Kae: Padded by one to fix culling issues with certain tile pieces at chunk borders, such as grass.
RectI chunkRange = RectI::integral(RectF(camera.worldTileRect().padded(1)).scaled(1.0f / RenderChunkSize));
for (int x = chunkRange.xMin(); x < chunkRange.xMax(); ++x) {
for (int y = chunkRange.yMin(); y < chunkRange.yMax(); ++y) {