Skip to content

Commit

Permalink
Merge branch 'suntzuquote' into 'master'
Browse files Browse the repository at this point in the history
Add an option to match sunlight to the sun (#8032)

Closes #8032

See merge request OpenMW/openmw!4490
  • Loading branch information
psi29a committed Jan 5, 2025
2 parents 25c19d5 + aa277c0 commit 52d1493
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/openmw/mwgui/settingswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ namespace MWGui

Settings::shaders().mForcePerPixelLighting.reset();
Settings::shaders().mClassicFalloff.reset();
Settings::shaders().mMatchSunlightToSun.reset();
Settings::shaders().mLightBoundsMultiplier.reset();
Settings::shaders().mMaximumLightDistance.reset();
Settings::shaders().mLightFadeStart.reset();
Expand Down
13 changes: 9 additions & 4 deletions apps/openmw/mwrender/renderingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,13 +754,18 @@ namespace MWRender

void RenderingManager::setSunDirection(const osg::Vec3f& direction)
{
osg::Vec3 position = direction * -1;
// need to wrap this in a StateUpdater?
mSunLight->setPosition(osg::Vec4(position.x(), position.y(), position.z(), 0));
osg::Vec3f position = -direction;

// The sun is not synchronized with the sunlight because sunlight origin can't reach the horizon
// The sun is not synchronized with the sunlight because reasons
// This is based on exterior sun orbit and won't make sense for interiors, see WeatherManager::update
position.z() = 400.f - std::abs(position.x());

// need to wrap this in a StateUpdater?
if (Settings::shaders().mMatchSunlightToSun)
mSunLight->setPosition(osg::Vec4f(position, 0.f));
else
mSunLight->setPosition(osg::Vec4f(-direction, 0.f));

mSky->setSunDirection(position);

mPostProcessor->getStateUpdater()->setSunPos(osg::Vec4f(position, 0.f), mNight);
Expand Down
1 change: 1 addition & 0 deletions components/settings/categories/shaders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace Settings
SettingValue<bool> mApplyLightingToEnvironmentMaps{ mIndex, "Shaders", "apply lighting to environment maps" };
SettingValue<SceneUtil::LightingMethod> mLightingMethod{ mIndex, "Shaders", "lighting method" };
SettingValue<bool> mClassicFalloff{ mIndex, "Shaders", "classic falloff" };
SettingValue<bool> mMatchSunlightToSun{ mIndex, "Shaders", "match sunlight to sun" };
SettingValue<float> mLightBoundsMultiplier{ mIndex, "Shaders", "light bounds multiplier",
makeClampSanitizerFloat(0, 5) };
SettingValue<float> mMaximumLightDistance{ mIndex, "Shaders", "maximum light distance",
Expand Down
12 changes: 12 additions & 0 deletions docs/source/reference/modding/settings/shaders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ Alternatively, refer to :ref:`minimum interior brightness`.

'legacy' :ref:`lighting method` behaves as if this setting were enabled.

match sunlight to sun
---------------------

:Type: boolean
:Range: True/False
:Default: False

In Morrowind, the apparent sun position does not match its light direction due to mysterious reasons.
We preserve this unrealistic behavior for compatibility.

This option makes the sun light source's position match the sun's position.

maximum light distance
----------------------

Expand Down
6 changes: 6 additions & 0 deletions files/data/l10n/OMWEngine/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ LightsMaximumDistance: "Maximale Lichtreichweite"
LightsMaximumDistanceTooltip: "Standard: 8192 (1 Zelle)\nMaximale Entfernung, bis zu der Lichtquellen noch dargestellt werden (gemessen in In-Game-Einheiten).\n\nEin Wert von 0 entspricht einer unbegrenzten Reichweite."
LightsMinimumInteriorBrightness: "Minimale Helligkeit in Innenräumen"
LightsMinimumInteriorBrightnessTooltip: "Standard: 0,08\nMinimale Umgebungshelligkeit in Innenräumen.\n\nKann erhöht werden, falls Innenräume zu dunkel dargestellt werden.\n\nDies hat keine Auswirkung, wenn der klassische Lichtabfall verwendet wird."
MatchSunlightToSun: "Licht an Sonne ausrichten"
MatchSunlightToSunTooltip: |-
In Morrowind stimmt die sichtbare Sonnenposition aus mysteriösen Gründen nicht mit ihrer Lichtrichtung überein.
Wir bewahren dieses unrealistische Verhalten, um die Kompatibilität sicherzustellen.
Diese Option passt die Position der Sonnenlichtquelle an die sichtbare Position der Sonne an.
MaxLights: "Maximale Anzahl von Lichtquellen pro Objekt"
MaxLightsTooltip: "Standard: 8\nMaximale Anzahl von Lichtquellen, die ein Objekt beleuchten können.\n\nKleine Werte können gerade an Orten mit vielen Lichtquellen zum Aufploppen und zum schnellen Wechsel von Lichtern führen, wie es aus der Original-Engine und anderen The-Elder-Scrolls-Titeln bekannt ist."
MenuHelpDelay: "Verzögerung des Hilfe-Menüs"
Expand Down
6 changes: 6 additions & 0 deletions files/data/l10n/OMWEngine/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ LightsMaximumDistance: "Maximum Light Distance"
LightsMaximumDistanceTooltip: "Default: 8192\nMaximum distance at which lights will appear (measured in units).\n\nSet this to 0 to use an unlimited distance."
LightsMinimumInteriorBrightness: "Minimum Interior Brightness"
LightsMinimumInteriorBrightnessTooltip: "Default: 0.08\nMinimum ambient interior brightness.\n\nIncrease this if you feel interiors are too dark.\n\nThis has no effect if classic falloff is used."
MatchSunlightToSun: "Match Sunlight to Sun"
MatchSunlightToSunTooltip: |-
In Morrowind, the apparent sun position does not match its light direction due to mysterious reasons.
We preserve this unrealistic behavior for compatibility.
This option makes the sun light source's position match the sun's position.
MaxLights: "Max Lights"
MaxLightsTooltip: "Default: 8\nMaximum number of lights per object.\n\nA low number near default will cause light popping similar to what you would see with legacy lighting."
MenuHelpDelay: "Menu Help Delay"
Expand Down
6 changes: 6 additions & 0 deletions files/data/l10n/OMWEngine/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ LightsMaximumDistance: "Distance maximale des sources lumineuses"
LightsMaximumDistanceTooltip: "valeur par défaut: 8192\nDistance maximale d'affichage des sources lumineuses (en unité de distance).\n\nMettez cette valeur à 0 pour une distance d'affichage infinie."
LightsMinimumInteriorBrightness: "Luminosité intérieure minimale"
LightsMinimumInteriorBrightnessTooltip: "valeur par défaut: 0.08\nLuminosité ambiante minimum en intérieur.\n\nAugmentez cette valeur si les intérieurs vous semblent trop sombres.\n\nCela n'a aucun effet si l'atténuation classique est utilisée."
MatchSunlightToSun: "Aligner la lumière du soleil"
MatchSunlightToSunTooltip: |-
Dans Morrowind, la position apparente du soleil ne correspond pas à la direction de sa lumière pour des raisons mystérieuses.
Nous conservons ce comportement irréaliste pour maintenir la compatibilité.
Cette option aligne la source lumineuse du soleil sur la position réelle du soleil.
MaxLights: "Maximum de sources lumineuses"
MaxLightsTooltip: "valeur par défaut: 8\nNombre maximum de sources lumineuses par objet.\n\nUne valeur faible mène à des apparitions tardives des sources lumineuses similaires à celles obtenues avec la méthode d'éclairage traditionnelle."
MenuHelpDelay: "Délai d'affichage du menu d'aide"
Expand Down
6 changes: 6 additions & 0 deletions files/data/l10n/OMWEngine/ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ LightsMaximumDistance: "Дальность отображения источни
LightsMaximumDistanceTooltip: "Значение по умолчанию: 8192\nМаксимальное расстояние, на котором будут отображаться источники света (во внутриигровых единицах измерения).\n\nЕсли 0, то расстояние не ограничено."
LightsMinimumInteriorBrightness: "Минимальный уровень освещения в помещениях"
LightsMinimumInteriorBrightnessTooltip: "Значение по умолчанию: 0.08\nМинимальный уровень фонового освещения в помещениях.\n\nУвеличьте значение, если помещения в игре кажутся слишком темными. Эта настройка не имеет эффекта, если используется классическое угасание."
MatchSunlightToSun: "Свет солнца идет от солнца"
MatchSunlightToSunTooltip: |-
В Morrowind по загадочным причинам видимое положение солнца не соответствует направлению его света.
Мы копируем это нереалистичное поведение ради совместимости.
Настройка делает так, чтобы направление света от солнца соответствовало его положению.
MaxLights: "Макс. кол-во источников света"
MaxLightsTooltip: "Значение по умолчанию: 8\nМаксимальное количество источников света для каждого объекта.\n\nНизкие числа (близкие к значению по умолчанию) приводят к резким перепадам освещения, как при устаревшем методе освещения."
MenuHelpDelay: "Задержка всплывающих подсказок"
Expand Down
6 changes: 6 additions & 0 deletions files/data/l10n/OMWEngine/sv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ LightsMaximumDistance: "Maximalt ljusavstånd"
LightsMaximumDistanceTooltip: "Förvalt: 8192\nMaximala avståndet där ljuskällor syns (mätt i enheter).\n\nVärdet 0 ger oändligt avstånd."
LightsMinimumInteriorBrightness: "Minsta ljusstyrka i interiörer"
LightsMinimumInteriorBrightnessTooltip: "Förvalt: 0.08\nMinsta omgivande ljusstyrka i interiörer.\n\nÖka värdet om du anser att interiörer är för mörka.\n\nDetta har ingen effekt om klassiskt ljusavtagande används."
MatchSunlightToSun: "Matcha solljus med solen"
MatchSunlightToSunTooltip: |-
I Morrowind stämmer inte solens synbara position överens med dess ljusriktning av mystiska skäl.
Vi behåller detta orealistiska beteende för att behålla kompatibilitet.
Detta alternativ gör att solljuskällans position matchar solens synliga position.
MaxLights: "Max antal ljuskällor"
MaxLightsTooltip: "Förvalt: 8\nMaximalt antal ljuskällor per objekt.\n\nEtt lågt tal nära det förvalda kommer orsaka att ljuskällor poppar upp som vid ljussättningsmetoden Gammaldags."
MenuHelpDelay: "Menyhjälp, fördröjning" #Unsure in what context this goes
Expand Down
37 changes: 26 additions & 11 deletions files/data/mygui/openmw_settings_window.layout
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout" version="3.2.0">
<Widget type="Window" skin="MW_Window" position="0 0 400 485" layer="Settings" name="_Main">
<Property key="MinSize" value="640 490"/>
<Property key="MinSize" value="640 540"/>
<Widget type="TabControl" skin="TabControl" position="8 8 368 405" align="Stretch" name="SettingsTab">
<Property key="ButtonAutoWidth" value="true"/>
<Widget type="TabItem">
Expand Down Expand Up @@ -626,15 +626,30 @@
</Widget>
</Widget>

<Widget type="ImageBox" skin="MW_HLine" position="0 84 360 18" align="Top HStretch"/>
<Widget type="HBox" position="0 90 600 24">
<!-- Match Sunlight To Sun -->
<Widget type="AutoSizedButton" skin="MW_Button" align="Left Top">
<UserString key="SettingCategory" value="Shaders"/>
<UserString key="SettingName" value="match sunlight to sun"/>
<UserString key="SettingType" value="CheckButton"/>
</Widget>
<Widget type="AutoSizedTextBox" skin="SandText" align="Left Top">
<Property key="Caption" value="#{OMWEngine:MatchSunlightToSun}"/>
<UserString key="ToolTipType" value="Layout"/>
<UserString key="ToolTipLayout" value="TextToolTip"/>
<UserString key="Caption_Text" value="#{OMWEngine:MatchSunlightToSunTooltip}"/>
</Widget>
</Widget>

<Widget type="ImageBox" skin="MW_HLine" position="0 114 360 18" align="Top HStretch"/>

<!-- Light Fade Start -->
<Widget type="TextBox" skin="NormalText" position="0 104 500 18" align="Left Top" name="MaxLightDistanceText">
<Widget type="TextBox" skin="NormalText" position="0 134 500 18" align="Left Top" name="MaxLightDistanceText">
<UserString key="ToolTipType" value="Layout"/>
<UserString key="ToolTipLayout" value="TextToolTip"/>
<UserString key="Caption_Text" value="#{OMWEngine:LightsMaximumDistanceTooltip}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HScroll" position="0 128 352 18" align="HStretch Top">
<Widget type="ScrollBar" skin="MW_HScroll" position="0 158 352 18" align="HStretch Top">
<Property key="Range" value="8193"/>
<Property key="Page" value="128"/>
<UserString key="SettingType" value="Slider"/>
Expand All @@ -647,12 +662,12 @@
<UserString key="SettingLabelCaption" value="#{OMWEngine:LightsMaximumDistance} (%s)"/>
</Widget>
<!-- Light Fade Multiplier -->
<Widget type="TextBox" skin="NormalText" position="0 152 500 18" align="Left Top" name="LightFadeMultiplierText">
<Widget type="TextBox" skin="NormalText" position="0 182 500 18" align="Left Top" name="LightFadeMultiplierText">
<UserString key="ToolTipType" value="Layout"/>
<UserString key="ToolTipLayout" value="TextToolTip"/>
<UserString key="Caption_Text" value="#{OMWEngine:LightsFadeStartMultiplierTooltip}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HScroll" position="0 176 352 18" align="HStretch Top">
<Widget type="ScrollBar" skin="MW_HScroll" position="0 206 352 18" align="HStretch Top">
<Property key="Range" value="10000"/>
<Property key="Page" value="100"/>
<UserString key="SettingType" value="Slider"/>
Expand All @@ -665,12 +680,12 @@
<UserString key="SettingLabelCaption" value="#{OMWEngine:LightsFadeStartMultiplier} (%s)"/>
</Widget>
<!-- Bounding Sphere Multiplier -->
<Widget type="TextBox" skin="NormalText" position="0 200 500 18" align="Left Top" name="BoundingSphereMultText">
<Widget type="TextBox" skin="NormalText" position="0 230 500 18" align="Left Top" name="BoundingSphereMultText">
<UserString key="ToolTipType" value="Layout"/>
<UserString key="ToolTipLayout" value="TextToolTip"/>
<UserString key="Caption_Text" value="#{OMWEngine:LightsBoundingSphereMultiplierTooltip}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HScroll" position="0 224 352 18" align="HStretch Top">
<Widget type="ScrollBar" skin="MW_HScroll" position="0 254 352 18" align="HStretch Top">
<Property key="Range" value="500000"/>
<Property key="Page" value="1000"/>
<UserString key="SettingType" value="Slider"/>
Expand All @@ -683,12 +698,12 @@
<UserString key="SettingLabelCaption" value="#{OMWEngine:LightsBoundingSphereMultiplier} (%s)"/>
</Widget>
<!-- Minimum Ambient Brightness -->
<Widget type="TextBox" skin="NormalText" position="0 248 500 18" align="Left Top" name="MinimumBrightnessText">
<Widget type="TextBox" skin="NormalText" position="0 278 500 18" align="Left Top" name="MinimumBrightnessText">
<UserString key="ToolTipType" value="Layout"/>
<UserString key="ToolTipLayout" value="TextToolTip"/>
<UserString key="Caption_Text" value="#{OMWEngine:LightsMinimumInteriorBrightnessTooltip}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HScroll" position="0 272 352 18" align="HStretch Top">
<Widget type="ScrollBar" skin="MW_HScroll" position="0 302 352 18" align="HStretch Top">
<Property key="Range" value="10000"/>
<Property key="Page" value="100"/>
<UserString key="SettingType" value="Slider"/>
Expand All @@ -698,7 +713,7 @@
<UserString key="SettingLabelWidget" value="MinimumBrightnessText"/>
<UserString key="SettingLabelCaption" value="#{OMWEngine:LightsMinimumInteriorBrightness} (%s)"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" position="0 306 0 0" align="Top Left" name="LightsResetButton">
<Widget type="AutoSizedButton" skin="MW_Button" position="0 336 0 0" align="Top Left" name="LightsResetButton">
<Property key="Caption" value="#{Interface:Reset}"/>
</Widget>
</Widget>
Expand Down
3 changes: 3 additions & 0 deletions files/settings-default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ lighting method = shaders compatibility
# When 'lighting method' is set to 'legacy', this setting is always true.
classic falloff = false

# Matches exterior sunlight to the apparent sun orbit
match sunlight to sun = false

# Sets the bounding sphere multiplier of light sources.
# The bounding sphere is used to determine if an object should receive lighting.
# Higher values will allow for smoother transitions of light sources,
Expand Down

0 comments on commit 52d1493

Please sign in to comment.