Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-03-20 15:29:26 +1100
committerKae <80987908+Novaenia@users.noreply.github.com>2024-03-20 15:29:26 +1100
commitbf73fbc1ad3ed8b13683481c29cc2ec39e2d3117 (patch)
treed04dc378333be32566b94fb5f04eb98877a50ad5
parent6d76a11e256cd96c9cdd7ae5a10c0276e6347277 (diff)
cursed point lights everywhere (but god it looks good)
-rw-r--r--source/core/StarJsonExtra.cpp19
-rw-r--r--source/game/StarWorldClient.cpp6
-rw-r--r--source/rendering/StarTilePainter.cpp7
3 files changed, 16 insertions, 16 deletions
diff --git a/source/core/StarJsonExtra.cpp b/source/core/StarJsonExtra.cpp
index 81bc858..2517b7b 100644
--- a/source/core/StarJsonExtra.cpp
+++ b/source/core/StarJsonExtra.cpp
@@ -214,12 +214,12 @@ Color jsonToColor(Json const& v) {
if (v.type() != Json::Type::Array || (v.size() != 3 && v.size() != 4))
throw JsonException("Json not an array of size 3 or 4 in jsonToColor");
Color c = Color::rgba(0, 0, 0, 255);
- c.setRedF((float)v.getInt(0) / 255.f);
- c.setGreenF((float)v.getInt(1) / 255.f);
- c.setBlueF((float)v.getInt(2) / 255.f);
+ c.setRed(v.getInt(0));
+ c.setGreen(v.getInt(1));
+ c.setBlue(v.getInt(2));
if (v.size() == 4)
- c.setAlphaF((float)v.getInt(3) / 255.f);
+ c.setAlpha(v.getInt(3));
return c;
} else if (v.type() == Json::Type::String) {
@@ -231,12 +231,11 @@ Color jsonToColor(Json const& v) {
Json jsonFromColor(Color const& color) {
JsonArray result;
- result.push_back(color.redF() * 255.f);
- result.push_back(color.greenF() * 255.f);
- result.push_back(color.blueF() * 255.f);
- if (color.alphaF() < 255.f) {
- result.push_back(color.alphaF() * 255.f);
- }
+ result.push_back(color.red());
+ result.push_back(color.green());
+ result.push_back(color.blue());
+ if (color.alpha() < 255)
+ result.push_back(color.alpha());
return result;
}
diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp
index bcbbdb3..0e63c06 100644
--- a/source/game/StarWorldClient.cpp
+++ b/source/game/StarWorldClient.cpp
@@ -1654,13 +1654,15 @@ void WorldClient::lightingCalc() {
if (light.pointLight)
m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience);
else {
- m_lightingCalculator.addSpreadLight(position, light.color);
+ m_lightingCalculator.addSpreadLight(position, light.color * 0.6f);
+ m_lightingCalculator.addPointLight(position, light.color * 0.4f, 0.0f, 0.0f, 1.0f);
}
}
for (auto const& lightPair : particleLights) {
Vec2F position = m_geometry.nearestTo(Vec2F(m_lightingCalculator.calculationRegion().min()), lightPair.first);
- m_lightingCalculator.addSpreadLight(position, lightPair.second);
+ m_lightingCalculator.addSpreadLight(position, lightPair.second * 0.6f);
+ m_lightingCalculator.addPointLight(position, lightPair.second * 0.4f, 0.0f, 0.0f, 1.0f);
}
m_lightingCalculator.calculate(m_pendingLightMap);
diff --git a/source/rendering/StarTilePainter.cpp b/source/rendering/StarTilePainter.cpp
index 91b1367..58d9d28 100644
--- a/source/rendering/StarTilePainter.cpp
+++ b/source/rendering/StarTilePainter.cpp
@@ -38,7 +38,7 @@ 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;
@@ -47,9 +47,8 @@ void TilePainter::adjustLighting(WorldRenderData& renderData) const {
auto lightValue = renderData.lightMap.get(lightIndex.x(), lightIndex.y());
auto const& liquid = m_liquids[tile.liquidId];
- Vec3F tileLight = Vec3F(lightValue);
- float darknessLevel = (1.f - tileLight.sum() / 3.0f) * drawLevel;
- lightValue = tileLight.piecewiseMultiply(Vec3F::filled(1.f - 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.x(), lightIndex.y(), lightValue);
});