diff options
Diffstat (limited to 'source/rendering/StarTilePainter.cpp')
-rw-r--r-- | source/rendering/StarTilePainter.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/source/rendering/StarTilePainter.cpp b/source/rendering/StarTilePainter.cpp index 31fe0a6..58d9d28 100644 --- a/source/rendering/StarTilePainter.cpp +++ b/source/rendering/StarTilePainter.cpp @@ -38,20 +38,19 @@ TilePainter::TilePainter(RendererPtr renderer) : TileDrawer() { void TilePainter::adjustLighting(WorldRenderData& renderData) const { RectI lightRange = RectI::withSize(renderData.lightMinPosition, Vec2I(renderData.lightMap.size())); forEachRenderTile(renderData, lightRange, [&](Vec2I const& pos, RenderTile const& tile) { - // Only adjust lighting for full tiles + // Only adjust lighting for tiles with liquid above the draw threshold float drawLevel = liquidDrawLevel(byteToFloat(tile.liquidLevel)); if (drawLevel == 0.0f) return; auto lightIndex = Vec2U(pos - renderData.lightMinPosition); - auto lightValue = renderData.lightMap.get(lightIndex).vec3(); + auto lightValue = renderData.lightMap.get(lightIndex.x(), lightIndex.y()); auto const& liquid = m_liquids[tile.liquidId]; - Vec3F tileLight = Vec3F(lightValue); - float darknessLevel = (1 - tileLight.sum() / (3.0f * 255.0f)) * drawLevel; - lightValue = Vec3B(tileLight.piecewiseMultiply(Vec3F::filled(1 - darknessLevel) + liquid.bottomLightMix * darknessLevel)); + float darknessLevel = (1.f - (lightValue.sum() / 3.0f)) * drawLevel; + lightValue = lightValue.piecewiseMultiply(Vec3F::filled(1.f - darknessLevel) + liquid.bottomLightMix * darknessLevel); - renderData.lightMap.set(lightIndex, lightValue); + renderData.lightMap.set(lightIndex.x(), lightIndex.y(), lightValue); }); } |