cursed point lights everywhere (but god it looks good)

This commit is contained in:
Kae 2024-03-20 15:29:26 +11:00
parent 6d76a11e25
commit bf73fbc1ad
3 changed files with 16 additions and 16 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
});