lighting: disable the new additive point light behavior when new lighting is off

This commit is contained in:
Kae 2024-06-28 17:10:17 +10:00
parent bb5387fbdb
commit 54ac208dd5
9 changed files with 58 additions and 34 deletions

View File

@ -4,7 +4,7 @@ function patch(original)
image:copyInto({0, 0}, original:process("?crop=0;0;236;96")) image:copyInto({0, 0}, original:process("?crop=0;0;236;96"))
local checkbox = image:process("?crop=19;26;117;35") local checkbox = image:process("?crop=19;26;117;35")
image:copyInto({119, 26}, checkbox) -- Anti-Aliasing image:copyInto({119, 26}, checkbox) -- Anti-Aliasing
image:copyInto({19, 15}, checkbox) -- Object Lighting image:copyInto({19, 15}, checkbox) -- New Lighting
image:copyInto({119, 15}, checkbox) -- Hardware Cursor image:copyInto({119, 15}, checkbox) -- Hardware Cursor
image:copyInto({119, 68}, image:process("?crop=19;68;117;87")) -- Camera Pan Speed image:copyInto({119, 68}, image:process("?crop=19;68;117;87")) -- Camera Pan Speed

View File

@ -35,9 +35,9 @@ function patch(config)
-- Create anti-aliasing toggle -- Create anti-aliasing toggle
shift(clone(layout, "multiTextureLabel", "antiAliasingLabel"), 98).value = "SUPER-SAMPLED AA" shift(clone(layout, "multiTextureLabel", "antiAliasingLabel"), 98).value = "SUPER-SAMPLED AA"
shift(clone(layout, "multiTextureCheckbox", "antiAliasingCheckbox"), 99) shift(clone(layout, "multiTextureCheckbox", "antiAliasingCheckbox"), 99)
-- Create object lighting toggle -- Create new lighting toggle
shift(clone(layout, "multiTextureLabel", "objectLightingLabel"), 0, -11).value = "NEW OBJECT LIGHTS" shift(clone(layout, "multiTextureLabel", "newLightingLabel"), 0, -11).value = "NEW LIGHTING"
shift(clone(layout, "multiTextureCheckbox", "objectLightingCheckbox"), 0, -11) shift(clone(layout, "multiTextureCheckbox", "newLightingCheckbox"), 0, -11)
-- Create hardware cursor toggle -- Create hardware cursor toggle
shift(clone(layout, "multiTextureLabel", "hardwareCursorLabel"), 98, -11).value = "HARDWARE CURSOR" shift(clone(layout, "multiTextureLabel", "hardwareCursorLabel"), 98, -11).value = "HARDWARE CURSOR"
shift(clone(layout, "multiTextureCheckbox", "hardwareCursorCheckbox"), 99, -11) shift(clone(layout, "multiTextureCheckbox", "hardwareCursorCheckbox"), 99, -11)

View File

@ -1,5 +1,5 @@
{ {
"lighting" : { "lighting" : {
"brightnessLimit" : 1.5 "brightnessLimit" : 1.4
} }
} }

View File

@ -1,6 +1,22 @@
--local function drop(color)
-- if type(color) == "table" then
-- for i = 1, #color do
-- color[i] = color[i] * 0.8
-- end
-- end
--end
function patch(object, path) function patch(object, path)
if object.pointLight ~= true and (object.lightColor or object.lightColors) then if object.pointLight ~= true and (object.lightColor or object.lightColors) then
object.lightType = "PointAsSpread" object.lightType = "PointAsSpread"
return object; return object
--elseif type(object.lightColor) == "table" then
-- drop(object.lightColor)
-- return object
--elseif type(object.lightColors) == "table" then
-- for i, v in pairs(object.lightColors) do
-- drop(v)
-- end
-- return object
end end
end end

View File

@ -64,12 +64,12 @@ void CellularLightArray<ScalarLightTraits>::calculatePointLighting(size_t xmin,
attenuation += min(blockAttenuation, circularizedPerBlockObstacleAttenuation) * m_pointObstacleBoost; attenuation += min(blockAttenuation, circularizedPerBlockObstacleAttenuation) * m_pointObstacleBoost;
if (attenuation < 1.0f) { if (attenuation < 1.0f) {
auto newLight = ScalarLightTraits::subtract(light.value, attenuation); if (m_pointAdditive) {
if (ScalarLightTraits::maxIntensity(newLight) > 0.0001f) { auto newLight = ScalarLightTraits::subtract(light.value, attenuation);
if (light.asSpread) if (ScalarLightTraits::maxIntensity(newLight) > 0.0001f)
setLight(x, y, lvalue + newLight * 0.15f); setLight(x, y, lvalue + (light.asSpread ? newLight * 0.15f : newLight));
else } else {
setLight(x, y, lvalue + newLight); 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; attenuation += min(blockAttenuation, circularizedPerBlockObstacleAttenuation) * m_pointObstacleBoost;
if (attenuation < 1.0f) { if (attenuation < 1.0f) {
auto newLight = ColoredLightTraits::subtract(light.value, attenuation); if (m_pointAdditive) {
if (ColoredLightTraits::maxIntensity(newLight) > 0.0001f) { auto newLight = ColoredLightTraits::subtract(light.value, attenuation);
if (light.asSpread) if (ColoredLightTraits::maxIntensity(newLight) > 0.0001f)
setLight(x, y, lvalue + newLight * 0.15f); setLight(x, y, lvalue + (light.asSpread ? newLight * 0.15f : newLight));
else } else {
setLight(x, y, lvalue + newLight); setLight(x, y, ColoredLightTraits::max(ColoredLightTraits::subtract(light.value, attenuation), lvalue));
} }
} }
} }

View File

@ -60,7 +60,7 @@ public:
}; };
void setParameters(unsigned spreadPasses, float spreadMaxAir, float spreadMaxObstacle, 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 // The border around the target lighting array where initial lighting / light
// source data is required. Based on parameters. // source data is required. Based on parameters.
@ -129,6 +129,7 @@ private:
float m_pointMaxAir; float m_pointMaxAir;
float m_pointMaxObstacle; float m_pointMaxObstacle;
float m_pointObstacleBoost; float m_pointObstacleBoost;
bool m_pointAdditive;
}; };
typedef CellularLightArray<ColoredLightTraits> ColoredCellularLightArray; typedef CellularLightArray<ColoredLightTraits> ColoredCellularLightArray;
@ -204,13 +205,14 @@ inline Vec3F ColoredLightTraits::max(Vec3F const& v1, Vec3F const& v2) {
template <typename LightTraits> template <typename LightTraits>
void CellularLightArray<LightTraits>::setParameters(unsigned spreadPasses, float spreadMaxAir, float spreadMaxObstacle, 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_spreadPasses = spreadPasses;
m_spreadMaxAir = spreadMaxAir; m_spreadMaxAir = spreadMaxAir;
m_spreadMaxObstacle = spreadMaxObstacle; m_spreadMaxObstacle = spreadMaxObstacle;
m_pointMaxAir = pointMaxAir; m_pointMaxAir = pointMaxAir;
m_pointMaxObstacle = pointMaxObstacle; m_pointMaxObstacle = pointMaxObstacle;
m_pointObstacleBoost = pointObstacleBoost; m_pointObstacleBoost = pointObstacleBoost;
m_pointAdditive = pointAdditive;
} }
template <typename LightTraits> template <typename LightTraits>

View File

@ -73,7 +73,8 @@ void CellularLightingCalculator::setParameters(Json const& config) {
config.getFloat("spreadMaxObstacle"), config.getFloat("spreadMaxObstacle"),
config.getFloat("pointMaxAir"), config.getFloat("pointMaxAir"),
config.getFloat("pointMaxObstacle"), config.getFloat("pointMaxObstacle"),
config.getFloat("pointObstacleBoost") config.getFloat("pointObstacleBoost"),
config.getBool("pointAdditive", false)
); );
else else
m_lightArray.left().setParameters( m_lightArray.left().setParameters(
@ -82,7 +83,8 @@ void CellularLightingCalculator::setParameters(Json const& config) {
config.getFloat("spreadMaxObstacle"), config.getFloat("spreadMaxObstacle"),
config.getFloat("pointMaxAir"), config.getFloat("pointMaxAir"),
config.getFloat("pointMaxObstacle"), 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("spreadMaxObstacle"),
config.getFloat("pointMaxAir"), config.getFloat("pointMaxAir"),
config.getFloat("pointMaxObstacle"), config.getFloat("pointMaxObstacle"),
config.getFloat("pointObstacleBoost") config.getFloat("pointObstacleBoost"),
config.getBool("pointAdditive", false)
); );
} }

View File

@ -97,10 +97,10 @@ GraphicsMenu::GraphicsMenu() {
Root::singleton().configuration()->set("monochromeLighting", checked); Root::singleton().configuration()->set("monochromeLighting", checked);
syncGui(); syncGui();
}); });
reader.registerCallback("objectLightingCheckbox", [=](Widget*) { reader.registerCallback("newLightingCheckbox", [=](Widget*) {
bool checked = fetchChild<ButtonWidget>("objectLightingCheckbox")->isChecked(); bool checked = fetchChild<ButtonWidget>("newLightingCheckbox")->isChecked();
m_localChanges.set("newObjectLighting", checked); m_localChanges.set("newLighting", checked);
Root::singleton().configuration()->set("newObjectLighting", checked); Root::singleton().configuration()->set("newLighting", checked);
syncGui(); syncGui();
}); });
@ -162,7 +162,7 @@ StringList const GraphicsMenu::ConfigKeys = {
"antiAliasing", "antiAliasing",
"hardwareCursor", "hardwareCursor",
"monochromeLighting", "monochromeLighting",
"newObjectLighting" "newLighting"
}; };
void GraphicsMenu::initConfig() { void GraphicsMenu::initConfig() {
@ -229,7 +229,7 @@ void GraphicsMenu::syncGui() {
fetchChild<ButtonWidget>("multiTextureCheckbox")->setChecked(m_localChanges.get("useMultiTexturing").optBool().value(true)); fetchChild<ButtonWidget>("multiTextureCheckbox")->setChecked(m_localChanges.get("useMultiTexturing").optBool().value(true));
fetchChild<ButtonWidget>("antiAliasingCheckbox")->setChecked(m_localChanges.get("antiAliasing").toBool()); fetchChild<ButtonWidget>("antiAliasingCheckbox")->setChecked(m_localChanges.get("antiAliasing").toBool());
fetchChild<ButtonWidget>("monochromeCheckbox")->setChecked(m_localChanges.get("monochromeLighting").toBool()); fetchChild<ButtonWidget>("monochromeCheckbox")->setChecked(m_localChanges.get("monochromeLighting").toBool());
fetchChild<ButtonWidget>("objectLightingCheckbox")->setChecked(m_localChanges.get("newObjectLighting").optBool().value(true)); fetchChild<ButtonWidget>("newLightingCheckbox")->setChecked(m_localChanges.get("newLighting").optBool().value(true));
fetchChild<ButtonWidget>("hardwareCursorCheckbox")->setChecked(m_localChanges.get("hardwareCursor").toBool()); fetchChild<ButtonWidget>("hardwareCursorCheckbox")->setChecked(m_localChanges.get("hardwareCursor").toBool());
} }

View File

@ -1667,29 +1667,32 @@ void WorldClient::lightingCalc() {
RectI lightRange = m_pendingLightRange; RectI lightRange = m_pendingLightRange;
List<LightSource> lights = std::move(m_pendingLights); List<LightSource> lights = std::move(m_pendingLights);
List<std::pair<Vec2F, Vec3F>> particleLights = std::move(m_pendingParticleLights); List<std::pair<Vec2F, Vec3F>> particleLights = std::move(m_pendingParticleLights);
auto configuration = Root::singleton().configuration(); auto& root = Root::singleton();
auto configuration = root.configuration();
bool newLighting = configuration->get("newLighting").optBool().value(true);
bool monochrome = configuration->get("monochromeLighting").toBool(); bool monochrome = configuration->get("monochromeLighting").toBool();
m_lightingCalculator.setParameters(root.assets()->json("/lighting.config:lighting").set("pointAdditive", newLighting));
m_lightingCalculator.setMonochrome(monochrome); m_lightingCalculator.setMonochrome(monochrome);
m_lightingCalculator.begin(lightRange); m_lightingCalculator.begin(lightRange);
lightingTileGather(); lightingTileGather();
prepLocker.unlock(); prepLocker.unlock();
bool useHybridPointLights = configuration->get("newObjectLighting").optBool().value(true);
for (auto const& light : lights) { for (auto const& light : lights) {
Vec2F position = m_geometry.nearestTo(Vec2F(m_lightingCalculator.calculationRegion().min()), light.position); Vec2F position = m_geometry.nearestTo(Vec2F(m_lightingCalculator.calculationRegion().min()), light.position);
if (light.type == LightType::Spread) if (light.type == LightType::Spread)
m_lightingCalculator.addSpreadLight(position, light.color); m_lightingCalculator.addSpreadLight(position, light.color);
else { else {
if (light.type == LightType::PointAsSpread) { if (light.type == LightType::PointAsSpread) {
if (!useHybridPointLights) if (!newLighting)
m_lightingCalculator.addSpreadLight(position, light.color); m_lightingCalculator.addSpreadLight(position, light.color);
else { // hybrid (used for auto-converted object lights) - 85% spread, 15% point (2nd is applied elsewhere) else { // hybrid (used for auto-converted object lights) - 85% spread, 15% point (* .15 is applied in the calculation code)
m_lightingCalculator.addSpreadLight(position, light.color * 0.85f); m_lightingCalculator.addSpreadLight(position, light.color * 0.85f);
m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience, true); m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience, true);
} }
} else // fully additive point light } else {
m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience); m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience);
}
} }
} }