cursed point lights everywhere (but god it looks good)
This commit is contained in:
parent
6d76a11e25
commit
bf73fbc1ad
@ -214,12 +214,12 @@ Color jsonToColor(Json const& v) {
|
|||||||
if (v.type() != Json::Type::Array || (v.size() != 3 && v.size() != 4))
|
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");
|
throw JsonException("Json not an array of size 3 or 4 in jsonToColor");
|
||||||
Color c = Color::rgba(0, 0, 0, 255);
|
Color c = Color::rgba(0, 0, 0, 255);
|
||||||
c.setRedF((float)v.getInt(0) / 255.f);
|
c.setRed(v.getInt(0));
|
||||||
c.setGreenF((float)v.getInt(1) / 255.f);
|
c.setGreen(v.getInt(1));
|
||||||
c.setBlueF((float)v.getInt(2) / 255.f);
|
c.setBlue(v.getInt(2));
|
||||||
|
|
||||||
if (v.size() == 4)
|
if (v.size() == 4)
|
||||||
c.setAlphaF((float)v.getInt(3) / 255.f);
|
c.setAlpha(v.getInt(3));
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
} else if (v.type() == Json::Type::String) {
|
} else if (v.type() == Json::Type::String) {
|
||||||
@ -231,12 +231,11 @@ Color jsonToColor(Json const& v) {
|
|||||||
|
|
||||||
Json jsonFromColor(Color const& color) {
|
Json jsonFromColor(Color const& color) {
|
||||||
JsonArray result;
|
JsonArray result;
|
||||||
result.push_back(color.redF() * 255.f);
|
result.push_back(color.red());
|
||||||
result.push_back(color.greenF() * 255.f);
|
result.push_back(color.green());
|
||||||
result.push_back(color.blueF() * 255.f);
|
result.push_back(color.blue());
|
||||||
if (color.alphaF() < 255.f) {
|
if (color.alpha() < 255)
|
||||||
result.push_back(color.alphaF() * 255.f);
|
result.push_back(color.alpha());
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1654,13 +1654,15 @@ void WorldClient::lightingCalc() {
|
|||||||
if (light.pointLight)
|
if (light.pointLight)
|
||||||
m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience);
|
m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience);
|
||||||
else {
|
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) {
|
for (auto const& lightPair : particleLights) {
|
||||||
Vec2F position = m_geometry.nearestTo(Vec2F(m_lightingCalculator.calculationRegion().min()), lightPair.first);
|
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);
|
m_lightingCalculator.calculate(m_pendingLightMap);
|
||||||
|
@ -38,7 +38,7 @@ TilePainter::TilePainter(RendererPtr renderer) : TileDrawer() {
|
|||||||
void TilePainter::adjustLighting(WorldRenderData& renderData) const {
|
void TilePainter::adjustLighting(WorldRenderData& renderData) const {
|
||||||
RectI lightRange = RectI::withSize(renderData.lightMinPosition, Vec2I(renderData.lightMap.size()));
|
RectI lightRange = RectI::withSize(renderData.lightMinPosition, Vec2I(renderData.lightMap.size()));
|
||||||
forEachRenderTile(renderData, lightRange, [&](Vec2I const& pos, RenderTile const& tile) {
|
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));
|
float drawLevel = liquidDrawLevel(byteToFloat(tile.liquidLevel));
|
||||||
if (drawLevel == 0.0f)
|
if (drawLevel == 0.0f)
|
||||||
return;
|
return;
|
||||||
@ -47,9 +47,8 @@ void TilePainter::adjustLighting(WorldRenderData& renderData) const {
|
|||||||
auto lightValue = renderData.lightMap.get(lightIndex.x(), lightIndex.y());
|
auto lightValue = renderData.lightMap.get(lightIndex.x(), lightIndex.y());
|
||||||
|
|
||||||
auto const& liquid = m_liquids[tile.liquidId];
|
auto const& liquid = m_liquids[tile.liquidId];
|
||||||
Vec3F tileLight = Vec3F(lightValue);
|
float darknessLevel = (1.f - (lightValue.sum() / 3.0f)) * drawLevel;
|
||||||
float darknessLevel = (1.f - tileLight.sum() / 3.0f) * drawLevel;
|
lightValue = lightValue.piecewiseMultiply(Vec3F::filled(1.f - darknessLevel) + liquid.bottomLightMix * darknessLevel);
|
||||||
lightValue = tileLight.piecewiseMultiply(Vec3F::filled(1.f - darknessLevel) + liquid.bottomLightMix * darknessLevel);
|
|
||||||
|
|
||||||
renderData.lightMap.set(lightIndex.x(), lightIndex.y(), lightValue);
|
renderData.lightMap.set(lightIndex.x(), lightIndex.y(), lightValue);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user