Skip to content

Commit 6c5d939

Browse files
committed
Merge branch 'telvanni-photon-magic' into 'master'
Project Magnus (Volume Tiled Forward Shading) Closes #6900 See merge request OpenMW/openmw!5212
2 parents 1c5a942 + 60ff408 commit 6c5d939

73 files changed

Lines changed: 1205 additions & 1630 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Ubuntu_GCC_preprocess:
8888
- if [[ "${BUILD_TESTS_ONLY}" && ! "${BUILD_WITH_CODE_COVERAGE}" ]]; then ./openmw_settings_access_benchmark; fi
8989
- ccache -svv
9090
- df -h
91-
- if [[ "${BUILD_WITH_CODE_COVERAGE}" ]]; then ~/.local/bin/gcovr --xml-pretty --exclude-unreachable-branches --gcov-ignore-parse-errors=negative_hits.warn_once_per_file --print-summary --root "${CI_PROJECT_DIR}" -j $(nproc) -o ../coverage.xml; fi
91+
- if [[ "${BUILD_WITH_CODE_COVERAGE}" ]]; then ~/.local/bin/gcovr --merge-mode-functions merge-use-line-max --xml-pretty --exclude-unreachable-branches --gcov-ignore-parse-errors=negative_hits.warn_once_per_file --print-summary --root "${CI_PROJECT_DIR}" -j $(nproc) -o ../coverage.xml; fi
9292
# this line must be updated when artifacts are added or they'll be deleted, but if we get rid of it, we run out of disk space while archiving
9393
- find * -type f | grep -v -e '^extern/' -e '^install/' -e 'CMakeCache\.txt$' -e '^components-tests.xml$' -e '^openmw-tests.xml$' -e '^openmw-cs-tests.xml$' | xargs rm -f
9494
- cd ..
@@ -425,7 +425,7 @@ Ubuntu_Clang:
425425
CTCACHE_CLANG_TIDY: /usr/bin/clang-tidy-19
426426
CTCACHE_SAVE_OUTPUT: 1
427427
CTCACHE_DIR: $CI_PROJECT_DIR/ctcache
428-
428+
429429
CMAKE_CXX_CLANG_TIDY: 'clang_tidy_cache.py;$CTCACHE_CLANG_TIDY'
430430
script:
431431
- mkdir -pv "${CCACHE_DIR}"

apps/components_tests/resource/testresourcesystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace
2727

2828
auto shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
2929

30-
osg::ref_ptr<SceneUtil::LightManager> lightManager = new SceneUtil::LightManager(SceneUtil::LightSettings{});
30+
osg::ref_ptr<SceneUtil::LightManager> lightManager
31+
= new SceneUtil::LightManager(SceneUtil::LightSettings{}, &resourceSystem);
3132
auto lightDefines = lightManager->getLightDefines();
3233

3334
for (const auto& define : shadowDefines)

apps/launcher/settingspage.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,6 @@ bool Launcher::SettingsPage::loadSettings()
330330
}
331331

332332
connect(shadowDistanceCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotShadowDistLimitToggled);
333-
334-
int lightingMethod = 0;
335-
switch (Settings::shaders().mLightingMethod)
336-
{
337-
case SceneUtil::LightingMethod::PerObjectUniform:
338-
lightingMethod = 0;
339-
break;
340-
case SceneUtil::LightingMethod::SingleUBO:
341-
lightingMethod = 1;
342-
break;
343-
}
344-
lightingMethodComboBox->setCurrentIndex(lightingMethod);
345333
}
346334

347335
// Audio
@@ -584,12 +572,6 @@ void Launcher::SettingsPage::saveSettings()
584572
saveSettingBool(*skyBlendingCheckBox, Settings::fog().mSkyBlending);
585573
Settings::fog().mSkyBlendingStart.set(skyBlendingStartComboBox->value());
586574

587-
static constexpr std::array<SceneUtil::LightingMethod, 2> lightingMethodMap = {
588-
SceneUtil::LightingMethod::PerObjectUniform,
589-
SceneUtil::LightingMethod::SingleUBO,
590-
};
591-
Settings::shaders().mLightingMethod.set(lightingMethodMap[lightingMethodComboBox->currentIndex()]);
592-
593575
const int cShadowDist
594576
= shadowDistanceCheckBox->checkState() != Qt::Unchecked ? shadowDistanceSpinBox->value() : 0;
595577
Settings::shadows().mMaximumShadowMapDistance.set(cShadowDist);

apps/launcher/ui/settingspage.ui

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,56 +1022,6 @@
10221022
</item>
10231023
</layout>
10241024
</widget>
1025-
<widget class="QWidget" name="lightingTab">
1026-
<attribute name="title">
1027-
<string>Lighting</string>
1028-
</attribute>
1029-
<layout class="QHBoxLayout" name="horizontalLightingLayout">
1030-
<item>
1031-
<layout class="QGridLayout" name="lightingLayout" columnstretch="0,0">
1032-
<item row="2" column="1">
1033-
<spacer name="verticalSpacer_10">
1034-
<property name="orientation">
1035-
<enum>Qt::Vertical</enum>
1036-
</property>
1037-
<property name="sizeHint" stdset="0">
1038-
<size>
1039-
<width>20</width>
1040-
<height>40</height>
1041-
</size>
1042-
</property>
1043-
</spacer>
1044-
</item>
1045-
<item row="1" column="0">
1046-
<widget class="QLabel" name="lightingMethodLabel">
1047-
<property name="toolTip">
1048-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
1049-
&lt;p&gt;&quot;Shaders (compatibility)&quot; It is recommended to use this with older hardware and a light limit closer to 8.&lt;/p&gt;
1050-
&lt;p&gt; &quot;Shaders&quot; carries all of the benefits that &quot;Shaders (compatibility)&quot; does, but uses a modern approach that allows for a higher max lights count with little to no performance penalties on modern hardware.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1051-
</property>
1052-
<property name="text">
1053-
<string>Lighting Method</string>
1054-
</property>
1055-
</widget>
1056-
</item>
1057-
<item row="1" column="1">
1058-
<widget class="QComboBox" name="lightingMethodComboBox">
1059-
<item>
1060-
<property name="text">
1061-
<string>Shaders (compatibility)</string>
1062-
</property>
1063-
</item>
1064-
<item>
1065-
<property name="text">
1066-
<string>Shaders</string>
1067-
</property>
1068-
</item>
1069-
</widget>
1070-
</item>
1071-
</layout>
1072-
</item>
1073-
</layout>
1074-
</widget>
10751025
</widget>
10761026
</item>
10771027
</layout>

apps/opencs/model/world/data.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ CSMWorld::Data::Data(ToUTF8::FromType encoding, const Files::PathContainer& data
158158

159159
auto shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
160160

161-
osg::ref_ptr<SceneUtil::LightManager> lightManager = new SceneUtil::LightManager(SceneUtil::LightSettings{});
161+
osg::ref_ptr<SceneUtil::LightManager> lightManager
162+
= new SceneUtil::LightManager(SceneUtil::LightSettings{}, mResourceSystem.get());
162163
auto lightDefines = lightManager->getLightDefines();
163164

164165
for (const auto& define : shadowDefines)

apps/opencs/view/render/scenewidget.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include <osg/GraphicsContext>
2323
#include <osg/Group>
2424
#include <osg/Light>
25-
#include <osg/LightModel>
26-
#include <osg/LightSource>
2725
#include <osg/Material>
2826
#include <osg/Matrix>
2927
#include <osg/PrimitiveSet>
@@ -147,22 +145,17 @@ namespace CSVRender
147145

148146
mView->getCamera()->setGraphicsContext(window);
149147

150-
osg::ref_ptr<SceneUtil::LightManager> lightMgr = new SceneUtil::LightManager(SceneUtil::LightSettings{});
151-
lightMgr->setStartLight(1);
148+
osg::ref_ptr<SceneUtil::LightManager> lightMgr
149+
= new SceneUtil::LightManager(SceneUtil::LightSettings{}, resourceSystem.get());
152150
lightMgr->setLightingMask(Mask_Lighting);
153151

154-
osg::ref_ptr<osg::LightSource> source = new osg::LightSource;
155-
source->setNodeMask(Mask_Lighting);
156152
mSunLight = new osg::Light;
157-
source->setLight(mSunLight);
158153
mSunLight->setDiffuse(osg::Vec4f(0, 0, 0, 1));
159154
mSunLight->setAmbient(osg::Vec4f(0, 0, 0, 1));
160155
mSunLight->setSpecular(osg::Vec4f(0, 0, 0, 0));
161156
mSunLight->setConstantAttenuation(1.f);
162157
lightMgr->setSunlight(mSunLight);
163158

164-
lightMgr->addChild(source);
165-
166159
mRootNode = std::move(lightMgr);
167160

168161
mStateUpdater = new SceneUtil::StateUpdater();

apps/openmw/mwgui/settingswindow.cpp

Lines changed: 14 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,6 @@ namespace
6262
return "#{OMWEngine:TextureFilteringOther}";
6363
}
6464

65-
MyGUI::UString lightingMethodToStr(SceneUtil::LightingMethod method)
66-
{
67-
std::string_view result;
68-
switch (method)
69-
{
70-
case SceneUtil::LightingMethod::PerObjectUniform:
71-
result = "#{OMWEngine:LightingMethodShadersCompatibility}";
72-
break;
73-
case SceneUtil::LightingMethod::SingleUBO:
74-
default:
75-
result = "#{OMWEngine:LightingMethodShaders}";
76-
break;
77-
}
78-
79-
return MyGUI::LanguageManager::getInstance().replaceTags(MyGUI::UString(result));
80-
}
81-
8265
bool sortResolutions(std::pair<int, int> left, std::pair<int, int> right)
8366
{
8467
if (left.first == right.first)
@@ -281,7 +264,7 @@ namespace MWGui
281264
getWidget(mSecondaryLanguage, "SecondaryLanguage");
282265
getWidget(mGmstOverridesL10n, "GmstOverridesL10nButton");
283266
getWidget(mWindowModeHint, "WindowModeHint");
284-
getWidget(mLightingMethodButton, "LightingMethodButton");
267+
getWidget(mClusteredLightingButton, "ClusteredLightingButton");
285268
getWidget(mLightsResetButton, "LightsResetButton");
286269
getWidget(mMaxLights, "MaxLights");
287270
getWidget(mScriptFilter, "ScriptFilter");
@@ -290,6 +273,9 @@ namespace MWGui
290273
getWidget(mScriptView, "ScriptView");
291274
getWidget(mScriptAdapter, "ScriptAdapter");
292275
getWidget(mScriptDisabled, "ScriptDisabled");
276+
getWidget(mClassicFalloffWidget, "ClassicFalloffWidget");
277+
getWidget(mMinimumBrightnessText, "MinimumBrightnessText");
278+
getWidget(mMinimumBrightnessScroll, "MinimumBrightnessScroll");
293279

294280
#ifndef WIN32
295281
// hide gamma controls since it currently does not work under Linux
@@ -323,8 +309,6 @@ namespace MWGui
323309
mWaterRainRippleDetail->eventComboChangePosition
324310
+= MyGUI::newDelegate(this, &SettingsWindow::onWaterRainRippleDetailChanged);
325311

326-
mLightingMethodButton->eventComboChangePosition
327-
+= MyGUI::newDelegate(this, &SettingsWindow::onLightingMethodButtonChanged);
328312
mLightsResetButton->eventMouseButtonClick
329313
+= MyGUI::newDelegate(this, &SettingsWindow::onLightsResetButtonClicked);
330314
mMaxLights->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onMaxLightsChanged);
@@ -554,21 +538,6 @@ namespace MWGui
554538
apply();
555539
}
556540

557-
void SettingsWindow::onLightingMethodButtonChanged(MyGUI::ComboBox* sender, size_t pos)
558-
{
559-
if (pos == MyGUI::ITEM_NONE)
560-
return;
561-
562-
sender->setCaptionWithReplacing(sender->getItemNameAt(sender->getIndexSelected()));
563-
564-
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(
565-
"#{OMWEngine:ChangeRequiresRestart}", { "#{Interface:OK}" }, true);
566-
567-
Settings::shaders().mLightingMethod.set(
568-
Settings::parseLightingMethod(*sender->getItemDataAt<std::string>(pos)));
569-
apply();
570-
}
571-
572541
void SettingsWindow::onLanguageChanged(size_t langPriority, MyGUI::ComboBox* sender, size_t pos)
573542
{
574543
if (pos == MyGUI::ITEM_NONE)
@@ -658,11 +627,8 @@ namespace MWGui
658627
Settings::shaders().mLightFadeStart.reset();
659628
Settings::shaders().mMinimumInteriorBrightness.reset();
660629
Settings::shaders().mMaxLights.reset();
661-
Settings::shaders().mLightingMethod.reset();
630+
Settings::shaders().mClusteredLighting.reset();
662631

663-
const SceneUtil::LightingMethod lightingMethod = Settings::shaders().mLightingMethod;
664-
const std::size_t lightIndex = mLightingMethodButton->findItemIndexWith(lightingMethodToStr(lightingMethod));
665-
mLightingMethodButton->setIndexSelected(lightIndex);
666632
updateMaxLightsComboBox(mMaxLights);
667633

668634
apply();
@@ -779,6 +745,8 @@ namespace MWGui
779745
MWBase::Environment::get().getInputManager()->processChangedSettings(changed);
780746
MWBase::Environment::get().getMechanicsManager()->processChangedSettings(changed);
781747
Settings::Manager::resetPendingChanges();
748+
749+
updateLightSettings();
782750
}
783751

784752
void SettingsWindow::onKeyboardSwitchClicked(MyGUI::Widget* /*sender*/)
@@ -848,25 +816,15 @@ namespace MWGui
848816

849817
void SettingsWindow::updateLightSettings()
850818
{
851-
auto lightingMethod = MWBase::Environment::get().getResourceSystem()->getSceneManager()->getLightingMethod();
852-
MyGUI::UString lightingMethodStr = lightingMethodToStr(lightingMethod);
853-
854-
mLightingMethodButton->removeAllItems();
819+
mClusteredLightingButton->setEnabled(
820+
MWBase::Environment::get().getResourceSystem()->getSceneManager()->isClusteredLightingSupported());
855821

856-
std::array<SceneUtil::LightingMethod, 2> methods = {
857-
SceneUtil::LightingMethod::PerObjectUniform,
858-
SceneUtil::LightingMethod::SingleUBO,
859-
};
822+
const bool isClustered = Settings::shaders().mClusteredLighting;
823+
const bool isClassic = !isClustered && Settings::shaders().mClassicFalloff;
860824

861-
for (const auto& method : methods)
862-
{
863-
if (!MWBase::Environment::get().getResourceSystem()->getSceneManager()->isSupportedLightingMethod(method))
864-
continue;
865-
866-
mLightingMethodButton->addItem(
867-
lightingMethodToStr(method), SceneUtil::LightManager::getLightingMethodString(method));
868-
}
869-
mLightingMethodButton->setIndexSelected(mLightingMethodButton->findItemIndexWith(lightingMethodStr));
825+
mClassicFalloffWidget->setVisible(!isClustered);
826+
mMinimumBrightnessText->setVisible(!isClassic);
827+
mMinimumBrightnessScroll->setVisible(!isClassic);
870828
}
871829

872830
void SettingsWindow::updateWindowModeSettings()

apps/openmw/mwgui/settingswindow.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ namespace MWGui
5050
MyGUI::ComboBox* mWaterRainRippleDetail;
5151

5252
MyGUI::ComboBox* mMaxLights;
53-
MyGUI::ComboBox* mLightingMethodButton;
53+
MyGUI::Button* mClusteredLightingButton;
54+
MyGUI::Widget* mClassicFalloffWidget;
5455
MyGUI::Button* mLightsResetButton;
56+
MyGUI::Widget* mMinimumBrightnessText;
57+
MyGUI::Widget* mMinimumBrightnessScroll;
5558

5659
MyGUI::ComboBox* mPrimaryLanguage;
5760
MyGUI::ComboBox* mSecondaryLanguage;
@@ -89,7 +92,6 @@ namespace MWGui
8992
void onWaterReflectionDetailChanged(MyGUI::ComboBox* sender, size_t pos);
9093
void onWaterRainRippleDetailChanged(MyGUI::ComboBox* sender, size_t pos);
9194

92-
void onLightingMethodButtonChanged(MyGUI::ComboBox* sender, size_t pos);
9395
void onLightsResetButtonClicked(MyGUI::Widget* sender);
9496
void onMaxLightsChanged(MyGUI::ComboBox* sender, size_t pos);
9597

apps/openmw/mwrender/animation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#include "animation.hpp"
22

33
#include <algorithm>
4-
#include <iomanip>
54
#include <limits>
65

76
#include <osg/BlendFunc>
8-
#include <osg/LightModel>
97
#include <osg/Material>
108
#include <osg/Matrix>
119
#include <osg/MatrixTransform>
1210
#include <osg/Switch>
1311

12+
#include <osg/Vec4f>
1413
#include <osgParticle/ParticleProcessor>
1514
#include <osgParticle/ParticleSystem>
1615

@@ -1775,8 +1774,7 @@ namespace MWRender
17751774
if (useAmbientLight)
17761775
{
17771776
// Morrowind has a white ambient light attached to the root VFX node of the scenegraph
1778-
node->getOrCreateStateSet()->setAttributeAndModes(
1779-
getVFXLightModelInstance(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
1777+
SceneUtil::configureSunAmbientOverride(osg::Vec4f(1, 1, 1, 1), node->getOrCreateStateSet());
17801778
}
17811779

17821780
mResourceSystem->getSceneManager()->setUpNormalsRTForStateSet(node->getOrCreateStateSet(), false);

0 commit comments

Comments
 (0)