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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/opensb/interface/graphicsmenu/body.png.patch.lua2
-rw-r--r--assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua6
-rw-r--r--assets/opensb/lighting.config.patch2
-rw-r--r--assets/opensb/objects/opensb/object.patch.lua18
-rw-r--r--source/base/StarCellularLightArray.cpp24
-rw-r--r--source/base/StarCellularLightArray.hpp6
-rw-r--r--source/base/StarCellularLighting.cpp9
-rw-r--r--source/frontend/StarGraphicsMenu.cpp12
-rw-r--r--source/game/StarWorldClient.cpp13
9 files changed, 58 insertions, 34 deletions
diff --git a/assets/opensb/interface/graphicsmenu/body.png.patch.lua b/assets/opensb/interface/graphicsmenu/body.png.patch.lua
index 85ac17e..16051ab 100644
--- a/assets/opensb/interface/graphicsmenu/body.png.patch.lua
+++ b/assets/opensb/interface/graphicsmenu/body.png.patch.lua
@@ -4,7 +4,7 @@ function patch(original)
image:copyInto({0, 0}, original:process("?crop=0;0;236;96"))
local checkbox = image:process("?crop=19;26;117;35")
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, 68}, image:process("?crop=19;68;117;87")) -- Camera Pan Speed
diff --git a/assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua b/assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua
index 02d305c..7d7ab44 100644
--- a/assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua
+++ b/assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua
@@ -35,9 +35,9 @@ function patch(config)
-- Create anti-aliasing toggle
shift(clone(layout, "multiTextureLabel", "antiAliasingLabel"), 98).value = "SUPER-SAMPLED AA"
shift(clone(layout, "multiTextureCheckbox", "antiAliasingCheckbox"), 99)
- -- Create object lighting toggle
- shift(clone(layout, "multiTextureLabel", "objectLightingLabel"), 0, -11).value = "NEW OBJECT LIGHTS"
- shift(clone(layout, "multiTextureCheckbox", "objectLightingCheckbox"), 0, -11)
+ -- Create new lighting toggle
+ shift(clone(layout, "multiTextureLabel", "newLightingLabel"), 0, -11).value = "NEW LIGHTING"
+ shift(clone(layout, "multiTextureCheckbox", "newLightingCheckbox"), 0, -11)
-- Create hardware cursor toggle
shift(clone(layout, "multiTextureLabel", "hardwareCursorLabel"), 98, -11).value = "HARDWARE CURSOR"
shift(clone(layout, "multiTextureCheckbox", "hardwareCursorCheckbox"), 99, -11)
diff --git a/assets/opensb/lighting.config.patch b/assets/opensb/lighting.config.patch
index 92f7c62..44c0716 100644
--- a/assets/opensb/lighting.config.patch
+++ b/assets/opensb/lighting.config.patch
@@ -1,5 +1,5 @@
{
"lighting" : {
- "brightnessLimit" : 1.5
+ "brightnessLimit" : 1.4
}
} \ No newline at end of file
diff --git a/assets/opensb/objects/opensb/object.patch.lua b/assets/opensb/objects/opensb/object.patch.lua
index df783ac..45ecf23 100644
--- a/assets/opensb/objects/opensb/object.patch.lua
+++ b/assets/opensb/objects/opensb/object.patch.lua
@@ -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)
if object.pointLight ~= true and (object.lightColor or object.lightColors) then
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 \ No newline at end of file
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)
);
}
diff --git a/source/frontend/StarGraphicsMenu.cpp b/source/frontend/StarGraphicsMenu.cpp
index 6713c72..efce444 100644
--- a/source/frontend/StarGraphicsMenu.cpp
+++ b/source/frontend/StarGraphicsMenu.cpp
@@ -97,10 +97,10 @@ GraphicsMenu::GraphicsMenu() {
Root::singleton().configuration()->set("monochromeLighting", checked);
syncGui();
});
- reader.registerCallback("objectLightingCheckbox", [=](Widget*) {
- bool checked = fetchChild<ButtonWidget>("objectLightingCheckbox")->isChecked();
- m_localChanges.set("newObjectLighting", checked);
- Root::singleton().configuration()->set("newObjectLighting", checked);
+ reader.registerCallback("newLightingCheckbox", [=](Widget*) {
+ bool checked = fetchChild<ButtonWidget>("newLightingCheckbox")->isChecked();
+ m_localChanges.set("newLighting", checked);
+ Root::singleton().configuration()->set("newLighting", checked);
syncGui();
});
@@ -162,7 +162,7 @@ StringList const GraphicsMenu::ConfigKeys = {
"antiAliasing",
"hardwareCursor",
"monochromeLighting",
- "newObjectLighting"
+ "newLighting"
};
void GraphicsMenu::initConfig() {
@@ -229,7 +229,7 @@ void GraphicsMenu::syncGui() {
fetchChild<ButtonWidget>("multiTextureCheckbox")->setChecked(m_localChanges.get("useMultiTexturing").optBool().value(true));
fetchChild<ButtonWidget>("antiAliasingCheckbox")->setChecked(m_localChanges.get("antiAliasing").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());
}
diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp
index aa6f293..9e0478a 100644
--- a/source/game/StarWorldClient.cpp
+++ b/source/game/StarWorldClient.cpp
@@ -1667,29 +1667,32 @@ void WorldClient::lightingCalc() {
RectI lightRange = m_pendingLightRange;
List<LightSource> lights = std::move(m_pendingLights);
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();
+ m_lightingCalculator.setParameters(root.assets()->json("/lighting.config:lighting").set("pointAdditive", newLighting));
m_lightingCalculator.setMonochrome(monochrome);
m_lightingCalculator.begin(lightRange);
lightingTileGather();
prepLocker.unlock();
- bool useHybridPointLights = configuration->get("newObjectLighting").optBool().value(true);
for (auto const& light : lights) {
Vec2F position = m_geometry.nearestTo(Vec2F(m_lightingCalculator.calculationRegion().min()), light.position);
if (light.type == LightType::Spread)
m_lightingCalculator.addSpreadLight(position, light.color);
else {
if (light.type == LightType::PointAsSpread) {
- if (!useHybridPointLights)
+ if (!newLighting)
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.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);
+ }
}
}