Skip to content

Commit ab77928

Browse files
author
Sarah Sunday
committed
Merge branch 'sorry_ffp_you_smell' into 'master'
Remove exclusive FFP mode Closes #7595 and #9001 See merge request OpenMW/openmw!4771
2 parents a035bca + e53536a commit ab77928

96 files changed

Lines changed: 803 additions & 1761 deletions

File tree

Some content is hidden

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

apps/components_tests/nifosg/testnifloader.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ osg::Group {
137137
UserDataContainer TRUE {
138138
osg::DefaultUserDataContainer {
139139
UniqueID 5
140-
UDC_UserObjects 3 {
140+
UDC_UserObjects 2 {
141141
osg::UIntValueObject {
142142
UniqueID 6
143143
Name "recordIndex"
@@ -149,17 +149,12 @@ osg::Group {
149149
Value ")"
150150
<< shaderPrefix << R"("
151151
}
152-
osg::BoolValueObject {
153-
UniqueID 8
154-
Name "shaderRequired"
155-
Value TRUE
156-
}
157152
}
158153
}
159154
}
160155
StateSet TRUE {
161156
osg::StateSet {
162-
UniqueID 9
157+
UniqueID 8
163158
}
164159
}
165160
}
@@ -194,7 +189,7 @@ osg::Group {
194189
UserDataContainer TRUE {
195190
osg::DefaultUserDataContainer {
196191
UniqueID 5
197-
UDC_UserObjects 3 {
192+
UDC_UserObjects 2 {
198193
osg::UIntValueObject {
199194
UniqueID 6
200195
Name "recordIndex"
@@ -206,23 +201,18 @@ osg::Group {
206201
Value ")"
207202
<< shaderPrefix << R"("
208203
}
209-
osg::BoolValueObject {
210-
UniqueID 8
211-
Name "shaderRequired"
212-
Value TRUE
213-
}
214204
}
215205
}
216206
}
217207
StateSet TRUE {
218208
osg::StateSet {
219-
UniqueID 9
209+
UniqueID 8
220210
ModeList 1 {
221211
GL_DEPTH_TEST ON
222212
}
223213
AttributeList 1 {
224214
osg::Depth {
225-
UniqueID 10
215+
UniqueID 9
226216
Function LEQUAL
227217
}
228218
Value OFF

apps/components_tests/resource/testresourcesystem.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <components/resource/resourcesystem.hpp>
22
#include <components/resource/scenemanager.hpp>
3+
#include <components/sceneutil/shadow.hpp>
34
#include <components/toutf8/toutf8.hpp>
45
#include <components/vfs/manager.hpp>
56

@@ -18,6 +19,21 @@ namespace
1819
const ToUTF8::Utf8Encoder encoder(ToUTF8::WINDOWS_1252);
1920
Resource::ResourceSystem resourceSystem(&vfsManager, 1.0, &encoder.getStatelessEncoder());
2021
Resource::SceneManager* sceneManager = resourceSystem.getSceneManager();
22+
sceneManager->setShaderPath("resources/shaders");
23+
24+
auto defines = Shader::getDefaultDefines();
25+
26+
auto shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
27+
28+
osg::ref_ptr<SceneUtil::LightManager> lightManager = new SceneUtil::LightManager(SceneUtil::LightSettings{});
29+
auto lightDefines = lightManager->getLightDefines();
30+
31+
for (const auto& define : shadowDefines)
32+
defines[define.first] = define.second;
33+
for (const auto& define : lightDefines)
34+
defines[define.first] = define.second;
35+
36+
sceneManager->getShaderManager().setGlobalDefines(defines);
2137

2238
constexpr VFS::Path::NormalizedView noSuchPath("meshes/whatever.nif");
2339
std::vector<std::thread> threads;

apps/launcher/settingspage.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,17 +331,14 @@ bool Launcher::SettingsPage::loadSettings()
331331

332332
connect(shadowDistanceCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotShadowDistLimitToggled);
333333

334-
int lightingMethod = 1;
334+
int lightingMethod = 0;
335335
switch (Settings::shaders().mLightingMethod)
336336
{
337-
case SceneUtil::LightingMethod::FFP:
338-
lightingMethod = 0;
339-
break;
340337
case SceneUtil::LightingMethod::PerObjectUniform:
341-
lightingMethod = 1;
338+
lightingMethod = 0;
342339
break;
343340
case SceneUtil::LightingMethod::SingleUBO:
344-
lightingMethod = 2;
341+
lightingMethod = 1;
345342
break;
346343
}
347344
lightingMethodComboBox->setCurrentIndex(lightingMethod);
@@ -587,8 +584,7 @@ void Launcher::SettingsPage::saveSettings()
587584
saveSettingBool(*skyBlendingCheckBox, Settings::fog().mSkyBlending);
588585
Settings::fog().mSkyBlendingStart.set(skyBlendingStartComboBox->value());
589586

590-
static constexpr std::array<SceneUtil::LightingMethod, 3> lightingMethodMap = {
591-
SceneUtil::LightingMethod::FFP,
587+
static constexpr std::array<SceneUtil::LightingMethod, 2> lightingMethodMap = {
592588
SceneUtil::LightingMethod::PerObjectUniform,
593589
SceneUtil::LightingMethod::SingleUBO,
594590
};

apps/launcher/ui/settingspage.ui

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@
536536
<property name="toolTip">
537537
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally environment map reflections aren't affected by lighting, which makes environment-mapped (and thus bump-mapped objects) glow in the dark.
538538
Morrowind Code Patch includes an option to remedy that by doing environment-mapping before applying lighting, this is the equivalent of that option.
539-
Affected objects will use shaders.
540539
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
541540
</property>
542541
<property name="text">
@@ -1047,8 +1046,7 @@
10471046
<widget class="QLabel" name="lightingMethodLabel">
10481047
<property name="toolTip">
10491048
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
1050-
&lt;p&gt; &quot;Legacy&quot; always uses 8 lights per object. It provides results most similar to Morrowind's lighting.&lt;/p&gt;
1051-
&lt;p&gt;&quot;Shaders (compatibility)&quot; removes the 8 light limit. This mode also enables lighting on groundcover. It is recommended to use this with older hardware and a light limit closer to 8.&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;
10521050
&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>
10531051
</property>
10541052
<property name="text">
@@ -1058,11 +1056,6 @@
10581056
</item>
10591057
<item row="1" column="1">
10601058
<widget class="QComboBox" name="lightingMethodComboBox">
1061-
<item>
1062-
<property name="text">
1063-
<string>Legacy</string>
1064-
</property>
1065-
</item>
10661059
<item>
10671060
<property name="text">
10681061
<string>Shaders (compatibility)</string>

apps/opencs/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ opencs_units (view/render
9292
)
9393

9494
opencs_units (view/render
95-
lighting lightingday lightingnight lightingbright object cell terrainstorage
96-
cellarrow cellmarker cellborder pathgrid
95+
object cell terrainstorage cellarrow cellmarker cellborder pathgrid
9796
)
9897

9998
opencs_hdrs (view/render

apps/opencs/model/world/data.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,17 @@ CSMWorld::Data::Data(ToUTF8::FromType encoding, const Files::PathContainer& data
152152
mResourceSystem
153153
= std::make_unique<Resource::ResourceSystem>(mVFS.get(), expiryDelay, &mEncoder.getStatelessEncoder());
154154

155-
Shader::ShaderManager::DefineMap defines
156-
= mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines();
157-
Shader::ShaderManager::DefineMap shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
158-
defines["forcePPL"] = "0"; // Don't force per-pixel lighting
159-
defines["clamp"] = "1"; // Clamp lighting
160-
defines["preLightEnv"] = "0"; // Apply environment maps after lighting like Morrowind
161-
defines["radialFog"] = "0";
162-
defines["lightingModel"] = "0";
163-
defines["reverseZ"] = "0";
164-
defines["waterRefraction"] = "0";
155+
auto defines = Shader::getDefaultDefines();
156+
157+
auto shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
158+
159+
osg::ref_ptr<SceneUtil::LightManager> lightManager = new SceneUtil::LightManager(SceneUtil::LightSettings{});
160+
auto lightDefines = lightManager->getLightDefines();
161+
165162
for (const auto& define : shadowDefines)
166163
defines[define.first] = define.second;
164+
for (const auto& define : lightDefines)
165+
defines[define.first] = define.second;
167166
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines);
168167

169168
mResourceSystem->getSceneManager()->setShaderPath(resDir / "shaders");

apps/opencs/view/render/brushdraw.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ void CSVRender::BrushDraw::update(osg::Vec3d point, int brushSize, CSVWidget::Br
259259
break;
260260
}
261261

262-
mGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
263-
264262
mBrushDrawNode->addChild(mGeometry);
265263
}
266264

apps/opencs/view/render/cellarrow.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ void CSVRender::CellArrow::buildShape()
194194

195195
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
196196

197-
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
198-
199197
mBaseNode->addChild(geometry);
200198
}
201199

apps/opencs/view/render/cellborder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ void CSVRender::CellBorder::buildShape(const ESM::Land& esmLand)
115115
primitives->setElement(VertexCount, 0);
116116

117117
mBorderGeometry->addPrimitiveSet(primitives);
118-
mBorderGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
119118

120119
mBaseNode->addChild(mBorderGeometry);
121120
}

apps/opencs/view/render/instanceselectionmode.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ namespace CSVRender
194194

195195
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
196196

197-
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
198197
geometry->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
199198
geometry->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
200199
geometry->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
@@ -292,7 +291,6 @@ namespace CSVRender
292291

293292
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
294293

295-
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
296294
geometry->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
297295
geometry->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
298296
geometry->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
@@ -393,7 +391,6 @@ namespace CSVRender
393391

394392
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
395393

396-
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
397394
geometry->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
398395
geometry->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
399396
geometry->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

0 commit comments

Comments
 (0)