diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-06-28 17:10:17 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-06-28 17:10:17 +1000 |
commit | 54ac208dd5a54c827567a3a86e152680ae7663ea (patch) | |
tree | 86218292795659a558f5ae65a712f1e6ed0e33ea /source/base | |
parent | bb5387fbdb90ec5e3b387ed73718b281b207252b (diff) |
lighting: disable the new additive point light behavior when new lighting is off
Diffstat (limited to 'source/base')
-rw-r--r-- | source/base/StarCellularLightArray.cpp | 24 | ||||
-rw-r--r-- | source/base/StarCellularLightArray.hpp | 6 | ||||
-rw-r--r-- | source/base/StarCellularLighting.cpp | 9 |
3 files changed, 22 insertions, 17 deletions
diff --git a/source/base/StarCellularLightArray.cpp b/source/base/StarCellularLightArray.cpp index 49e0917..c20cd5c 100644 --- a/source/base/StarCellularLightArray.cpp +++ b/source/base/StarCellularLightArray.cpp @@ -64,12 +64,12 @@ void CellularLightArray<ScalarLightTraits>::calculatePointLighting(size_t xmin, attenuation += min(blockAttenuation, circularizedPerBlockObstacleAttenuation) * m_pointObstacleBoost; if (attenuation < 1.0f) { - auto newLight = ScalarLightTraits::subtract(light.value, attenuation); - if (ScalarLightTraits::maxIntensity(newLight) > 0.0001f) { - if (light.asSpread) - setLight(x, y, lvalue + newLight * 0.15f); - else - setLight(x, y, lvalue + newLight); + if (m_pointAdditive) { + auto newLight = ScalarLightTraits::subtract(light.value, attenuation); + if (ScalarLightTraits::maxIntensity(newLight) > 0.0001f) + setLight(x, y, lvalue + (light.asSpread ? newLight * 0.15f : newLight)); + } else { + setLight(x, y, ScalarLightTraits::max(ScalarLightTraits::subtract(light.value, attenuation), lvalue)); } } } @@ -137,12 +137,12 @@ void CellularLightArray<ColoredLightTraits>::calculatePointLighting(size_t xmin, attenuation += min(blockAttenuation, circularizedPerBlockObstacleAttenuation) * m_pointObstacleBoost; if (attenuation < 1.0f) { - auto newLight = ColoredLightTraits::subtract(light.value, attenuation); - if (ColoredLightTraits::maxIntensity(newLight) > 0.0001f) { - if (light.asSpread) - setLight(x, y, lvalue + newLight * 0.15f); - else - setLight(x, y, lvalue + newLight); + if (m_pointAdditive) { + auto newLight = ColoredLightTraits::subtract(light.value, attenuation); + if (ColoredLightTraits::maxIntensity(newLight) > 0.0001f) + setLight(x, y, lvalue + (light.asSpread ? newLight * 0.15f : newLight)); + } else { + setLight(x, y, ColoredLightTraits::max(ColoredLightTraits::subtract(light.value, attenuation), lvalue)); } } } diff --git a/source/base/StarCellularLightArray.hpp b/source/base/StarCellularLightArray.hpp index 587ae1f..4b7e654 100644 --- a/source/base/StarCellularLightArray.hpp +++ b/source/base/StarCellularLightArray.hpp @@ -60,7 +60,7 @@ public: }; void setParameters(unsigned spreadPasses, float spreadMaxAir, float spreadMaxObstacle, - float pointMaxAir, float pointMaxObstacle, float pointObstacleBoost); + float pointMaxAir, float pointMaxObstacle, float pointObstacleBoost, bool pointAdditive); // The border around the target lighting array where initial lighting / light // source data is required. Based on parameters. @@ -129,6 +129,7 @@ private: float m_pointMaxAir; float m_pointMaxObstacle; float m_pointObstacleBoost; + bool m_pointAdditive; }; typedef CellularLightArray<ColoredLightTraits> ColoredCellularLightArray; @@ -204,13 +205,14 @@ inline Vec3F ColoredLightTraits::max(Vec3F const& v1, Vec3F const& v2) { template <typename LightTraits> void CellularLightArray<LightTraits>::setParameters(unsigned spreadPasses, float spreadMaxAir, float spreadMaxObstacle, - float pointMaxAir, float pointMaxObstacle, float pointObstacleBoost) { + float pointMaxAir, float pointMaxObstacle, float pointObstacleBoost, bool pointAdditive) { m_spreadPasses = spreadPasses; m_spreadMaxAir = spreadMaxAir; m_spreadMaxObstacle = spreadMaxObstacle; m_pointMaxAir = pointMaxAir; m_pointMaxObstacle = pointMaxObstacle; m_pointObstacleBoost = pointObstacleBoost; + m_pointAdditive = pointAdditive; } template <typename LightTraits> diff --git a/source/base/StarCellularLighting.cpp b/source/base/StarCellularLighting.cpp index 48ba265..d5ef9ee 100644 --- a/source/base/StarCellularLighting.cpp +++ b/source/base/StarCellularLighting.cpp @@ -73,7 +73,8 @@ void CellularLightingCalculator::setParameters(Json const& config) { config.getFloat("spreadMaxObstacle"), config.getFloat("pointMaxAir"), config.getFloat("pointMaxObstacle"), - config.getFloat("pointObstacleBoost") + config.getFloat("pointObstacleBoost"), + config.getBool("pointAdditive", false) ); else m_lightArray.left().setParameters( @@ -82,7 +83,8 @@ void CellularLightingCalculator::setParameters(Json const& config) { config.getFloat("spreadMaxObstacle"), config.getFloat("pointMaxAir"), config.getFloat("pointMaxObstacle"), - config.getFloat("pointObstacleBoost") + config.getFloat("pointObstacleBoost"), + config.getBool("pointAdditive", false) ); } @@ -190,7 +192,8 @@ void CellularLightIntensityCalculator::setParameters(Json const& config) { config.getFloat("spreadMaxObstacle"), config.getFloat("pointMaxAir"), config.getFloat("pointMaxObstacle"), - config.getFloat("pointObstacleBoost") + config.getFloat("pointObstacleBoost"), + config.getBool("pointAdditive", false) ); } |