Remove exclusive FFP mode

This commit is contained in:
Cody Glassman
2026-03-15 14:13:19 -05:00
committed by Sarah Sunday
parent a035bcad2a
commit e53536a3ec
96 changed files with 803 additions and 1761 deletions
+5 -15
View File
@@ -137,7 +137,7 @@ osg::Group {
UserDataContainer TRUE {
osg::DefaultUserDataContainer {
UniqueID 5
UDC_UserObjects 3 {
UDC_UserObjects 2 {
osg::UIntValueObject {
UniqueID 6
Name "recordIndex"
@@ -149,17 +149,12 @@ osg::Group {
Value ")"
<< shaderPrefix << R"("
}
osg::BoolValueObject {
UniqueID 8
Name "shaderRequired"
Value TRUE
}
}
}
}
StateSet TRUE {
osg::StateSet {
UniqueID 9
UniqueID 8
}
}
}
@@ -194,7 +189,7 @@ osg::Group {
UserDataContainer TRUE {
osg::DefaultUserDataContainer {
UniqueID 5
UDC_UserObjects 3 {
UDC_UserObjects 2 {
osg::UIntValueObject {
UniqueID 6
Name "recordIndex"
@@ -206,23 +201,18 @@ osg::Group {
Value ")"
<< shaderPrefix << R"("
}
osg::BoolValueObject {
UniqueID 8
Name "shaderRequired"
Value TRUE
}
}
}
}
StateSet TRUE {
osg::StateSet {
UniqueID 9
UniqueID 8
ModeList 1 {
GL_DEPTH_TEST ON
}
AttributeList 1 {
osg::Depth {
UniqueID 10
UniqueID 9
Function LEQUAL
}
Value OFF
@@ -1,5 +1,6 @@
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/shadow.hpp>
#include <components/toutf8/toutf8.hpp>
#include <components/vfs/manager.hpp>
@@ -18,6 +19,21 @@ namespace
const ToUTF8::Utf8Encoder encoder(ToUTF8::WINDOWS_1252);
Resource::ResourceSystem resourceSystem(&vfsManager, 1.0, &encoder.getStatelessEncoder());
Resource::SceneManager* sceneManager = resourceSystem.getSceneManager();
sceneManager->setShaderPath("resources/shaders");
auto defines = Shader::getDefaultDefines();
auto shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
osg::ref_ptr<SceneUtil::LightManager> lightManager = new SceneUtil::LightManager(SceneUtil::LightSettings{});
auto lightDefines = lightManager->getLightDefines();
for (const auto& define : shadowDefines)
defines[define.first] = define.second;
for (const auto& define : lightDefines)
defines[define.first] = define.second;
sceneManager->getShaderManager().setGlobalDefines(defines);
constexpr VFS::Path::NormalizedView noSuchPath("meshes/whatever.nif");
std::vector<std::thread> threads;
+4 -8
View File
@@ -331,17 +331,14 @@ bool Launcher::SettingsPage::loadSettings()
connect(shadowDistanceCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotShadowDistLimitToggled);
int lightingMethod = 1;
int lightingMethod = 0;
switch (Settings::shaders().mLightingMethod)
{
case SceneUtil::LightingMethod::FFP:
case SceneUtil::LightingMethod::PerObjectUniform:
lightingMethod = 0;
break;
case SceneUtil::LightingMethod::PerObjectUniform:
lightingMethod = 1;
break;
case SceneUtil::LightingMethod::SingleUBO:
lightingMethod = 2;
lightingMethod = 1;
break;
}
lightingMethodComboBox->setCurrentIndex(lightingMethod);
@@ -587,8 +584,7 @@ void Launcher::SettingsPage::saveSettings()
saveSettingBool(*skyBlendingCheckBox, Settings::fog().mSkyBlending);
Settings::fog().mSkyBlendingStart.set(skyBlendingStartComboBox->value());
static constexpr std::array<SceneUtil::LightingMethod, 3> lightingMethodMap = {
SceneUtil::LightingMethod::FFP,
static constexpr std::array<SceneUtil::LightingMethod, 2> lightingMethodMap = {
SceneUtil::LightingMethod::PerObjectUniform,
SceneUtil::LightingMethod::SingleUBO,
};
+1 -8
View File
@@ -536,7 +536,6 @@
<property name="toolTip">
<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.
Morrowind Code Patch includes an option to remedy that by doing environment-mapping before applying lighting, this is the equivalent of that option.
Affected objects will use shaders.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
@@ -1047,8 +1046,7 @@
<widget class="QLabel" name="lightingMethodLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
&lt;p&gt; &quot;Legacy&quot; always uses 8 lights per object. It provides results most similar to Morrowind's lighting.&lt;/p&gt;
&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;
&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;
&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>
</property>
<property name="text">
@@ -1058,11 +1056,6 @@
</item>
<item row="1" column="1">
<widget class="QComboBox" name="lightingMethodComboBox">
<item>
<property name="text">
<string>Legacy</string>
</property>
</item>
<item>
<property name="text">
<string>Shaders (compatibility)</string>
+1 -2
View File
@@ -92,8 +92,7 @@ opencs_units (view/render
)
opencs_units (view/render
lighting lightingday lightingnight lightingbright object cell terrainstorage
cellarrow cellmarker cellborder pathgrid
object cell terrainstorage cellarrow cellmarker cellborder pathgrid
)
opencs_hdrs (view/render
+9 -10
View File
@@ -152,18 +152,17 @@ CSMWorld::Data::Data(ToUTF8::FromType encoding, const Files::PathContainer& data
mResourceSystem
= std::make_unique<Resource::ResourceSystem>(mVFS.get(), expiryDelay, &mEncoder.getStatelessEncoder());
Shader::ShaderManager::DefineMap defines
= mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines();
Shader::ShaderManager::DefineMap shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
defines["forcePPL"] = "0"; // Don't force per-pixel lighting
defines["clamp"] = "1"; // Clamp lighting
defines["preLightEnv"] = "0"; // Apply environment maps after lighting like Morrowind
defines["radialFog"] = "0";
defines["lightingModel"] = "0";
defines["reverseZ"] = "0";
defines["waterRefraction"] = "0";
auto defines = Shader::getDefaultDefines();
auto shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
osg::ref_ptr<SceneUtil::LightManager> lightManager = new SceneUtil::LightManager(SceneUtil::LightSettings{});
auto lightDefines = lightManager->getLightDefines();
for (const auto& define : shadowDefines)
defines[define.first] = define.second;
for (const auto& define : lightDefines)
defines[define.first] = define.second;
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines);
mResourceSystem->getSceneManager()->setShaderPath(resDir / "shaders");
-2
View File
@@ -259,8 +259,6 @@ void CSVRender::BrushDraw::update(osg::Vec3d point, int brushSize, CSVWidget::Br
break;
}
mGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mBrushDrawNode->addChild(mGeometry);
}
-2
View File
@@ -194,8 +194,6 @@ void CSVRender::CellArrow::buildShape()
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mBaseNode->addChild(geometry);
}
-1
View File
@@ -115,7 +115,6 @@ void CSVRender::CellBorder::buildShape(const ESM::Land& esmLand)
primitives->setElement(VertexCount, 0);
mBorderGeometry->addPrimitiveSet(primitives);
mBorderGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mBaseNode->addChild(mBorderGeometry);
}
@@ -194,7 +194,6 @@ namespace CSVRender
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geometry->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
geometry->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
geometry->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
@@ -292,7 +291,6 @@ namespace CSVRender
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geometry->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
geometry->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
geometry->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
@@ -393,7 +391,6 @@ namespace CSVRender
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geometry->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
geometry->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
geometry->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
-72
View File
@@ -1,72 +0,0 @@
#include "lighting.hpp"
#include <string>
#include <osg/Group>
#include <osg/LightSource>
#include <osg/NodeVisitor>
#include <osg/Object>
#include <osg/Switch>
#include <osg/ValueObject>
#include <apps/opencs/model/prefs/category.hpp>
#include <apps/opencs/model/prefs/setting.hpp>
#include <components/misc/constants.hpp>
#include "../../model/prefs/state.hpp"
class DayNightSwitchVisitor : public osg::NodeVisitor
{
public:
DayNightSwitchVisitor(int index)
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
, mIndex(index)
{
}
void apply(osg::Switch& switchNode) override
{
constexpr unsigned noIndex = static_cast<unsigned>(-1);
unsigned initialIndex = noIndex;
if (!switchNode.getUserValue("initialIndex", initialIndex))
{
for (size_t i = 0; i < switchNode.getValueList().size(); ++i)
{
if (switchNode.getValueList()[i])
{
initialIndex = static_cast<unsigned>(i);
break;
}
}
if (initialIndex != noIndex)
switchNode.setUserValue("initialIndex", initialIndex);
}
if (CSMPrefs::get()["Rendering"]["scene-day-night-switch-nodes"].isTrue())
{
if (switchNode.getName() == Constants::NightDayLabel)
switchNode.setSingleChildOn(mIndex);
}
else if (initialIndex != noIndex)
{
switchNode.setSingleChildOn(initialIndex);
}
traverse(switchNode);
}
private:
int mIndex;
};
void CSVRender::Lighting::updateDayNightMode(int index)
{
if (mRootNode == nullptr)
return;
DayNightSwitchVisitor visitor(index);
mRootNode->accept(visitor);
}
-38
View File
@@ -1,38 +0,0 @@
#ifndef OPENCS_VIEW_LIGHTING_H
#define OPENCS_VIEW_LIGHTING_H
#include <osg/ref_ptr>
namespace osg
{
class Vec4f;
class LightSource;
class Group;
}
namespace CSVRender
{
class Lighting
{
public:
Lighting()
: mRootNode(nullptr)
{
}
virtual ~Lighting() = default;
virtual void activate(osg::Group* rootNode, bool isExterior) = 0;
virtual void deactivate() = 0;
virtual osg::Vec4f getAmbientColour(osg::Vec4f* defaultAmbient) = 0;
protected:
void updateDayNightMode(int index);
osg::ref_ptr<osg::LightSource> mLightSource;
osg::Group* mRootNode;
};
}
#endif
@@ -1,39 +0,0 @@
#include "lightingbright.hpp"
#include <osg/Group>
#include <osg/Light>
#include <osg/LightSource>
#include <osg/ref_ptr>
CSVRender::LightingBright::LightingBright() {}
void CSVRender::LightingBright::activate(osg::Group* rootNode, bool /*isExterior*/)
{
mRootNode = rootNode;
mLightSource = (new osg::LightSource);
osg::ref_ptr<osg::Light> light(new osg::Light);
light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
light->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f));
light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f));
light->setConstantAttenuation(1.f);
mLightSource->setLight(light);
mRootNode->addChild(mLightSource);
updateDayNightMode(0);
}
void CSVRender::LightingBright::deactivate()
{
if (mRootNode && mLightSource.get())
mRootNode->removeChild(mLightSource);
}
osg::Vec4f CSVRender::LightingBright::getAmbientColour(osg::Vec4f* /*defaultAmbient*/)
{
return osg::Vec4f(1.f, 1.f, 1.f, 1.f);
}
@@ -1,28 +0,0 @@
#ifndef OPENCS_VIEW_LIGHTING_BRIGHT_H
#define OPENCS_VIEW_LIGHTING_BRIGHT_H
#include "lighting.hpp"
#include <osg/Vec4f>
namespace osg
{
class Group;
}
namespace CSVRender
{
class LightingBright : public Lighting
{
public:
LightingBright();
void activate(osg::Group* rootNode, bool /*isExterior*/) override;
void deactivate() override;
osg::Vec4f getAmbientColour(osg::Vec4f* defaultAmbient) override;
};
}
#endif
-39
View File
@@ -1,39 +0,0 @@
#include "lightingday.hpp"
#include <osg/Group>
#include <osg/Light>
#include <osg/LightSource>
#include <osg/ref_ptr>
void CSVRender::LightingDay::activate(osg::Group* rootNode, bool /*isExterior*/)
{
mRootNode = rootNode;
mLightSource = new osg::LightSource;
osg::ref_ptr<osg::Light> light(new osg::Light);
light->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f));
light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f));
light->setConstantAttenuation(1.f);
mLightSource->setLight(light);
mRootNode->addChild(mLightSource);
updateDayNightMode(0);
}
void CSVRender::LightingDay::deactivate()
{
if (mRootNode && mLightSource.get())
mRootNode->removeChild(mLightSource);
}
osg::Vec4f CSVRender::LightingDay::getAmbientColour(osg::Vec4f* defaultAmbient)
{
if (defaultAmbient)
return *defaultAmbient;
else
return osg::Vec4f(0.7f, 0.7f, 0.7f, 1.f);
}
-28
View File
@@ -1,28 +0,0 @@
#ifndef OPENCS_VIEW_LIGHTING_DAY_H
#define OPENCS_VIEW_LIGHTING_DAY_H
#include "lighting.hpp"
#include <osg/Vec4f>
namespace osg
{
class Group;
}
namespace CSVRender
{
class LightingDay : public Lighting
{
public:
LightingDay() = default;
void activate(osg::Group* rootNode, bool /*isExterior*/) override;
void deactivate() override;
osg::Vec4f getAmbientColour(osg::Vec4f* defaultAmbient) override;
};
}
#endif
-40
View File
@@ -1,40 +0,0 @@
#include "lightingnight.hpp"
#include <osg/Group>
#include <osg/Light>
#include <osg/LightSource>
#include <osg/ref_ptr>
void CSVRender::LightingNight::activate(osg::Group* rootNode, bool isExterior)
{
mRootNode = rootNode;
mLightSource = new osg::LightSource;
osg::ref_ptr<osg::Light> light(new osg::Light);
light->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f));
light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
light->setDiffuse(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f));
light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f));
light->setConstantAttenuation(1.f);
mLightSource->setLight(light);
mRootNode->addChild(mLightSource);
updateDayNightMode(isExterior ? 1 : 0);
}
void CSVRender::LightingNight::deactivate()
{
if (mRootNode && mLightSource.get())
mRootNode->removeChild(mLightSource);
}
osg::Vec4f CSVRender::LightingNight::getAmbientColour(osg::Vec4f* defaultAmbient)
{
if (defaultAmbient)
return *defaultAmbient;
else
return osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f);
}
-27
View File
@@ -1,27 +0,0 @@
#ifndef OPENCS_VIEW_LIGHTING_NIGHT_H
#define OPENCS_VIEW_LIGHTING_NIGHT_H
#include "lighting.hpp"
#include <osg/Vec4f>
namespace osg
{
class Group;
}
namespace CSVRender
{
class LightingNight : public Lighting
{
public:
LightingNight() = default;
void activate(osg::Group* rootNode, bool isExterior) override;
void deactivate() override;
osg::Vec4f getAmbientColour(osg::Vec4f* defaultAmbient) override;
};
}
#endif
+25 -26
View File
@@ -8,6 +8,10 @@
#include <string>
#include <utility>
#include <osg/PolygonMode>
#include <osg/PolygonOffset>
#include <osg/ShapeDrawable>
#include <apps/opencs/model/prefs/category.hpp>
#include <apps/opencs/model/prefs/setting.hpp>
#include <apps/opencs/model/world/columns.hpp>
@@ -18,11 +22,7 @@
#include <apps/opencs/model/world/universalid.hpp>
#include <apps/opencs/view/render/tagbase.hpp>
#include <osg/Quat>
#include <osg/ShapeDrawable>
#include <osgFX/Scribe>
#include "../../model/prefs/state.hpp"
#include "../../model/world/cellcoordinates.hpp"
#include "../../model/world/commandmacro.hpp"
#include "../../model/world/commands.hpp"
@@ -35,6 +35,7 @@
#include <components/sceneutil/lightcommon.hpp>
#include <components/sceneutil/lightmanager.hpp>
#include <components/sceneutil/lightutil.hpp>
#include <components/shader/shadermanager.hpp>
#include "actor.hpp"
#include "mask.hpp"
@@ -191,11 +192,23 @@ CSVRender::Object::Object(
mBaseNode = new osg::PositionAttitudeTransform;
mBaseNode->addCullCallback(new SceneUtil::LightListCallback);
mOutline = new osgFX::Scribe;
mOutline = new osg::Group;
mOutline->setNodeMask(0);
osg::ref_ptr<osg::PolygonOffset> offset = new osg::PolygonOffset(1, 1);
osg::ref_ptr<osg::PolygonMode> mode
= new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
mOutline->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4f(1, 1, 1, 1)));
mOutline->getStateSet()->setAttributeAndModes(mode);
mOutline->getStateSet()->setAttributeAndModes(offset);
mOutline->getStateSet()->setAttributeAndModes(
mResourceSystem->getSceneManager()->getShaderManager().getProgram("outline"),
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED);
mOutline->addChild(mBaseNode);
mBaseNode->setUserData(new ObjectTag(this));
mRootNode->addChild(mBaseNode);
mRootNode->addChild(mOutline);
parentNode->addChild(mRootNode);
@@ -231,17 +244,10 @@ void CSVRender::Object::setSelected(bool selected, const osg::Vec4f& color)
setSnapTarget(false);
}
mOutline->removeChild(mBaseNode);
mRootNode->removeChild(mOutline);
mRootNode->removeChild(mBaseNode);
mOutline->setNodeMask(selected ? ~0u : 0);
if (selected)
{
mOutline->setWireframeColor(color);
mOutline->addChild(mBaseNode);
mRootNode->addChild(mOutline);
}
else
mRootNode->addChild(mBaseNode);
mOutline->getStateSet()->getUniform("color")->set(color);
}
bool CSVRender::Object::getSelected() const
@@ -258,17 +264,10 @@ void CSVRender::Object::setSnapTarget(bool isSnapTarget)
setSelected(false);
}
mOutline->removeChild(mBaseNode);
mRootNode->removeChild(mOutline);
mRootNode->removeChild(mBaseNode);
mOutline->setNodeMask(isSnapTarget ? ~0u : 0);
if (isSnapTarget)
{
mOutline->setWireframeColor(osg::Vec4f(1, 1, 0, 1));
mOutline->addChild(mBaseNode);
mRootNode->addChild(mOutline);
}
else
mRootNode->addChild(mBaseNode);
mOutline->getStateSet()->getUniform("color")->set(osg::Vec4f(1, 1, 0, 1));
}
bool CSVRender::Object::getSnapTarget() const
+1 -6
View File
@@ -23,11 +23,6 @@ namespace osg
class Node;
}
namespace osgFX
{
class Scribe;
}
namespace Resource
{
class ResourceSystem;
@@ -89,7 +84,7 @@ namespace CSVRender
ESM::RefId mReferenceableId;
osg::ref_ptr<osg::PositionAttitudeTransform> mRootNode;
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
osg::ref_ptr<osgFX::Scribe> mOutline;
osg::ref_ptr<osg::Group> mOutline;
bool mSelected{ false };
bool mSnapTarget{ false };
osg::Group* mParentNode;
+1
View File
@@ -97,6 +97,7 @@ namespace CSVRender
auto markerData = file.readAll();
mResourceSystem->getSceneManager()->loadSelectionMarker(mBaseNode, markerData.data(), markerData.size());
mResourceSystem->getSceneManager()->recreateShaders(mBaseNode);
osg::ref_ptr<osg::StateSet> baseNodeState = mBaseNode->getOrCreateStateSet();
baseNodeState->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
-1
View File
@@ -637,7 +637,6 @@ namespace CSVRender
mDragGeometry->setVertexArray(vertices);
mDragGeometry->setColorArray(colors, osg::Array::BIND_OVERALL);
mDragGeometry->addPrimitiveSet(indices);
mDragGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mPathgridGroup->addChild(mDragGeometry);
}
+143 -39
View File
@@ -10,9 +10,6 @@
#include <apps/opencs/model/prefs/category.hpp>
#include <apps/opencs/model/prefs/setting.hpp>
#include <apps/opencs/view/render/lightingbright.hpp>
#include <apps/opencs/view/render/lightingday.hpp>
#include <apps/opencs/view/render/lightingnight.hpp>
#include <osgQt/CompositeOsgRenderer.hpp>
#include <osgQt/osgQOpenGLWidget.hpp>
@@ -24,7 +21,9 @@
#include <osg/Geometry>
#include <osg/GraphicsContext>
#include <osg/Group>
#include <osg/Light>
#include <osg/LightModel>
#include <osg/LightSource>
#include <osg/Material>
#include <osg/Matrix>
#include <osg/PrimitiveSet>
@@ -46,10 +45,13 @@
#include <osgViewer/ViewerEventHandlers>
#include <components/debug/debuglog.hpp>
#include <components/misc/constants.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/glextensions.hpp>
#include <components/sceneutil/lightmanager.hpp>
#include <components/sceneutil/stateupdater.hpp>
#include <components/shader/removedalphafunc.hpp>
#include "../widget/scenetoolmode.hpp"
@@ -57,18 +59,66 @@
#include "../../model/prefs/state.hpp"
#include "cameracontroller.hpp"
#include "lighting.hpp"
#include "mask.hpp"
namespace
{
class DayNightSwitchVisitor : public osg::NodeVisitor
{
public:
DayNightSwitchVisitor(int index)
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
, mIndex(index)
{
}
void apply(osg::Switch& switchNode) override
{
constexpr unsigned noIndex = static_cast<unsigned>(-1);
unsigned initialIndex = noIndex;
if (!switchNode.getUserValue("initialIndex", initialIndex))
{
for (size_t i = 0; i < switchNode.getValueList().size(); ++i)
{
if (switchNode.getValueList()[i])
{
initialIndex = static_cast<unsigned>(i);
break;
}
}
if (initialIndex != noIndex)
switchNode.setUserValue("initialIndex", initialIndex);
}
if (CSMPrefs::get()["Rendering"]["scene-day-night-switch-nodes"].isTrue())
{
if (switchNode.getName() == Constants::NightDayLabel)
switchNode.setSingleChildOn(mIndex);
}
else if (initialIndex != noIndex)
{
switchNode.setSingleChildOn(initialIndex);
}
traverse(switchNode);
}
private:
int mIndex;
};
}
namespace CSVRender
{
RenderWidget::RenderWidget(QWidget* parent, Qt::WindowFlags f)
RenderWidget::RenderWidget(
std::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f)
, mRootNode(nullptr)
{
mView = new osgViewer::View;
updateCameraParameters(width() / static_cast<double>(height()));
mWidget = new osgQOpenGLWidget(this);
@@ -97,15 +147,45 @@ namespace CSVRender
mView->getCamera()->setGraphicsContext(window);
osg::ref_ptr<SceneUtil::LightManager> lightMgr = new SceneUtil::LightManager;
osg::ref_ptr<SceneUtil::LightManager> lightMgr = new SceneUtil::LightManager(SceneUtil::LightSettings{});
lightMgr->setStartLight(1);
lightMgr->setLightingMask(Mask_Lighting);
osg::ref_ptr<osg::LightSource> source = new osg::LightSource;
source->setNodeMask(Mask_Lighting);
mSunLight = new osg::Light;
source->setLight(mSunLight);
mSunLight->setDiffuse(osg::Vec4f(0, 0, 0, 1));
mSunLight->setAmbient(osg::Vec4f(0, 0, 0, 1));
mSunLight->setSpecular(osg::Vec4f(0, 0, 0, 0));
mSunLight->setConstantAttenuation(1.f);
lightMgr->setSunlight(mSunLight);
lightMgr->addChild(source);
mRootNode = std::move(lightMgr);
mStateUpdater = new SceneUtil::StateUpdater();
mRootNode->addUpdateCallback(mStateUpdater);
mSharedUniformStateUpdater = new SceneUtil::SharedUniformStateUpdater(1.0);
mRootNode->addUpdateCallback(mSharedUniformStateUpdater);
mPerViewUniformStateUpdater = new SceneUtil::PerViewUniformStateUpdater(resourceSystem->getSceneManager());
mRootNode->addCullCallback(mPerViewUniformStateUpdater);
mRootNode->getOrCreateStateSet()->setAttribute(Shader::RemovedAlphaFunc::getInstance(GL_ALWAYS));
mRootNode->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF);
mRootNode->getOrCreateStateSet()->setMode(
GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED | osg::StateAttribute::OVERRIDE);
mView->getCamera()->setViewport(new osg::Viewport(0, 0, width(), height()));
mView->getCamera()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
mView->getCamera()->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
mView->getCamera()->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
mView->getCamera()->setName(Constants::SceneCamera);
osg::ref_ptr<osg::Material> defaultMat(new osg::Material);
defaultMat->setColorMode(osg::Material::OFF);
defaultMat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4f(1, 1, 1, 1));
@@ -120,6 +200,8 @@ namespace CSVRender
mRenderer->addView(mView);
mRenderer->setDone(false);
updateCameraParameters(width() / static_cast<double>(height()));
}
RenderWidget::~RenderWidget()
@@ -163,9 +245,8 @@ namespace CSVRender
SceneWidget::SceneWidget(std::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget* parent,
Qt::WindowFlags f, bool retrieveInput)
: RenderWidget(parent, f)
, mResourceSystem(std::move(resourceSystem))
, mLighting(nullptr)
: RenderWidget(resourceSystem, parent, f)
, mResourceSystem(resourceSystem)
, mHasDefaultAmbient(false)
, mIsExterior(true)
, mCamPositionSet(false)
@@ -197,7 +278,7 @@ namespace CSVRender
// we handle lighting manually
mView->setLightingMode(osgViewer::View::NO_LIGHT);
setLighting(&mLightingDay);
setLighting(LightingMode::Day);
mResourceSystem->getSceneManager()->setParticleSystemMask(Mask_ParticleSystem);
@@ -268,7 +349,6 @@ namespace CSVRender
geometry->setColorArray(colours, osg::Array::BIND_PER_VERTEX);
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geometry->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
return geometry;
@@ -303,31 +383,40 @@ namespace CSVRender
mGradientCamera->setChild(0, gradientRect.get());
}
void SceneWidget::setLighting(Lighting* lighting)
void SceneWidget::setLighting(LightingMode mode)
{
if (mLighting)
mLighting->deactivate();
int index = 0;
switch (mode)
{
case LightingMode::Day:
mSunLight->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f));
mSunLight->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
mSunLight->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
mStateUpdater->setAmbientColor(
mHasDefaultAmbient ? mDefaultAmbient : osg::Vec4f(0.7f, 0.7f, 0.7f, 1.f));
break;
case LightingMode::Night:
mSunLight->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f));
mSunLight->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
mSunLight->setDiffuse(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f));
mStateUpdater->setAmbientColor(
mHasDefaultAmbient ? mDefaultAmbient : osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f));
index = mIsExterior ? 1 : 0;
break;
case LightingMode::Bright:
mSunLight->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f));
mSunLight->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
mSunLight->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
mStateUpdater->setAmbientColor(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
break;
}
mLighting = lighting;
mLighting->activate(mRootNode, mIsExterior);
osg::Vec4f ambient = mLighting->getAmbientColour(mHasDefaultAmbient ? &mDefaultAmbient : nullptr);
setAmbient(ambient);
DayNightSwitchVisitor visitor(index);
mRootNode->accept(visitor);
flagAsModified();
}
void SceneWidget::setAmbient(const osg::Vec4f& ambient)
{
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
osg::ref_ptr<osg::LightModel> lightmodel = new osg::LightModel;
lightmodel->setAmbientIntensity(ambient);
stateset->setMode(GL_LIGHTING, osg::StateAttribute::ON);
stateset->setMode(GL_LIGHT0, osg::StateAttribute::ON);
stateset->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
mRootNode->setStateSet(stateset);
}
void SceneWidget::selectLightingMode(const std::string& mode)
{
QColor backgroundColour;
@@ -336,19 +425,19 @@ namespace CSVRender
{
backgroundColour = CSMPrefs::get()["Rendering"]["scene-day-background-colour"].toColor();
gradientColour = CSMPrefs::get()["Rendering"]["scene-day-gradient-colour"].toColor();
setLighting(&mLightingDay);
setLighting(LightingMode::Day);
}
else if (mode == "night")
{
backgroundColour = CSMPrefs::get()["Rendering"]["scene-night-background-colour"].toColor();
gradientColour = CSMPrefs::get()["Rendering"]["scene-night-gradient-colour"].toColor();
setLighting(&mLightingNight);
setLighting(LightingMode::Night);
}
else if (mode == "bright")
{
backgroundColour = CSMPrefs::get()["Rendering"]["scene-bright-background-colour"].toColor();
gradientColour = CSMPrefs::get()["Rendering"]["scene-bright-gradient-colour"].toColor();
setLighting(&mLightingBright);
setLighting(LightingMode::Bright);
}
if (CSMPrefs::get()["Rendering"]["scene-use-gradient"].isTrue())
{
@@ -417,8 +506,6 @@ namespace CSVRender
{
mDefaultAmbient = colour;
mHasDefaultAmbient = true;
setAmbient(mLighting->getAmbientColour(&mDefaultAmbient));
}
void SceneWidget::setExterior(bool isExterior)
@@ -439,6 +526,16 @@ namespace CSVRender
mCurrentCamControl->handleMouseScrollEvent(event->angleDelta().y());
}
void SceneWidget::resizeEvent(QResizeEvent* event)
{
updateCameraParameters(width() / static_cast<double>(height()));
}
void SceneWidget::showEvent(QShowEvent* event)
{
updateCameraParameters(width() / static_cast<double>(height()));
}
void SceneWidget::update(double dt)
{
if (mCamPositionSet)
@@ -541,15 +638,14 @@ namespace CSVRender
}
else if (*setting == "Rendering/scene-day-night-switch-nodes")
{
if (mLighting)
setLighting(mLighting);
setLighting(mLightingMode);
}
}
void RenderWidget::updateCameraParameters(double overrideAspect)
{
const float nearDist = 1.0;
const float farDist = 1000.0;
const float farDist = 8192.0 * 100;
if (CSMPrefs::get()["Rendering"]["camera-ortho"].isTrue())
{
@@ -565,6 +661,14 @@ namespace CSVRender
mView->getCamera()->setProjectionMatrixAsPerspective(CSMPrefs::get()["Rendering"]["camera-fov"].toInt(),
static_cast<double>(width()) / static_cast<double>(height()), nearDist, farDist);
}
mSharedUniformStateUpdater->setScreenRes(width(), height());
mSharedUniformStateUpdater->setNear(nearDist);
mSharedUniformStateUpdater->setFar(farDist);
mPerViewUniformStateUpdater->setProjectionMatrix(mView->getCamera()->getProjectionMatrix());
mStateUpdater->setFogStart(nearDist);
mStateUpdater->setFogEnd(farDist);
}
void SceneWidget::selectNavigationMode(const std::string& mode)
+30 -14
View File
@@ -15,12 +15,10 @@
#include <osgViewer/CompositeViewer>
#include "lightingbright.hpp"
#include "lightingday.hpp"
#include "lightingnight.hpp"
class QMouseEvent;
class QWheelEvent;
class QResizeEvent;
class QShowEvent;
class osgQOpenGLWidget;
class CompositeOsgRenderer;
@@ -35,6 +33,7 @@ namespace osg
class Group;
class Camera;
class Geometry;
class Light;
}
namespace osg
@@ -53,19 +52,26 @@ namespace CSMPrefs
class Setting;
}
namespace SceneUtil
{
class PerViewUniformStateUpdater;
class SharedUniformStateUpdater;
class StateUpdater;
}
namespace CSVRender
{
class CameraController;
class FreeCameraController;
class OrbitCameraController;
class Lighting;
class RenderWidget : public QWidget
{
Q_OBJECT
public:
RenderWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
RenderWidget(std::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::WindowFlags());
virtual ~RenderWidget();
/// Initiates a request to redraw the view
@@ -80,6 +86,13 @@ namespace CSVRender
CompositeOsgRenderer* mRenderer;
osg::ref_ptr<osgViewer::View> mView;
osg::ref_ptr<osg::Group> mRootNode;
osg::ref_ptr<osg::Light> mSunLight;
std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
osg::ref_ptr<SceneUtil::StateUpdater> mStateUpdater;
osg::ref_ptr<SceneUtil::SharedUniformStateUpdater> mSharedUniformStateUpdater;
osg::ref_ptr<SceneUtil::PerViewUniformStateUpdater> mPerViewUniformStateUpdater;
void updateCameraParameters(double overrideAspect = -1.0);
@@ -112,13 +125,21 @@ namespace CSVRender
}
protected:
void setLighting(Lighting* lighting);
///< \attention The ownership of \a lighting is not transferred to *this.
enum LightingMode
{
Bright,
Night,
Day
};
void setAmbient(const osg::Vec4f& ambient);
LightingMode mLightingMode = LightingMode::Day;
void setLighting(LightingMode mode);
void mouseMoveEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void showEvent(QShowEvent* event) override;
osg::ref_ptr<osg::Geometry> createGradientRectangle(QColor& bgColour, QColor& gradientColour);
osg::ref_ptr<osg::Camera> createGradientCamera(QColor& bgColour, QColor& gradientColour);
@@ -126,16 +147,11 @@ namespace CSVRender
std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
Lighting* mLighting;
osg::ref_ptr<osg::PositionAttitudeTransform> mSelectionMarkerNode;
osg::ref_ptr<osg::Camera> mGradientCamera;
osg::Vec4f mDefaultAmbient;
bool mHasDefaultAmbient;
bool mIsExterior;
LightingDay mLightingDay;
LightingNight mLightingNight;
LightingBright mLightingBright;
QPointF mPrevMouse;
+1 -2
View File
@@ -807,7 +807,6 @@ void OMW::Engine::prepareEngine()
mResourceSystem->getSceneManager()->setShaderPath(mResDir / "shaders");
osg::GLExtensions& exts = SceneUtil::getGLExtensions();
bool shadersSupported = exts.glslLanguageVersion >= 1.2f;
#if OSG_VERSION_LESS_THAN(3, 6, 6)
// hack fix for https://github.com/openscenegraph/OpenSceneGraph/issues/1028
@@ -823,7 +822,7 @@ void OMW::Engine::prepareEngine()
mWindowManager = std::make_unique<MWGui::WindowManager>(mWindow, mViewer, guiRoot, mResourceSystem.get(),
mWorkQueue.get(), mCfgMgr.getLogPath(), mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts,
Version::getOpenmwVersionDescription(), shadersSupported, mCfgMgr);
Version::getOpenmwVersionDescription(), mCfgMgr);
mEnvironment.setWindowManager(*mWindowManager);
mInputManager = std::make_unique<MWInput::InputManager>(mWindow, mViewer, mScreenCaptureHandler, keybinderUser,
+1 -5
View File
@@ -67,9 +67,6 @@ namespace
std::string_view result;
switch (method)
{
case SceneUtil::LightingMethod::FFP:
result = "#{OMWEngine:LightingMethodLegacy}";
break;
case SceneUtil::LightingMethod::PerObjectUniform:
result = "#{OMWEngine:LightingMethodShadersCompatibility}";
break;
@@ -855,8 +852,7 @@ namespace MWGui
mLightingMethodButton->removeAllItems();
std::array<SceneUtil::LightingMethod, 3> methods = {
SceneUtil::LightingMethod::FFP,
std::array<SceneUtil::LightingMethod, 2> methods = {
SceneUtil::LightingMethod::PerObjectUniform,
SceneUtil::LightingMethod::SingleUBO,
};
+2 -3
View File
@@ -150,7 +150,7 @@ namespace MWGui
WindowManager::WindowManager(SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot,
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::filesystem::path& logpath,
bool consoleOnlyScripts, Translation::Storage& translationDataStorage, ToUTF8::FromType encoding,
bool exportFonts, const std::string& versionDescription, bool useShaders, Files::ConfigurationManager& cfgMgr)
bool exportFonts, const std::string& versionDescription, Files::ConfigurationManager& cfgMgr)
: mOldUpdateMask(0)
, mOldCullMask(0)
, mStore(nullptr)
@@ -304,8 +304,7 @@ namespace MWGui
mVideoWrapper = std::make_unique<SDLUtil::VideoWrapper>(window, viewer);
mVideoWrapper->setGammaContrast(Settings::video().mGamma, Settings::video().mContrast);
if (useShaders)
mGuiPlatform->getRenderManagerPtr()->enableShaders(mResourceSystem->getSceneManager()->getShaderManager());
mGuiPlatform->getRenderManagerPtr()->enableShaders(mResourceSystem->getSceneManager()->getShaderManager());
mStatsWatcher = std::make_unique<StatsWatcher>();
}
+1 -1
View File
@@ -130,7 +130,7 @@ namespace MWGui
WindowManager(SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot,
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
const std::filesystem::path& logpath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, bool useShaders,
ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription,
Files::ConfigurationManager& cfgMgr);
virtual ~WindowManager();
+2 -19
View File
@@ -9,7 +9,6 @@
#include <osg/LightSource>
#include <osg/Material>
#include <osg/PositionAttitudeTransform>
#include <osg/TexEnvCombine>
#include <osg/Texture2D>
#include <osg/ValueObject>
#include <osgUtil/IntersectionVisitor>
@@ -237,7 +236,6 @@ namespace MWRender
lightManager->setStartLight(1);
osg::ref_ptr<osg::StateSet> stateset = lightManager->getOrCreateStateSet();
stateset->setDefine("FORCE_OPAQUE", "1", osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING, osg::StateAttribute::ON);
stateset->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
osg::ref_ptr<osg::Material> defaultMat(new osg::Material);
@@ -264,13 +262,6 @@ namespace MWRender
stateset->addUniform(new osg::Uniform("emissiveMult", 1.f));
// Opaque stuff must have 1 as its fragment alpha as the FBO is translucent, so having blending off isn't enough
osg::ref_ptr<osg::TexEnvCombine> noBlendAlphaEnv = new osg::TexEnvCombine();
noBlendAlphaEnv->setCombine_Alpha(osg::TexEnvCombine::REPLACE);
noBlendAlphaEnv->setSource0_Alpha(osg::TexEnvCombine::CONSTANT);
noBlendAlphaEnv->setConstantColor(osg::Vec4(0.0, 0.0, 0.0, 1.0));
noBlendAlphaEnv->setCombine_RGB(osg::TexEnvCombine::REPLACE);
noBlendAlphaEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
osg::ref_ptr<osg::Texture2D> dummyTexture = new osg::Texture2D();
dummyTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
dummyTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
@@ -280,7 +271,6 @@ namespace MWRender
dummyTexture->setShadowComparison(true);
dummyTexture->setShadowCompareFunc(osg::Texture::ShadowCompareFunc::ALWAYS);
stateset->setTextureAttributeAndModes(7, dummyTexture, osg::StateAttribute::ON);
stateset->setTextureAttribute(7, noBlendAlphaEnv, osg::StateAttribute::ON);
osg::ref_ptr<osg::LightModel> lightmodel = new osg::LightModel;
lightmodel->setAmbientIntensity(osg::Vec4(0.0, 0.0, 0.0, 1.0));
@@ -301,15 +291,8 @@ namespace MWRender
light->setPosition(osg::Vec4(positionX, positionY, positionZ, 0.0));
light->setDiffuse(osg::Vec4(diffuseR, diffuseG, diffuseB, 1));
osg::Vec4 ambientRGBA = osg::Vec4(ambientR, ambientG, ambientB, 1);
if (mResourceSystem->getSceneManager()->getForceShaders())
{
// When using shaders, we now skip the ambient sun calculation as this is the only place it's used.
// Using the scene ambient will give identical results.
lightmodel->setAmbientIntensity(ambientRGBA);
light->setAmbient(osg::Vec4(0, 0, 0, 1));
}
else
light->setAmbient(ambientRGBA);
lightmodel->setAmbientIntensity(ambientRGBA);
light->setAmbient(osg::Vec4(0, 0, 0, 1));
light->setSpecular(osg::Vec4(0, 0, 0, 0));
light->setLightNum(0);
light->setConstantAttenuation(1.f);
-6
View File
@@ -3,7 +3,6 @@
#include <osg/Geometry>
#include <osg/Group>
#include <osg/Image>
#include <osg/TexEnvCombine>
#include <osg/Texture2D>
#include <osgDB/WriteFile>
@@ -365,7 +364,6 @@ namespace MWRender
osg::StateSet* stateset = geom->getOrCreateStateSet();
stateset->setAttribute(depth);
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
if (mAlphaTexture)
@@ -383,10 +381,6 @@ namespace MWRender
geom->setTexCoordArray(1, texcoords, osg::Array::BIND_PER_VERTEX);
stateset->setTextureAttributeAndModes(1, mAlphaTexture, osg::StateAttribute::ON);
osg::ref_ptr<osg::TexEnvCombine> texEnvCombine = new osg::TexEnvCombine;
texEnvCombine->setCombine_RGB(osg::TexEnvCombine::REPLACE);
texEnvCombine->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
stateset->setTextureAttributeAndModes(1, texEnvCombine);
}
camera->addChild(geom);
+2 -2
View File
@@ -455,9 +455,9 @@ namespace MWRender
group->setStateSet(mStateset);
group->setNodeMask(Mask_Groundcover);
if (mSceneManager->getLightingMethod() != SceneUtil::LightingMethod::FFP)
if (Settings::groundcover().mPointLighting)
group->addCullCallback(new SceneUtil::LightListCallback);
mSceneManager->recreateShaders(group, "groundcover", true, mProgramTemplate);
mSceneManager->recreateShaders(group, "groundcover", mProgramTemplate);
mSceneManager->shareState(group);
group->getBound();
return group;
-1
View File
@@ -39,7 +39,6 @@ namespace MWRender
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
stateSet->setAttributeAndModes(lineWidth);
stateSet->setAttributeAndModes(blendFunc);
-1
View File
@@ -322,7 +322,6 @@ namespace MWRender
mStateSet = new osg::StateSet;
mStateSet->setAttributeAndModes(new osg::ColorMask(false, false, false, false), osg::StateAttribute::ON);
mStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
}
void drawImplementation(
-1
View File
@@ -141,7 +141,6 @@ namespace MWRender
mHUDCamera->setAllowEventFocus(false);
mHUDCamera->setViewport(0, 0, mWidth, mHeight);
mHUDCamera->setNodeMask(Mask_RenderToTexture);
mHUDCamera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mHUDCamera->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
mHUDCamera->addChild(mCanvases[0]);
mHUDCamera->addChild(mCanvases[1]);
+1 -12
View File
@@ -17,22 +17,11 @@
namespace MWRender
{
namespace
{
osg::ref_ptr<osg::StateSet> makeDebugDrawStateSet()
{
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
return stateSet;
}
}
RecastMesh::RecastMesh(const osg::ref_ptr<osg::Group>& root, bool enabled)
: mRootNode(root)
, mEnabled(enabled)
, mGroupStateSet(SceneUtil::makeDetourGroupStateSet())
, mDebugDrawStateSet(makeDebugDrawStateSet())
, mDebugDrawStateSet(new osg::StateSet)
{
}
+15 -257
View File
@@ -5,12 +5,9 @@
#include <osg/ClipControl>
#include <osg/ComputeBoundsVisitor>
#include <osg/Fog>
#include <osg/Group>
#include <osg/Light>
#include <osg/LightModel>
#include <osg/Material>
#include <osg/PolygonMode>
#include <osg/UserDataContainer>
#include <osgUtil/LineSegmentIntersector>
@@ -37,9 +34,8 @@
#include <components/sceneutil/depth.hpp>
#include <components/sceneutil/lightmanager.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include <components/sceneutil/rtt.hpp>
#include <components/sceneutil/shadow.hpp>
#include <components/sceneutil/statesetupdater.hpp>
#include <components/sceneutil/stateupdater.hpp>
#include <components/sceneutil/visitor.hpp>
#include <components/sceneutil/workqueue.hpp>
#include <components/sceneutil/writescene.hpp>
@@ -89,188 +85,6 @@
namespace MWRender
{
class PerViewUniformStateUpdater final : public SceneUtil::StateSetUpdater
{
public:
PerViewUniformStateUpdater(Resource::SceneManager* sceneManager)
: mSceneManager(sceneManager)
{
mOpaqueTextureUnit = mSceneManager->getShaderManager().reserveGlobalTextureUnits(
Shader::ShaderManager::Slot::OpaqueDepthTexture);
}
void setDefaults(osg::StateSet* stateset) override
{
stateset->addUniform(new osg::Uniform("projectionMatrix", osg::Matrixf{}));
if (mSkyRTT)
stateset->addUniform(new osg::Uniform("sky", mSkyTextureUnit));
}
void apply(osg::StateSet* stateset, osg::NodeVisitor* nv) override
{
stateset->getUniform("projectionMatrix")->set(mProjectionMatrix);
if (mSkyRTT && nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
{
osg::Texture* skyTexture = mSkyRTT->getColorTexture(static_cast<osgUtil::CullVisitor*>(nv));
stateset->setTextureAttribute(
mSkyTextureUnit, skyTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
stateset->setTextureAttribute(mOpaqueTextureUnit,
mSceneManager->getOpaqueDepthTex(nv->getTraversalNumber()), osg::StateAttribute::ON);
}
void applyLeft(osg::StateSet* stateset, osgUtil::CullVisitor* nv) override
{
stateset->getUniform("projectionMatrix")->set(getEyeProjectionMatrix(0));
}
void applyRight(osg::StateSet* stateset, osgUtil::CullVisitor* nv) override
{
stateset->getUniform("projectionMatrix")->set(getEyeProjectionMatrix(1));
}
void setProjectionMatrix(const osg::Matrixf& projectionMatrix) { mProjectionMatrix = projectionMatrix; }
const osg::Matrixf& getProjectionMatrix() const { return mProjectionMatrix; }
void enableSkyRTT(int skyTextureUnit, SceneUtil::RTTNode* skyRTT)
{
mSkyTextureUnit = skyTextureUnit;
mSkyRTT = skyRTT;
}
private:
osg::Matrixf getEyeProjectionMatrix(int view)
{
return Stereo::Manager::instance().computeEyeProjection(view, SceneUtil::AutoDepth::isReversed());
}
osg::Matrixf mProjectionMatrix;
int mSkyTextureUnit = -1;
SceneUtil::RTTNode* mSkyRTT = nullptr;
Resource::SceneManager* mSceneManager;
int mOpaqueTextureUnit = -1;
};
class SharedUniformStateUpdater : public SceneUtil::StateSetUpdater
{
public:
SharedUniformStateUpdater()
: mNear(0.f)
, mFar(0.f)
, mWindSpeed(0.f)
, mSkyBlendingStartCoef(Settings::fog().mSkyBlendingStart)
{
}
void setDefaults(osg::StateSet* stateset) override
{
stateset->addUniform(new osg::Uniform("near", 0.f));
stateset->addUniform(new osg::Uniform("far", 0.f));
stateset->addUniform(new osg::Uniform("skyBlendingStart", 0.f));
stateset->addUniform(new osg::Uniform("screenRes", osg::Vec2f{}));
stateset->addUniform(new osg::Uniform("isReflection", false));
stateset->addUniform(new osg::Uniform("windSpeed", 0.0f));
stateset->addUniform(new osg::Uniform("playerPos", osg::Vec3f(0.f, 0.f, 0.f)));
stateset->addUniform(new osg::Uniform("useTreeAnim", false));
}
void apply(osg::StateSet* stateset, osg::NodeVisitor* nv) override
{
stateset->getUniform("near")->set(mNear);
stateset->getUniform("far")->set(mFar);
stateset->getUniform("skyBlendingStart")->set(mFar * mSkyBlendingStartCoef);
stateset->getUniform("screenRes")->set(mScreenRes);
stateset->getUniform("windSpeed")->set(mWindSpeed);
stateset->getUniform("playerPos")->set(mPlayerPos);
}
void setNear(float near) { mNear = near; }
void setFar(float far) { mFar = far; }
void setScreenRes(float width, float height) { mScreenRes = osg::Vec2f(width, height); }
void setWindSpeed(float windSpeed) { mWindSpeed = windSpeed; }
void setPlayerPos(osg::Vec3f playerPos) { mPlayerPos = playerPos; }
private:
float mNear;
float mFar;
float mWindSpeed;
float mSkyBlendingStartCoef;
osg::Vec3f mPlayerPos;
osg::Vec2f mScreenRes;
};
class StateUpdater : public SceneUtil::StateSetUpdater
{
public:
StateUpdater()
: mFogStart(0.f)
, mFogEnd(0.f)
, mWireframe(false)
{
}
void setDefaults(osg::StateSet* stateset) override
{
osg::LightModel* lightModel = new osg::LightModel;
stateset->setAttribute(lightModel, osg::StateAttribute::ON);
osg::Fog* fog = new osg::Fog;
fog->setMode(osg::Fog::LINEAR);
stateset->setAttributeAndModes(fog, osg::StateAttribute::ON);
if (mWireframe)
{
osg::PolygonMode* polygonmode = new osg::PolygonMode;
polygonmode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
stateset->setAttributeAndModes(polygonmode, osg::StateAttribute::ON);
}
else
stateset->removeAttribute(osg::StateAttribute::POLYGONMODE);
}
void apply(osg::StateSet* stateset, osg::NodeVisitor*) override
{
osg::LightModel* lightModel
= static_cast<osg::LightModel*>(stateset->getAttribute(osg::StateAttribute::LIGHTMODEL));
lightModel->setAmbientIntensity(mAmbientColor);
osg::Fog* fog = static_cast<osg::Fog*>(stateset->getAttribute(osg::StateAttribute::FOG));
fog->setColor(mFogColor);
fog->setStart(mFogStart);
fog->setEnd(mFogEnd);
}
void setAmbientColor(const osg::Vec4f& col) { mAmbientColor = col; }
void setFogColor(const osg::Vec4f& col) { mFogColor = col; }
void setFogStart(float start) { mFogStart = start; }
void setFogEnd(float end) { mFogEnd = end; }
void setWireframe(bool wireframe)
{
if (mWireframe != wireframe)
{
mWireframe = wireframe;
reset();
}
}
bool getWireframe() const { return mWireframe; }
private:
osg::Vec4f mAmbientColor;
osg::Vec4f mFogColor;
float mFogStart;
float mFogEnd;
bool mWireframe;
};
class PreloadCommonAssetsWorkItem : public SceneUtil::WorkItem
{
public:
@@ -326,61 +140,8 @@ namespace MWRender
, mGroundCoverStore(groundcoverStore)
{
bool reverseZ = SceneUtil::AutoDepth::isReversed();
const SceneUtil::LightingMethod lightingMethod = Settings::shaders().mLightingMethod;
resourceSystem->getSceneManager()->setParticleSystemMask(MWRender::Mask_ParticleSystem);
// Figure out which pipeline must be used by default and inform the user
bool forceShaders = Settings::shaders().mForceShaders;
{
std::vector<std::string> requesters;
if (!forceShaders)
{
if (Settings::fog().mRadialFog)
requesters.push_back("radial fog");
if (Settings::fog().mExponentialFog)
requesters.push_back("exponential fog");
if (mSkyBlending)
requesters.push_back("sky blending");
if (Settings::shaders().mSoftParticles)
requesters.push_back("soft particles");
if (Settings::shadows().mEnableShadows)
requesters.push_back("shadows");
if (lightingMethod != SceneUtil::LightingMethod::FFP)
requesters.push_back("lighting method");
if (reverseZ)
requesters.push_back("reverse-Z depth buffer");
if (Stereo::getMultiview())
requesters.push_back("stereo multiview");
if (!requesters.empty())
forceShaders = true;
}
if (forceShaders)
{
std::string message = "Using rendering with shaders by default";
if (requesters.empty())
{
message += " (forced)";
}
else
{
message += ", requested by:";
for (size_t i = 0; i < requesters.size(); i++)
message += "\n - " + requesters[i];
}
Log(Debug::Info) << message;
}
else
{
Log(Debug::Info) << "Using fixed-function rendering by default";
}
}
resourceSystem->getSceneManager()->setForceShaders(forceShaders);
// FIXME: calling dummy method because terrain needs to know whether lighting is clamped
resourceSystem->getSceneManager()->setClampLighting(Settings::shaders().mClampLighting);
resourceSystem->getSceneManager()->setAutoUseNormalMaps(Settings::shaders().mAutoUseObjectNormalMaps);
resourceSystem->getSceneManager()->setNormalMapPattern(Settings::shaders().mNormalMapPattern);
resourceSystem->getSceneManager()->setNormalHeightMapPattern(Settings::shaders().mNormalHeightMapPattern);
@@ -392,10 +153,10 @@ namespace MWRender
resourceSystem->getSceneManager()->setAdjustCoverageForAlphaTest(
Settings::shaders().mAdjustCoverageForAlphaTest);
// Let LightManager choose which backend to use based on our hint. For methods besides legacy lighting, this
// depends on support for various OpenGL extensions.
// Let LightManager choose which backend to use based on our hint.
// Ultimately dependent on support for various OpenGL extensions.
osg::ref_ptr<SceneUtil::LightManager> sceneRoot = new SceneUtil::LightManager(SceneUtil::LightSettings{
.mLightingMethod = lightingMethod,
.mLightingMethod = Settings::shaders().mLightingMethod,
.mMaxLights = Settings::shaders().mMaxLights,
.mMaximumLightDistance = Settings::shaders().mMaximumLightDistance,
.mLightFadeStart = Settings::shaders().mLightFadeStart,
@@ -426,10 +187,9 @@ namespace MWRender
indoorShadowCastingTraversalMask, Mask_Terrain | Mask_Object | Mask_Static, Settings::shadows(),
mResourceSystem->getSceneManager()->getShaderManager());
Shader::ShaderManager::DefineMap globalDefines = Shader::getDefaultDefines();
Shader::ShaderManager::DefineMap shadowDefines = mShadowManager->getShadowDefines(Settings::shadows());
Shader::ShaderManager::DefineMap lightDefines = sceneRoot->getLightDefines();
Shader::ShaderManager::DefineMap globalDefines
= mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines();
for (auto itr = shadowDefines.begin(); itr != shadowDefines.end(); itr++)
globalDefines[itr->first] = itr->second;
@@ -442,11 +202,6 @@ namespace MWRender
globalDefines["radialFog"] = (exponentialFog || Settings::fog().mRadialFog) ? "1" : "0";
globalDefines["exponentialFog"] = exponentialFog ? "1" : "0";
globalDefines["skyBlending"] = mSkyBlending ? "1" : "0";
globalDefines["waterRefraction"] = "0";
globalDefines["useGPUShader4"] = "0";
globalDefines["useOVR_multiview"] = "0";
globalDefines["numViews"] = "1";
globalDefines["disableNormals"] = "1";
for (auto itr = lightDefines.begin(); itr != lightDefines.end(); itr++)
globalDefines[itr->first] = itr->second;
@@ -499,13 +254,15 @@ namespace MWRender
mGroundcover = chunkMgr.mGroundcover.get();
mObjectPaging = chunkMgr.mObjectPaging.get();
mStateUpdater = new StateUpdater;
mStateUpdater = new SceneUtil::StateUpdater();
sceneRoot->addUpdateCallback(mStateUpdater);
mSharedUniformStateUpdater = new SharedUniformStateUpdater();
mSharedUniformStateUpdater = new SceneUtil::SharedUniformStateUpdater(Settings::fog().mSkyBlendingStart);
rootNode->addUpdateCallback(mSharedUniformStateUpdater);
mPerViewUniformStateUpdater = new PerViewUniformStateUpdater(mResourceSystem->getSceneManager());
mPerViewUniformStateUpdater = new SceneUtil::PerViewUniformStateUpdater(mResourceSystem->getSceneManager(),
mResourceSystem->getSceneManager()->getShaderManager().reserveGlobalTextureUnits(
Shader::ShaderManager::Slot::OpaqueDepthTexture));
rootNode->addCullCallback(mPerViewUniformStateUpdater);
mPostProcessor = new PostProcessor(*this, viewer, mRootNode, resourceSystem->getVFS());
@@ -537,7 +294,6 @@ namespace MWRender
sceneRoot->addChild(source);
sceneRoot->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::ON);
sceneRoot->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
osg::ref_ptr<osg::Material> defaultMat(new osg::Material);
defaultMat->setColorMode(osg::Material::OFF);
@@ -601,6 +357,9 @@ namespace MWRender
mRootNode->getOrCreateStateSet()->setAttributeAndModes(clipcontrol, osg::StateAttribute::ON);
}
mRootNode->getOrCreateStateSet()->setMode(
GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED | osg::StateAttribute::OVERRIDE);
SceneUtil::setCameraClearDepth(mViewer->getCamera());
updateProjectionMatrix();
@@ -704,8 +463,7 @@ namespace MWRender
{
bool isInterior = !cell.isExterior() && !cell.isQuasiExterior();
bool needsAdjusting = false;
if (mResourceSystem->getSceneManager()->getLightingMethod() != SceneUtil::LightingMethod::FFP)
needsAdjusting = isInterior && !Settings::shaders().mClassicFalloff;
needsAdjusting = isInterior && !Settings::shaders().mClassicFalloff;
osg::Vec4f ambient = SceneUtil::colourFromRGB(cell.getMood().mAmbiantColor);
@@ -1566,7 +1324,7 @@ namespace MWRender
lightManager->processChangedSettings(Settings::shaders().mLightBoundsMultiplier,
Settings::shaders().mMaximumLightDistance, Settings::shaders().mLightFadeStart);
if (it->second == "max lights" && !lightManager->usingFFP())
if (it->second == "max lights")
{
mViewer->stopThreading();
+6 -6
View File
@@ -63,6 +63,9 @@ namespace SceneUtil
class WorkQueue;
class LightManager;
class UnrefQueue;
class PerViewUniformStateUpdater;
class SharedUniformStateUpdater;
class StateUpdater;
}
namespace DetourNavigator
@@ -85,9 +88,6 @@ namespace Debug
namespace MWRender
{
class StateUpdater;
class SharedUniformStateUpdater;
class PerViewUniformStateUpdater;
class IntersectionVisitorWithIgnoreList;
class EffectManager;
@@ -339,9 +339,9 @@ namespace MWRender
std::unique_ptr<Camera> mCamera;
osg::ref_ptr<Debug::DebugDrawer> mDebugDraw;
osg::ref_ptr<StateUpdater> mStateUpdater;
osg::ref_ptr<SharedUniformStateUpdater> mSharedUniformStateUpdater;
osg::ref_ptr<PerViewUniformStateUpdater> mPerViewUniformStateUpdater;
osg::ref_ptr<SceneUtil::StateUpdater> mStateUpdater;
osg::ref_ptr<SceneUtil::SharedUniformStateUpdater> mSharedUniformStateUpdater;
osg::ref_ptr<SceneUtil::PerViewUniformStateUpdater> mPerViewUniformStateUpdater;
osg::Vec4f mAmbientColor;
float mNightEyeFactor;
-1
View File
@@ -315,7 +315,6 @@ namespace MWRender
: osg::Camera()
, mRipples(new RipplesSurface(resourceSystem))
{
getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
setRenderOrder(osg::Camera::PRE_RENDER);
setReferenceFrame(osg::Camera::ABSOLUTE_RF);
+9 -18
View File
@@ -264,10 +264,6 @@ namespace MWRender
{
mSkyRootNode = new CameraRelativeTransform;
mSkyRootNode->setName("Sky Root");
// Assign empty program to specify we don't want shaders when we are rendering in FFP pipeline
if (!mSceneManager->getForceShaders())
mSkyRootNode->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(),
osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED | osg::StateAttribute::ON);
mSceneManager->setUpNormalsRTForStateSet(mSkyRootNode->getOrCreateStateSet(), false);
SceneUtil::ShadowManager::instance().disableShadowsForStateSet(*mSkyRootNode->getOrCreateStateSet());
parentNode->addChild(mSkyRootNode);
@@ -299,8 +295,6 @@ namespace MWRender
{
assert(!mCreated);
bool forceShaders = mSceneManager->getForceShaders();
mAtmosphereDay = mSceneManager->getInstance(Settings::models().mSkyatmosphere.get(), mEarlyRenderBinRoot);
ModVertexAlphaVisitor modAtmosphere(ModVertexAlphaVisitor::Atmosphere);
mAtmosphereDay->accept(modAtmosphere);
@@ -322,7 +316,7 @@ namespace MWRender
ModVertexAlphaVisitor modStars(ModVertexAlphaVisitor::Stars);
atmosphereNight->accept(modStars);
mAtmosphereNightUpdater = new AtmosphereNightUpdater(mSceneManager->getImageManager(), forceShaders);
mAtmosphereNightUpdater = new AtmosphereNightUpdater(mSceneManager->getImageManager());
atmosphereNight->addUpdateCallback(mAtmosphereNightUpdater);
mSun = std::make_unique<Sun>(mEarlyRenderBinRoot, *mSceneManager);
@@ -338,7 +332,7 @@ namespace MWRender
mCloudMesh = new osg::PositionAttitudeTransform;
osg::ref_ptr<osg::Node> cloudMeshChild
= mSceneManager->getInstance(Settings::models().mSkyclouds.get(), mCloudMesh);
mCloudUpdater = new CloudUpdater(forceShaders);
mCloudUpdater = new CloudUpdater();
mCloudUpdater->setOpacity(1.f);
cloudMeshChild->addUpdateCallback(mCloudUpdater);
mCloudMesh->addChild(cloudMeshChild);
@@ -346,7 +340,7 @@ namespace MWRender
mNextCloudMesh = new osg::PositionAttitudeTransform;
osg::ref_ptr<osg::Node> nextCloudMeshChild
= mSceneManager->getInstance(Settings::models().mSkyclouds.get(), mNextCloudMesh);
mNextCloudUpdater = new CloudUpdater(forceShaders);
mNextCloudUpdater = new CloudUpdater();
mNextCloudUpdater->setOpacity(0.f);
nextCloudMeshChild->addUpdateCallback(mNextCloudUpdater);
mNextCloudMesh->setNodeMask(0);
@@ -359,15 +353,12 @@ namespace MWRender
mCloudMesh->accept(modClouds);
mNextCloudMesh->accept(modClouds);
if (mSceneManager->getForceShaders())
{
Shader::ShaderManager::DefineMap defines = {};
Stereo::shaderStereoDefines(defines);
auto program = mSceneManager->getShaderManager().getProgram("sky", defines);
mEarlyRenderBinRoot->getOrCreateStateSet()->addUniform(new osg::Uniform("pass", -1));
mEarlyRenderBinRoot->getOrCreateStateSet()->setAttributeAndModes(
program, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
Shader::ShaderManager::DefineMap defines = {};
Stereo::shaderStereoDefines(defines);
auto program = mSceneManager->getShaderManager().getProgram("sky", defines);
mEarlyRenderBinRoot->getOrCreateStateSet()->addUniform(new osg::Uniform("pass", -1));
mEarlyRenderBinRoot->getOrCreateStateSet()->setAttributeAndModes(
program, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
osg::ref_ptr<osg::Depth> depth = new SceneUtil::AutoDepth;
depth->setWriteMask(false);
+28 -136
View File
@@ -11,7 +11,6 @@
#include <osg/Material>
#include <osg/OcclusionQueryNode>
#include <osg/PositionAttitudeTransform>
#include <osg/TexEnvCombine>
#include <osg/TexMat>
#include <osg/Transform>
#include <osg/observer_ptr>
@@ -326,9 +325,8 @@ namespace MWRender
float mShadowBlend;
osg::Vec4f mAtmosphereColor;
osg::Vec4f mMoonColor;
bool mForceShaders;
MoonUpdater(Resource::ImageManager& imageManager, bool forceShaders)
MoonUpdater(Resource::ImageManager& imageManager)
: mImageManager(imageManager)
, mPhaseTex()
, mCircleTex()
@@ -336,75 +334,34 @@ namespace MWRender
, mShadowBlend(1.0f)
, mAtmosphereColor(1.0f, 1.0f, 1.0f, 1.0f)
, mMoonColor(1.0f, 1.0f, 1.0f, 1.0f)
, mForceShaders(forceShaders)
{
}
void setDefaults(osg::StateSet* stateset) override
{
if (mForceShaders)
{
stateset->addUniform(new osg::Uniform("pass", static_cast<int>(Pass::Moon)));
stateset->setTextureAttributeAndModes(0, mPhaseTex);
stateset->setTextureAttributeAndModes(1, mCircleTex);
stateset->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->addUniform(new osg::Uniform("moonBlend", osg::Vec4f{}));
stateset->addUniform(new osg::Uniform("atmosphereFade", osg::Vec4f{}));
stateset->addUniform(new osg::Uniform("diffuseMap", 0));
stateset->addUniform(new osg::Uniform("maskMap", 1));
stateset->setAttributeAndModes(
createUnlitMaterial(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
else
{
stateset->setTextureAttributeAndModes(0, mPhaseTex);
osg::ref_ptr<osg::TexEnvCombine> texEnv = new osg::TexEnvCombine;
texEnv->setCombine_RGB(osg::TexEnvCombine::MODULATE);
texEnv->setSource0_RGB(osg::TexEnvCombine::CONSTANT);
texEnv->setSource1_RGB(osg::TexEnvCombine::TEXTURE);
texEnv->setConstantColor(osg::Vec4f(1.f, 0.f, 0.f, 1.f)); // mShadowBlend * mMoonColor
stateset->setTextureAttributeAndModes(0, texEnv);
stateset->setTextureAttributeAndModes(1, mCircleTex);
osg::ref_ptr<osg::TexEnvCombine> texEnv2 = new osg::TexEnvCombine;
texEnv2->setCombine_RGB(osg::TexEnvCombine::ADD);
texEnv2->setCombine_Alpha(osg::TexEnvCombine::MODULATE);
texEnv2->setSource0_Alpha(osg::TexEnvCombine::TEXTURE);
texEnv2->setSource1_Alpha(osg::TexEnvCombine::CONSTANT);
texEnv2->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
texEnv2->setSource1_RGB(osg::TexEnvCombine::CONSTANT);
texEnv2->setConstantColor(osg::Vec4f(0.f, 0.f, 0.f, 1.f)); // mAtmosphereColor.rgb, mTransparency
stateset->setTextureAttributeAndModes(1, texEnv2);
stateset->setAttributeAndModes(
createUnlitMaterial(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
stateset->addUniform(new osg::Uniform("pass", static_cast<int>(Pass::Moon)));
stateset->setTextureAttributeAndModes(0, mPhaseTex);
stateset->setTextureAttributeAndModes(1, mCircleTex);
stateset->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->addUniform(new osg::Uniform("moonBlend", osg::Vec4f{}));
stateset->addUniform(new osg::Uniform("atmosphereFade", osg::Vec4f{}));
stateset->addUniform(new osg::Uniform("diffuseMap", 0));
stateset->addUniform(new osg::Uniform("maskMap", 1));
stateset->setAttributeAndModes(
createUnlitMaterial(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
void apply(osg::StateSet* stateset, osg::NodeVisitor*) override
{
if (mForceShaders)
{
stateset->setTextureAttribute(0, mPhaseTex, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setTextureAttribute(1, mCircleTex, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setTextureAttribute(0, mPhaseTex, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setTextureAttribute(1, mCircleTex, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
if (auto* uMoonBlend = stateset->getUniform("moonBlend"))
uMoonBlend->set(mMoonColor * mShadowBlend);
if (auto* uAtmosphereFade = stateset->getUniform("atmosphereFade"))
uAtmosphereFade->set(
osg::Vec4f(mAtmosphereColor.x(), mAtmosphereColor.y(), mAtmosphereColor.z(), mTransparency));
}
else
{
osg::TexEnvCombine* texEnv
= static_cast<osg::TexEnvCombine*>(stateset->getTextureAttribute(0, osg::StateAttribute::TEXENV));
texEnv->setConstantColor(mMoonColor * mShadowBlend);
osg::TexEnvCombine* texEnv2
= static_cast<osg::TexEnvCombine*>(stateset->getTextureAttribute(1, osg::StateAttribute::TEXENV));
texEnv2->setConstantColor(
if (auto* uMoonBlend = stateset->getUniform("moonBlend"))
uMoonBlend->set(mMoonColor * mShadowBlend);
if (auto* uAtmosphereFade = stateset->getUniform("atmosphereFade"))
uAtmosphereFade->set(
osg::Vec4f(mAtmosphereColor.x(), mAtmosphereColor.y(), mAtmosphereColor.z(), mTransparency));
}
}
void setTextures(VFS::Path::NormalizedView phaseTex, VFS::Path::NormalizedView circleTex)
@@ -479,10 +436,9 @@ namespace MWRender
mat->setEmission(osg::Material::FRONT_AND_BACK, mEmissionColor);
}
AtmosphereNightUpdater::AtmosphereNightUpdater(Resource::ImageManager* imageManager, bool forceShaders)
AtmosphereNightUpdater::AtmosphereNightUpdater(Resource::ImageManager* imageManager)
: mColor(osg::Vec4f(0, 0, 0, 0))
, mTexture(new osg::Texture2D(imageManager->getWarningImage()))
, mForceShaders(forceShaders)
{
mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
@@ -495,42 +451,17 @@ namespace MWRender
void AtmosphereNightUpdater::setDefaults(osg::StateSet* stateset)
{
if (mForceShaders)
{
stateset->addUniform(new osg::Uniform("opacity", 0.f));
stateset->addUniform(new osg::Uniform("pass", static_cast<int>(Pass::Atmosphere_Night)));
}
else
{
osg::ref_ptr<osg::TexEnvCombine> texEnv = new osg::TexEnvCombine;
texEnv->setCombine_Alpha(osg::TexEnvCombine::MODULATE);
texEnv->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS);
texEnv->setSource1_Alpha(osg::TexEnvCombine::CONSTANT);
texEnv->setCombine_RGB(osg::TexEnvCombine::REPLACE);
texEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
stateset->setTextureAttributeAndModes(1, mTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setTextureAttributeAndModes(1, texEnv, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
stateset->addUniform(new osg::Uniform("opacity", 0.f));
stateset->addUniform(new osg::Uniform("pass", static_cast<int>(Pass::Atmosphere_Night)));
}
void AtmosphereNightUpdater::apply(osg::StateSet* stateset, osg::NodeVisitor* /*nv*/)
{
if (mForceShaders)
{
stateset->getUniform("opacity")->set(mColor.a());
}
else
{
osg::TexEnvCombine* texEnv
= static_cast<osg::TexEnvCombine*>(stateset->getTextureAttribute(1, osg::StateAttribute::TEXENV));
texEnv->setConstantColor(mColor);
}
stateset->getUniform("opacity")->set(mColor.a());
}
CloudUpdater::CloudUpdater(bool forceShaders)
CloudUpdater::CloudUpdater()
: mOpacity(0.f)
, mForceShaders(forceShaders)
{
}
@@ -562,30 +493,10 @@ namespace MWRender
osg::ref_ptr<osg::TexMat> texmat = new osg::TexMat;
stateset->setTextureAttributeAndModes(0, texmat);
if (mForceShaders)
{
stateset->setTextureAttribute(0, mTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setTextureAttribute(0, mTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->addUniform(new osg::Uniform("opacity", 1.f));
stateset->addUniform(new osg::Uniform("pass", static_cast<int>(Pass::Clouds)));
}
else
{
stateset->setTextureAttributeAndModes(1, texmat);
// need to set opacity on a separate texture unit, diffuse alpha is used by the vertex colors already
osg::ref_ptr<osg::TexEnvCombine> texEnvCombine = new osg::TexEnvCombine;
texEnvCombine->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
texEnvCombine->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS);
texEnvCombine->setSource1_Alpha(osg::TexEnvCombine::CONSTANT);
texEnvCombine->setConstantColor(osg::Vec4f(1, 1, 1, 1));
texEnvCombine->setCombine_Alpha(osg::TexEnvCombine::MODULATE);
texEnvCombine->setCombine_RGB(osg::TexEnvCombine::REPLACE);
stateset->setTextureAttributeAndModes(1, texEnvCombine);
stateset->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
stateset->addUniform(new osg::Uniform("opacity", 1.f));
stateset->addUniform(new osg::Uniform("pass", static_cast<int>(Pass::Clouds)));
}
void CloudUpdater::apply(osg::StateSet* stateset, osg::NodeVisitor* nv)
@@ -598,18 +509,7 @@ namespace MWRender
osg::TexMat* texMat = static_cast<osg::TexMat*>(stateset->getTextureAttribute(0, osg::StateAttribute::TEXMAT));
texMat->setMatrix(mTexMat);
if (mForceShaders)
{
stateset->getUniform("opacity")->set(mOpacity);
}
else
{
stateset->setTextureAttribute(1, mTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
osg::TexEnvCombine* texEnv
= static_cast<osg::TexEnvCombine*>(stateset->getTextureAttribute(1, osg::StateAttribute::TEXENV));
texEnv->setConstantColor(osg::Vec4f(1, 1, 1, mOpacity));
}
stateset->getUniform("opacity")->set(mOpacity);
}
class SkyStereoStatesetUpdater : public SceneUtil::StateSetUpdater
@@ -783,14 +683,6 @@ namespace MWRender
osg::StateSet* stateset = queryNode->getOrCreateStateSet();
stateset->setRenderBinDetails(RenderBin_OcclusionQuery, "RenderBin");
stateset->setNestRenderBins(false);
// Set up alpha testing on the occlusion testing subgraph, that way we can get the occlusion tested fragments to
// match the circular shape of the sun
if (!sceneManager.getForceShaders())
{
osg::ref_ptr<osg::AlphaFunc> alphaFunc = new osg::AlphaFunc;
alphaFunc->setFunction(osg::AlphaFunc::GREATER, 0.8f);
stateset->setAttributeAndModes(alphaFunc);
}
stateset->setTextureAttributeAndModes(0, sunTex);
stateset->setTextureAttributeAndModes(0, new SceneUtil::TextureType("diffuseMap"), osg::StateAttribute::ON);
stateset->setAttributeAndModes(createUnlitMaterial());
@@ -997,7 +889,7 @@ namespace MWRender
: CelestialBody(parentNode, scaleFactor, 2)
, mType(type)
, mPhase(MoonState::Phase::Unspecified)
, mUpdater(new MoonUpdater(*sceneManager.getImageManager(), sceneManager.getForceShaders()))
, mUpdater(new MoonUpdater(*sceneManager.getImageManager()))
{
setPhase(MoonState::Phase::Full);
setVisible(true);
+2 -4
View File
@@ -140,7 +140,7 @@ namespace MWRender
class AtmosphereNightUpdater : public SceneUtil::StateSetUpdater
{
public:
AtmosphereNightUpdater(Resource::ImageManager* imageManager, bool forceShaders);
AtmosphereNightUpdater(Resource::ImageManager* imageManager);
void setFade(float fade);
@@ -152,13 +152,12 @@ namespace MWRender
private:
osg::Vec4f mColor;
osg::ref_ptr<osg::Texture2D> mTexture;
bool mForceShaders;
};
class CloudUpdater : public SceneUtil::StateSetUpdater
{
public:
CloudUpdater(bool forceShaders);
CloudUpdater();
void setTexture(osg::ref_ptr<osg::Texture2D> texture);
@@ -174,7 +173,6 @@ namespace MWRender
osg::ref_ptr<osg::Texture2D> mTexture;
osg::Vec4f mEmissionColor;
float mOpacity;
bool mForceShaders;
osg::Matrixf mTexMat;
};
-3
View File
@@ -603,10 +603,7 @@ namespace MWRender
// use a shader to render the simple water, ensuring that fog is applied per pixel as required.
// this could be removed if a more detailed water mesh, using some sort of paging solution, is implemented.
Resource::SceneManager* sceneManager = mResourceSystem->getSceneManager();
bool oldValue = sceneManager->getForceShaders();
sceneManager->setForceShaders(true);
sceneManager->recreateShaders(node);
sceneManager->setForceShaders(oldValue);
}
class ShaderWaterStateSetUpdater : public SceneUtil::StateSetUpdater
+1 -1
View File
@@ -137,7 +137,7 @@ add_component_dir (shader
)
add_component_dir (sceneutil
clone attach visitor util statesetupdater controller skeleton riggeometry morphgeometry lightcontroller
clone attach visitor util statesetupdater stateupdater controller skeleton riggeometry morphgeometry lightcontroller
lightmanager lightutil positionattitudetransform workqueue pathgridutil waterutil writescene serialize optimizer
detourdebugdraw navmesh agentpath animblendrules shadow mwshadowtechnique recastmesh shadowsbin osgacontroller rtt
screencapture depth color riggeometryosgaextension extradata unrefqueue lightcommon lightingmethod clearcolor
@@ -178,7 +178,6 @@ namespace MyGUIPlatform
setUpdateCallback(frameUpdate);
mStateSet = new osg::StateSet;
mStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mStateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON);
mStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
mStateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
+1 -98
View File
@@ -9,7 +9,6 @@
#include <osg/Matrixf>
#include <osg/Sequence>
#include <osg/Switch>
#include <osg/TexGen>
#include <osg/TexMat>
#include <osg/ValueObject>
@@ -41,8 +40,6 @@
#include <osg/PolygonMode>
#include <osg/PolygonOffset>
#include <osg/Stencil>
#include <osg/TexEnv>
#include <osg/TexEnvCombine>
#include <osg/Texture2D>
#include <components/bgsm/file.hpp>
@@ -606,17 +603,9 @@ namespace NifOsg
return false;
}
osg::ref_ptr<osg::TexGen> texGen(new osg::TexGen);
switch (textureEffect->mCoordGenType)
{
case Nif::NiTextureEffect::CoordGenType::WorldParallel:
texGen->setMode(osg::TexGen::OBJECT_LINEAR);
break;
case Nif::NiTextureEffect::CoordGenType::WorldPerspective:
texGen->setMode(osg::TexGen::EYE_LINEAR);
break;
case Nif::NiTextureEffect::CoordGenType::SphereMap:
texGen->setMode(osg::TexGen::SPHERE_MAP);
break;
default:
Log(Debug::Info) << "Unhandled NiTextureEffect CoordGenType "
@@ -625,13 +614,10 @@ namespace NifOsg
}
const unsigned int uvSet = 0;
const unsigned int texUnit = 3; // FIXME
std::vector<unsigned int> boundTextures;
boundTextures.resize(3); // Dummy vector for attachNiSourceTexture
attachNiSourceTexture("envMap", textureEffect->mTexture.getPtr(), textureEffect->wrapS(),
textureEffect->wrapT(), uvSet, stateset, boundTextures);
stateset->setTextureAttributeAndModes(texUnit, texGen, osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(texUnit, createEmissiveTexEnv(), osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("envMapColor", osg::Vec4f(1, 1, 1, 1)));
return true;
@@ -2064,20 +2050,6 @@ namespace NifOsg
return image;
}
static osg::ref_ptr<osg::TexEnvCombine> createEmissiveTexEnv()
{
osg::ref_ptr<osg::TexEnvCombine> texEnv(new osg::TexEnvCombine);
// Sum the previous colour and the emissive colour.
texEnv->setCombine_RGB(osg::TexEnvCombine::ADD);
texEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
texEnv->setSource1_RGB(osg::TexEnvCombine::TEXTURE);
// Keep the previous alpha.
texEnv->setCombine_Alpha(osg::TexEnvCombine::REPLACE);
texEnv->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS);
texEnv->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA);
return texEnv;
}
static void handleDepthFlags(osg::StateSet* stateset, bool depthTest, bool depthWrite)
{
if (!depthWrite && !depthTest)
@@ -2140,7 +2112,6 @@ namespace NifOsg
}
}
const auto texUnit = static_cast<unsigned>(boundTextures.size());
if (tex.mEnabled)
{
if (tex.mSourceTexture.empty() && texprop->mController.empty())
@@ -2164,73 +2135,13 @@ namespace NifOsg
attachTexture(textureName, nullptr, true, true, 0, stateset, boundTextures);
}
if (i == Nif::NiTexturingProperty::GlowTexture)
if (i == Nif::NiTexturingProperty::BumpTexture)
{
stateset->setTextureAttributeAndModes(texUnit, createEmissiveTexEnv(), osg::StateAttribute::ON);
}
else if (i == Nif::NiTexturingProperty::DarkTexture)
{
osg::TexEnv* texEnv = new osg::TexEnv;
// Modulate both the colour and the alpha with the dark map.
texEnv->setMode(osg::TexEnv::MODULATE);
stateset->setTextureAttributeAndModes(texUnit, texEnv, osg::StateAttribute::ON);
}
else if (i == Nif::NiTexturingProperty::DetailTexture)
{
osg::TexEnvCombine* texEnv = new osg::TexEnvCombine;
// Modulate previous colour...
texEnv->setCombine_RGB(osg::TexEnvCombine::MODULATE);
texEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
texEnv->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
// with the detail map's colour,
texEnv->setSource1_RGB(osg::TexEnvCombine::TEXTURE);
texEnv->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);
// and a twist:
texEnv->setScale_RGB(2.f);
// Keep the previous alpha.
texEnv->setCombine_Alpha(osg::TexEnvCombine::REPLACE);
texEnv->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS);
texEnv->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA);
stateset->setTextureAttributeAndModes(texUnit, texEnv, osg::StateAttribute::ON);
}
else if (i == Nif::NiTexturingProperty::BumpTexture)
{
// Bump maps offset the environment map.
// Set this texture to Off by default since we can't render it with the fixed-function pipeline
stateset->setTextureMode(texUnit, GL_TEXTURE_2D, osg::StateAttribute::OFF);
osg::Matrix2 bumpMapMatrix(texprop->mBumpMapMatrix.x(), texprop->mBumpMapMatrix.y(),
texprop->mBumpMapMatrix.z(), texprop->mBumpMapMatrix.w());
stateset->addUniform(new osg::Uniform("bumpMapMatrix", bumpMapMatrix));
stateset->addUniform(new osg::Uniform("envMapLumaBias", texprop->mEnvMapLumaBias));
}
else if (i == Nif::NiTexturingProperty::GlossTexture)
{
// A gloss map is an environment map mask.
// Gloss maps are only implemented in the object shaders as well.
stateset->setTextureMode(texUnit, GL_TEXTURE_2D, osg::StateAttribute::OFF);
}
else if (i == Nif::NiTexturingProperty::DecalTexture)
{
// This is only an inaccurate imitation of the original implementation,
// see https://github.com/niftools/nifskope/issues/184
osg::TexEnvCombine* texEnv = new osg::TexEnvCombine;
// Interpolate to the decal texture's colour...
texEnv->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);
texEnv->setSource0_RGB(osg::TexEnvCombine::TEXTURE);
texEnv->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
// ...from the previous colour...
texEnv->setSource1_RGB(osg::TexEnvCombine::PREVIOUS);
texEnv->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);
// using the decal texture's alpha as the factor.
texEnv->setSource2_RGB(osg::TexEnvCombine::TEXTURE);
texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_ALPHA);
// Keep the previous alpha.
texEnv->setCombine_Alpha(osg::TexEnvCombine::REPLACE);
texEnv->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS);
texEnv->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA);
stateset->setTextureAttributeAndModes(texUnit, texEnv, osg::StateAttribute::ON);
}
}
}
handleTextureControllers(texprop, composite, stateset, animflags);
@@ -2571,9 +2482,7 @@ namespace NifOsg
case Nif::RC_BSShaderPPLightingProperty:
{
auto texprop = static_cast<const Nif::BSShaderPPLightingProperty*>(property);
bool shaderRequired = true;
node->setUserValue("shaderPrefix", std::string(getBSShaderPrefix(texprop->mType)));
node->setUserValue("shaderRequired", shaderRequired);
osg::StateSet* stateset = node->getOrCreateStateSet();
clearBoundTextures(stateset, boundTextures);
if (!texprop->mTextureSet.empty())
@@ -2587,10 +2496,8 @@ namespace NifOsg
case Nif::RC_BSShaderNoLightingProperty:
{
auto texprop = static_cast<const Nif::BSShaderNoLightingProperty*>(property);
bool shaderRequired = true;
bool useFalloff = false;
node->setUserValue("shaderPrefix", std::string(getBSShaderPrefix(texprop->mType)));
node->setUserValue("shaderRequired", shaderRequired);
osg::StateSet* stateset = node->getOrCreateStateSet();
clearBoundTextures(stateset, boundTextures);
if (!texprop->mFilename.empty())
@@ -2612,9 +2519,7 @@ namespace NifOsg
case Nif::RC_BSLightingShaderProperty:
{
auto texprop = static_cast<const Nif::BSLightingShaderProperty*>(property);
bool shaderRequired = true;
node->setUserValue("shaderPrefix", std::string(getBSLightingShaderPrefix(texprop->mType)));
node->setUserValue("shaderRequired", shaderRequired);
osg::StateSet* stateset = node->getOrCreateStateSet();
clearBoundTextures(stateset, boundTextures);
if (Bgsm::MaterialFilePtr material
@@ -2639,10 +2544,8 @@ namespace NifOsg
case Nif::RC_BSEffectShaderProperty:
{
auto texprop = static_cast<const Nif::BSEffectShaderProperty*>(property);
bool shaderRequired = true;
// TODO: implement BSEffectShader as a shader
node->setUserValue("shaderPrefix", std::string("bs/nolighting"));
node->setUserValue("shaderRequired", shaderRequired);
osg::StateSet* stateset = node->getOrCreateStateSet();
clearBoundTextures(stateset, boundTextures);
if (Bgsm::MaterialFilePtr material
+3 -26
View File
@@ -452,28 +452,16 @@ namespace Resource
, mMagFilter(osg::Texture::LINEAR)
, mMaxAnisotropy(1.f)
, mParticleSystemMask(~0u)
, mLightingMethod(SceneUtil::LightingMethod::FFP)
, mLightingMethod(SceneUtil::LightingMethod::PerObjectUniform)
{
}
void SceneManager::setForceShaders(bool force)
{
mForceShaders = force;
}
bool SceneManager::getForceShaders() const
{
return mForceShaders;
}
void SceneManager::recreateShaders(osg::ref_ptr<osg::Node> node, const std::string& shaderPrefix,
bool forceShadersForNode, const osg::Program* programTemplate)
void SceneManager::recreateShaders(
osg::ref_ptr<osg::Node> node, const std::string& shaderPrefix, const osg::Program* programTemplate)
{
osg::ref_ptr<Shader::ShaderVisitor> shaderVisitor(createShaderVisitor(shaderPrefix));
shaderVisitor->setAllowedToModifyStateSets(false);
shaderVisitor->setProgramTemplate(programTemplate);
if (forceShadersForNode)
shaderVisitor->setForceShaders(true);
node->accept(*shaderVisitor);
}
@@ -484,16 +472,6 @@ namespace Resource
node->accept(*reinstateRemovedStateVisitor);
}
void SceneManager::setClampLighting(bool clamp)
{
mClampLighting = clamp;
}
bool SceneManager::getClampLighting() const
{
return mClampLighting;
}
void SceneManager::setAutoUseNormalMaps(bool use)
{
mAutoUseNormalMaps = use;
@@ -1242,7 +1220,6 @@ namespace Resource
{
osg::ref_ptr<Shader::ShaderVisitor> shaderVisitor(
new Shader::ShaderVisitor(*mShaderManager.get(), *mImageManager, shaderPrefix));
shaderVisitor->setForceShaders(mForceShaders);
shaderVisitor->setAutoUseNormalMaps(mAutoUseNormalMaps);
shaderVisitor->setNormalMapPattern(mNormalMapPattern);
shaderVisitor->setNormalHeightMapPattern(mNormalHeightMapPattern);
+1 -10
View File
@@ -99,7 +99,7 @@ namespace Resource
/// Re-create shaders for this node, need to call this if alpha testing, texture stages or vertex color mode
/// have changed.
void recreateShaders(osg::ref_ptr<osg::Node> node, const std::string& shaderPrefix = "objects",
bool forceShadersForNode = false, const osg::Program* programTemplate = nullptr);
const osg::Program* programTemplate = nullptr);
/// Applying shaders to a node may replace some fixed-function state.
/// This restores it.
@@ -107,13 +107,6 @@ namespace Resource
/// afterwards.
void reinstateRemovedState(osg::ref_ptr<osg::Node> node);
/// @see ShaderVisitor::setForceShaders
void setForceShaders(bool force);
bool getForceShaders() const;
void setClampLighting(bool clamp);
bool getClampLighting() const;
/// @see ShaderVisitor::setAutoUseNormalMaps
void setAutoUseNormalMaps(bool use);
@@ -261,8 +254,6 @@ namespace Resource
unsigned int mParticleSystemMask;
SceneUtil::LightingMethod mLightingMethod;
SceneUtil::LightManager::SupportedMethods mSupportedLightingMethods;
bool mForceShaders = false;
bool mClampLighting = true;
bool mAutoUseNormalMaps = false;
bool mAutoUseSpecularMaps = false;
bool mApplyLightingToEnvMaps = false;
-1
View File
@@ -319,7 +319,6 @@ namespace Resource
, mStatNames(generateAllStatNames())
{
osg::ref_ptr<osg::StateSet> stateset = mSwitch->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
#ifdef OSG_GL1_AVAILABLE
View File
-1
View File
@@ -5,7 +5,6 @@ namespace SceneUtil
{
enum class LightingMethod
{
FFP,
PerObjectUniform,
SingleUBO,
};
+16 -230
View File
@@ -24,8 +24,6 @@
namespace
{
constexpr int ffpMaxLights = 8;
void configurePosition(osg::Matrixf& mat, const osg::Vec4& pos)
{
mat(0, 0) = pos.x();
@@ -69,7 +67,6 @@ namespace SceneUtil
namespace
{
const std::unordered_map<std::string, LightingMethod> lightingMethodSettingMap = {
{ "legacy", LightingMethod::FFP },
{ "shaders compatibility", LightingMethod::PerObjectUniform },
{ "shaders", LightingMethod::SingleUBO },
};
@@ -254,10 +251,6 @@ namespace SceneUtil
auto method = lightManager->getLightingMethod();
switch (method)
{
case LightingMethod::FFP:
{
break;
}
case LightingMethod::PerObjectUniform:
{
osg::Matrixf lightMat;
@@ -290,136 +283,6 @@ namespace SceneUtil
}
}
class DisableLight : public osg::StateAttribute
{
public:
DisableLight()
: mIndex(0)
{
}
DisableLight(int index)
: mIndex(index)
{
}
DisableLight(const DisableLight& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)
: osg::StateAttribute(copy, copyop)
, mIndex(copy.mIndex)
{
}
META_StateAttribute(SceneUtil, DisableLight, osg::StateAttribute::LIGHT)
unsigned int getMember() const override { return static_cast<unsigned int>(mIndex); }
bool getModeUsage(ModeUsage& usage) const override
{
usage.usesMode(static_cast<GLMode>(GL_LIGHT0 + mIndex));
return true;
}
int compare(const StateAttribute& sa) const override
{
throw std::runtime_error("DisableLight::compare: unimplemented");
}
void apply(osg::State& state) const override
{
GLenum lightNum = static_cast<GLenum>(GL_LIGHT0 + mIndex);
glLightfv(lightNum, GL_AMBIENT, mNullptr.ptr());
glLightfv(lightNum, GL_DIFFUSE, mNullptr.ptr());
glLightfv(lightNum, GL_SPECULAR, mNullptr.ptr());
LightStateCache* cache = getLightStateCache(state.getContextID());
cache->lastAppliedLight[mIndex] = nullptr;
}
private:
size_t mIndex;
osg::Vec4f mNullptr;
};
class FFPLightStateAttribute : public osg::StateAttribute
{
public:
FFPLightStateAttribute()
: mIndex(0)
{
}
FFPLightStateAttribute(size_t index, const std::vector<osg::ref_ptr<osg::Light>>& lights)
: mIndex(index)
, mLights(lights)
{
}
FFPLightStateAttribute(
const FFPLightStateAttribute& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)
: osg::StateAttribute(copy, copyop)
, mIndex(copy.mIndex)
, mLights(copy.mLights)
{
}
unsigned int getMember() const override { return static_cast<unsigned int>(mIndex); }
bool getModeUsage(ModeUsage& usage) const override
{
for (size_t i = 0; i < mLights.size(); ++i)
usage.usesMode(static_cast<GLMode>(GL_LIGHT0 + mIndex + i));
return true;
}
int compare(const StateAttribute& sa) const override
{
throw std::runtime_error("FFPLightStateAttribute::compare: unimplemented");
}
META_StateAttribute(SceneUtil, FFPLightStateAttribute, osg::StateAttribute::LIGHT)
void apply(osg::State& state) const override
{
if (mLights.empty())
return;
osg::Matrix modelViewMatrix = state.getModelViewMatrix();
state.applyModelViewMatrix(state.getInitialViewMatrix());
LightStateCache* cache = getLightStateCache(state.getContextID());
for (size_t i = 0; i < mLights.size(); ++i)
{
osg::Light* current = cache->lastAppliedLight[i + mIndex];
if (current != mLights[i].get())
{
applyLight((GLenum)((int)GL_LIGHT0 + i + mIndex), mLights[i].get());
cache->lastAppliedLight[i + mIndex] = mLights[i].get();
}
}
state.applyModelViewMatrix(modelViewMatrix);
}
void applyLight(GLenum lightNum, const osg::Light* light) const
{
glLightfv(lightNum, GL_AMBIENT, light->getAmbient().ptr());
glLightfv(lightNum, GL_DIFFUSE, light->getDiffuse().ptr());
glLightfv(lightNum, GL_SPECULAR, light->getSpecular().ptr());
glLightfv(lightNum, GL_POSITION, light->getPosition().ptr());
// TODO: enable this once spot lights are supported
// need to transform SPOT_DIRECTION by the world matrix?
// glLightfv(lightNum, GL_SPOT_DIRECTION, light->getDirection().ptr());
// glLightf(lightNum, GL_SPOT_EXPONENT, light->getSpotExponent());
// glLightf(lightNum, GL_SPOT_CUTOFF, light->getSpotCutoff());
glLightf(lightNum, GL_CONSTANT_ATTENUATION, light->getConstantAttenuation());
glLightf(lightNum, GL_LINEAR_ATTENUATION, light->getLinearAttenuation());
glLightf(lightNum, GL_QUADRATIC_ATTENUATION, light->getQuadraticAttenuation());
}
private:
size_t mIndex;
std::vector<osg::ref_ptr<osg::Light>> mLights;
};
struct StateSetGenerator
{
LightManager* mLightManager;
@@ -433,37 +296,6 @@ namespace SceneUtil
osg::Matrix mViewMatrix;
};
struct StateSetGeneratorFFP : StateSetGenerator
{
osg::ref_ptr<osg::StateSet> generate(const LightManager::LightList& lightList, size_t frameNum) override
{
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
std::vector<osg::ref_ptr<osg::Light>> lights;
lights.reserve(lightList.size());
for (size_t i = 0; i < lightList.size(); ++i)
lights.emplace_back(lightList[i]->mLightSource->getLight(frameNum));
// the first light state attribute handles the actual state setting for all lights
// it's best to batch these up so that we don't need to touch the modelView matrix more than necessary
// don't use setAttributeAndModes, that does not support light indices!
stateset->setAttribute(
new FFPLightStateAttribute(mLightManager->getStartLight(), std::move(lights)), osg::StateAttribute::ON);
for (size_t i = 0; i < lightList.size(); ++i)
stateset->setMode(
GL_LIGHT0 + mLightManager->getStartLight() + static_cast<int>(i), osg::StateAttribute::ON);
// need to push some dummy attributes to ensure proper state tracking
// lights need to reset to their default when the StateSet is popped
for (size_t i = 1; i < lightList.size(); ++i)
stateset->setAttribute(
mLightManager->getDummies()[i + mLightManager->getStartLight()].get(), osg::StateAttribute::ON);
return stateset;
}
};
struct StateSetGeneratorSingleUBO : StateSetGenerator
{
osg::ref_ptr<osg::StateSet> generate(const LightManager::LightList& lightList, size_t frameNum) override
@@ -824,40 +656,32 @@ namespace SceneUtil
bool supportsUBO = exts && exts->isUniformBufferObjectSupported;
bool supportsGPU4 = exts && exts->isGpuShader4Supported;
mSupported[static_cast<int>(LightingMethod::FFP)] = true;
mSupported[static_cast<int>(LightingMethod::PerObjectUniform)] = true;
mSupported[static_cast<int>(LightingMethod::SingleUBO)] = supportsUBO && supportsGPU4;
setUpdateCallback(new LightManagerUpdateCallback);
if (settings.mLightingMethod == LightingMethod::FFP)
static bool hasLoggedWarnings = false;
if (settings.mLightingMethod == LightingMethod::SingleUBO && !hasLoggedWarnings)
{
initFFP(ffpMaxLights);
if (!supportsUBO)
Log(Debug::Warning) << "GL_ARB_uniform_buffer_object not supported: switching to shader "
"compatibility lighting mode";
if (!supportsGPU4)
Log(Debug::Warning)
<< "GL_EXT_gpu_shader4 not supported: switching to shader compatibility lighting mode";
hasLoggedWarnings = true;
}
if (!supportsUBO || !supportsGPU4 || settings.mLightingMethod == LightingMethod::PerObjectUniform)
initPerObjectUniform(settings.mMaxLights);
else
{
static bool hasLoggedWarnings = false;
initSingleUBO(settings.mMaxLights);
if (settings.mLightingMethod == LightingMethod::SingleUBO && !hasLoggedWarnings)
{
if (!supportsUBO)
Log(Debug::Warning) << "GL_ARB_uniform_buffer_object not supported: switching to shader "
"compatibility lighting mode";
if (!supportsGPU4)
Log(Debug::Warning)
<< "GL_EXT_gpu_shader4 not supported: switching to shader compatibility lighting mode";
hasLoggedWarnings = true;
}
getOrCreateStateSet()->addUniform(new osg::Uniform("PointLightCount", 0));
if (!supportsUBO || !supportsGPU4 || settings.mLightingMethod == LightingMethod::PerObjectUniform)
initPerObjectUniform(settings.mMaxLights);
else
initSingleUBO(settings.mMaxLights);
getOrCreateStateSet()->addUniform(new osg::Uniform("PointLightCount", 0));
addCullCallback(new LightManagerCullCallback(this));
}
addCullCallback(new LightManagerCullCallback(this));
updateSettings(settings.mLightBoundsMultiplier, settings.mMaximumLightDistance, settings.mLightFadeStart);
}
@@ -881,11 +705,6 @@ namespace SceneUtil
return mLightingMethod;
}
bool LightManager::usingFFP() const
{
return mLightingMethod == LightingMethod::FFP;
}
int LightManager::getMaxLights() const
{
return mMaxLights;
@@ -908,15 +727,12 @@ namespace SceneUtil
defines["maxLights"] = std::to_string(getMaxLights());
defines["maxLightsInScene"] = std::to_string(getMaxLightsInScene());
defines["lightingMethodFFP"] = getLightingMethod() == LightingMethod::FFP ? "1" : "0";
defines["lightingMethodPerObjectUniform"] = getLightingMethod() == LightingMethod::PerObjectUniform ? "1" : "0";
defines["lightingMethodUBO"] = getLightingMethod() == LightingMethod::SingleUBO ? "1" : "0";
defines["useUBO"] = std::to_string(getLightingMethod() == LightingMethod::SingleUBO);
// exposes bitwise operators
defines["useGPUShader4"] = std::to_string(getLightingMethod() == LightingMethod::SingleUBO);
defines["getLight"] = getLightingMethod() == LightingMethod::FFP ? "gl_LightSource" : "LightBuffer";
defines["startLight"] = getLightingMethod() == LightingMethod::SingleUBO ? "0" : "1";
defines["endLight"] = getLightingMethod() == LightingMethod::FFP ? defines["maxLights"] : "PointLightCount";
return defines;
}
@@ -929,9 +745,6 @@ namespace SceneUtil
void LightManager::updateMaxLights(int maxLights)
{
if (usingFFP())
return;
setMaxLights(maxLights);
if (getLightingMethod() == LightingMethod::PerObjectUniform)
@@ -952,15 +765,6 @@ namespace SceneUtil
mPointLightFadeStart = mPointLightFadeEnd * lightFadeStart;
}
void LightManager::initFFP(int targetLights)
{
setLightingMethod(LightingMethod::FFP);
setMaxLights(targetLights);
for (int i = 0; i < getMaxLights(); ++i)
mDummies.push_back(new FFPLightStateAttribute(i, std::vector<osg::ref_ptr<osg::Light>>()));
}
void LightManager::initPerObjectUniform(int targetLights)
{
setLightingMethod(LightingMethod::PerObjectUniform);
@@ -983,9 +787,6 @@ namespace SceneUtil
mLightingMethod = method;
switch (method)
{
case LightingMethod::FFP:
mStateSetGenerator = std::make_unique<StateSetGeneratorFFP>();
break;
case LightingMethod::SingleUBO:
mStateSetGenerator = std::make_unique<StateSetGeneratorSingleUBO>();
break;
@@ -1009,18 +810,6 @@ namespace SceneUtil
void LightManager::setStartLight(int start)
{
mStartLight = start;
if (!usingFFP())
return;
// Set default light state to zero
// This is necessary because shaders don't respect glDisable(GL_LIGHTX) so in addition to disabling
// we'll have to set a light state that has no visible effect
for (int i = start; i < getMaxLights(); ++i)
{
osg::ref_ptr<DisableLight> defaultLight(new DisableLight(i));
getOrCreateStateSet()->setAttributeAndModes(defaultLight, osg::StateAttribute::OFF);
}
}
int LightManager::getStartLight() const
@@ -1058,9 +847,6 @@ namespace SceneUtil
void LightManager::setSunlight(osg::ref_ptr<osg::Light> sun)
{
if (usingFFP())
return;
mSun = sun;
}
+4 -7
View File
@@ -182,11 +182,11 @@ namespace SceneUtil
struct LightSettings
{
LightingMethod mLightingMethod = LightingMethod::FFP;
int mMaxLights = 0;
float mMaximumLightDistance = 0;
LightingMethod mLightingMethod = LightingMethod::PerObjectUniform;
int mMaxLights = 8;
float mMaximumLightDistance = 8192;
float mLightFadeStart = 0;
float mLightBoundsMultiplier = 0;
float mLightBoundsMultiplier = 1;
};
/// @brief Decorator node implementing the rendering of any number of LightSources that can be anywhere in the
@@ -246,8 +246,6 @@ namespace SceneUtil
void setSunlight(osg::ref_ptr<osg::Light> sun);
osg::ref_ptr<osg::Light> getSunlight();
bool usingFFP() const;
LightingMethod getLightingMethod() const;
int getMaxLights() const;
@@ -280,7 +278,6 @@ namespace SceneUtil
std::shared_ptr<PPLightBuffer> getPPLightsBuffer() { return mPPLightBuffer; }
private:
void initFFP(int targetLights);
void initPerObjectUniform(int targetLights);
void initSingleUBO(int targetLights);
-2
View File
@@ -139,7 +139,6 @@ namespace SceneUtil
gridGeometry->addPrimitiveSet(pointIndices);
if (!lineIndices->empty())
gridGeometry->addPrimitiveSet(lineIndices);
gridGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
}
template <class T>
@@ -187,7 +186,6 @@ namespace SceneUtil
wireframeGeometry->setVertexArray(vertices);
wireframeGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
wireframeGeometry->addPrimitiveSet(indices);
wireframeGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
}
}
-1
View File
@@ -199,7 +199,6 @@ namespace SceneUtil
"SceneUtil::UBOManager",
"SceneUtil::LightListCallback",
"SceneUtil::LightManagerUpdateCallback",
"SceneUtil::FFPLightStateAttribute",
"SceneUtil::UpdateRigBounds",
"SceneUtil::UpdateRigGeometry",
"SceneUtil::LightSource",
+190
View File
@@ -0,0 +1,190 @@
#include "stateupdater.hpp"
#include <osg/Fog>
#include <osg/LightModel>
#include <osg/PolygonMode>
#include "depth.hpp"
#include "rtt.hpp"
#include "statesetupdater.hpp"
#include <components/resource/scenemanager.hpp>
#include <components/stereo/multiview.hpp>
#include <components/stereo/stereomanager.hpp>
namespace SceneUtil
{
PerViewUniformStateUpdater::PerViewUniformStateUpdater(Resource::SceneManager* sceneManager, int opaqueTextureUnit)
: mSceneManager(sceneManager)
, mOpaqueTextureUnit(opaqueTextureUnit)
{
}
void PerViewUniformStateUpdater::setDefaults(osg::StateSet* stateset)
{
stateset->addUniform(new osg::Uniform("projectionMatrix", osg::Matrixf{}));
if (mSkyRTT)
stateset->addUniform(new osg::Uniform("sky", mSkyTextureUnit));
}
void PerViewUniformStateUpdater::apply(osg::StateSet* stateset, osg::NodeVisitor* nv)
{
stateset->getUniform("projectionMatrix")->set(mProjectionMatrix);
if (mSkyRTT && nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
{
osg::Texture* skyTexture = mSkyRTT->getColorTexture(static_cast<osgUtil::CullVisitor*>(nv));
stateset->setTextureAttribute(
mSkyTextureUnit, skyTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
if (mOpaqueTextureUnit > 0)
stateset->setTextureAttribute(mOpaqueTextureUnit,
mSceneManager->getOpaqueDepthTex(nv->getTraversalNumber()), osg::StateAttribute::ON);
}
void PerViewUniformStateUpdater::applyLeft(osg::StateSet* stateset, osgUtil::CullVisitor* nv)
{
stateset->getUniform("projectionMatrix")->set(getEyeProjectionMatrix(0));
}
void PerViewUniformStateUpdater::applyRight(osg::StateSet* stateset, osgUtil::CullVisitor* nv)
{
stateset->getUniform("projectionMatrix")->set(getEyeProjectionMatrix(1));
}
void PerViewUniformStateUpdater::setProjectionMatrix(const osg::Matrixf& projectionMatrix)
{
mProjectionMatrix = projectionMatrix;
}
const osg::Matrixf& PerViewUniformStateUpdater::getProjectionMatrix() const
{
return mProjectionMatrix;
}
void PerViewUniformStateUpdater::enableSkyRTT(int skyTextureUnit, RTTNode* skyRTT)
{
mSkyTextureUnit = skyTextureUnit;
mSkyRTT = skyRTT;
}
osg::Matrixf PerViewUniformStateUpdater::getEyeProjectionMatrix(int view)
{
return Stereo::Manager::instance().computeEyeProjection(view, AutoDepth::isReversed());
}
SharedUniformStateUpdater::SharedUniformStateUpdater(float skyBlendingStartCoef)
: mSkyBlendingStartCoef(skyBlendingStartCoef)
{
}
void SharedUniformStateUpdater::setDefaults(osg::StateSet* stateset)
{
stateset->addUniform(new osg::Uniform("near", 0.f));
stateset->addUniform(new osg::Uniform("far", 0.f));
stateset->addUniform(new osg::Uniform("skyBlendingStart", 0.f));
stateset->addUniform(new osg::Uniform("screenRes", osg::Vec2f{}));
stateset->addUniform(new osg::Uniform("isReflection", false));
stateset->addUniform(new osg::Uniform("windSpeed", 0.0f));
stateset->addUniform(new osg::Uniform("playerPos", osg::Vec3f(0.f, 0.f, 0.f)));
stateset->addUniform(new osg::Uniform("useTreeAnim", false));
}
void SharedUniformStateUpdater::apply(osg::StateSet* stateset, osg::NodeVisitor* nv)
{
stateset->getUniform("near")->set(mNear);
stateset->getUniform("far")->set(mFar);
stateset->getUniform("skyBlendingStart")->set(mFar * mSkyBlendingStartCoef);
stateset->getUniform("screenRes")->set(mScreenRes);
stateset->getUniform("windSpeed")->set(mWindSpeed);
stateset->getUniform("playerPos")->set(mPlayerPos);
}
void SharedUniformStateUpdater::setNear(float near)
{
mNear = near;
}
void SharedUniformStateUpdater::setFar(float far)
{
mFar = far;
}
void SharedUniformStateUpdater::setScreenRes(float width, float height)
{
mScreenRes = osg::Vec2f(width, height);
}
void SharedUniformStateUpdater::setWindSpeed(float windSpeed)
{
mWindSpeed = windSpeed;
}
void SharedUniformStateUpdater::setPlayerPos(osg::Vec3f playerPos)
{
mPlayerPos = playerPos;
}
void StateUpdater::setDefaults(osg::StateSet* stateset)
{
osg::LightModel* lightModel = new osg::LightModel;
stateset->setAttribute(lightModel, osg::StateAttribute::ON);
osg::Fog* fog = new osg::Fog;
fog->setMode(osg::Fog::LINEAR);
stateset->setAttributeAndModes(fog, osg::StateAttribute::ON);
if (mWireframe)
{
osg::PolygonMode* polygonmode = new osg::PolygonMode;
polygonmode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
stateset->setAttributeAndModes(polygonmode, osg::StateAttribute::ON);
}
else
stateset->removeAttribute(osg::StateAttribute::POLYGONMODE);
}
void StateUpdater::apply(osg::StateSet* stateset, osg::NodeVisitor*)
{
osg::LightModel* lightModel
= static_cast<osg::LightModel*>(stateset->getAttribute(osg::StateAttribute::LIGHTMODEL));
lightModel->setAmbientIntensity(mAmbientColor);
osg::Fog* fog = static_cast<osg::Fog*>(stateset->getAttribute(osg::StateAttribute::FOG));
fog->setColor(mFogColor);
fog->setStart(mFogStart);
fog->setEnd(mFogEnd);
}
void StateUpdater::setAmbientColor(const osg::Vec4f& col)
{
mAmbientColor = col;
}
void StateUpdater::setFogColor(const osg::Vec4f& col)
{
mFogColor = col;
}
void StateUpdater::setFogStart(float start)
{
mFogStart = start;
}
void StateUpdater::setFogEnd(float end)
{
mFogEnd = end;
}
void StateUpdater::setWireframe(bool wireframe)
{
if (mWireframe != wireframe)
{
mWireframe = wireframe;
reset();
}
}
bool StateUpdater::getWireframe() const
{
return mWireframe;
}
}
+108
View File
@@ -0,0 +1,108 @@
#ifndef OPENMW_COMPONENTS_SCENEUTIL_STATEUPDATER_H
#define OPENMW_COMPONENTS_SCENEUTIL_STATEUPDATER_H
#include <osg/Matrixf>
#include <osg/Vec2f>
#include <osg/Vec3f>
#include <osg/Vec4f>
#include <components/sceneutil/statesetupdater.hpp>
namespace osg
{
class StateSet;
}
namespace Resource
{
class SceneManager;
}
namespace SceneUtil
{
class RTTNode;
class PerViewUniformStateUpdater final : public StateSetUpdater
{
public:
PerViewUniformStateUpdater(Resource::SceneManager* sceneManager, int opaqueTextureUnit = -1);
void setDefaults(osg::StateSet* stateset) override;
void apply(osg::StateSet* stateset, osg::NodeVisitor* nv) override;
void applyLeft(osg::StateSet* stateset, osgUtil::CullVisitor* nv) override;
void applyRight(osg::StateSet* stateset, osgUtil::CullVisitor* nv) override;
void setProjectionMatrix(const osg::Matrixf& projectionMatrix);
const osg::Matrixf& getProjectionMatrix() const;
void enableSkyRTT(int skyTextureUnit, RTTNode* skyRTT);
private:
osg::Matrixf getEyeProjectionMatrix(int view);
osg::Matrixf mProjectionMatrix;
int mSkyTextureUnit = -1;
RTTNode* mSkyRTT = nullptr;
Resource::SceneManager* mSceneManager;
int mOpaqueTextureUnit = -1;
};
class SharedUniformStateUpdater : public StateSetUpdater
{
public:
SharedUniformStateUpdater(float skyBlendingStartCoef);
void setDefaults(osg::StateSet* stateset) override;
void apply(osg::StateSet* stateset, osg::NodeVisitor* nv) override;
void setNear(float near);
void setFar(float far);
void setScreenRes(float width, float height);
void setWindSpeed(float windSpeed);
void setPlayerPos(osg::Vec3f playerPos);
private:
float mNear = 0.f;
float mFar = 0.f;
float mWindSpeed = 0.f;
float mSkyBlendingStartCoef = 0.f;
osg::Vec3f mPlayerPos;
osg::Vec2f mScreenRes;
};
class StateUpdater : public StateSetUpdater
{
public:
void setDefaults(osg::StateSet* stateset) override;
void apply(osg::StateSet* stateset, osg::NodeVisitor*) override;
void setAmbientColor(const osg::Vec4f& col);
void setFogColor(const osg::Vec4f& col);
void setFogStart(float start);
void setFogEnd(float end);
void setWireframe(bool wireframe);
bool getWireframe() const;
private:
osg::Vec4f mAmbientColor;
osg::Vec4f mFogColor;
float mFogStart = 0.f;
float mFogEnd = 0.f;
bool mWireframe = false;
};
}
#endif
-18
View File
@@ -8,8 +8,6 @@
#include <osg/FrameBufferObject>
#include <osg/Node>
#include <osg/NodeVisitor>
#include <osg/TexEnvCombine>
#include <osg/TexGen>
#include <osgUtil/CullVisitor>
#include <osgUtil/RenderStage>
@@ -85,20 +83,6 @@ namespace SceneUtil
else
{
stateset->setTextureMode(mTexUnit, GL_TEXTURE_2D, osg::StateAttribute::ON);
osg::TexGen* texGen = new osg::TexGen;
texGen->setMode(osg::TexGen::SPHERE_MAP);
stateset->setTextureAttributeAndModes(
mTexUnit, texGen, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
osg::TexEnvCombine* texEnv = new osg::TexEnvCombine;
texEnv->setSource0_RGB(osg::TexEnvCombine::CONSTANT);
texEnv->setConstantColor(mColor);
texEnv->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);
texEnv->setSource2_RGB(osg::TexEnvCombine::TEXTURE);
texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_COLOR);
stateset->setTextureAttributeAndModes(mTexUnit, texEnv, osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("envMapColor", mColor));
}
}
@@ -106,8 +90,6 @@ namespace SceneUtil
void GlowUpdater::removeTexture(osg::StateSet* stateset)
{
stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXTURE);
stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXGEN);
stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXENV);
stateset->removeTextureMode(mTexUnit, GL_TEXTURE_2D);
stateset->removeUniform("envMapColor");
@@ -24,6 +24,7 @@ namespace Settings
SettingValue<int> mStompMode{ mIndex, "Groundcover", "stomp mode", makeEnumSanitizerInt({ 0, 1, 2 }) };
SettingValue<int> mStompIntensity{ mIndex, "Groundcover", "stomp intensity",
makeEnumSanitizerInt({ 0, 1, 2 }) };
SettingValue<bool> mPointLighting{ mIndex, "Groundcover", "point lighting" };
};
}
@@ -19,7 +19,6 @@ namespace Settings
{
using WithIndex::WithIndex;
SettingValue<bool> mForceShaders{ mIndex, "Shaders", "force shaders" };
SettingValue<bool> mForcePerPixelLighting{ mIndex, "Shaders", "force per pixel lighting" };
SettingValue<bool> mClampLighting{ mIndex, "Shaders", "clamp lighting" };
SettingValue<bool> mAutoUseObjectNormalMaps{ mIndex, "Shaders", "auto use object normal maps" };
-4
View File
@@ -93,8 +93,6 @@ namespace Settings
{
switch (value)
{
case SceneUtil::LightingMethod::FFP:
return "legacy";
case SceneUtil::LightingMethod::PerObjectUniform:
return "shaders compatibility";
case SceneUtil::LightingMethod::SingleUBO:
@@ -548,8 +546,6 @@ namespace Settings
SceneUtil::LightingMethod parseLightingMethod(std::string_view value)
{
if (value == "legacy")
return SceneUtil::LightingMethod::FFP;
if (value == "shaders compatibility")
return SceneUtil::LightingMethod::PerObjectUniform;
if (value == "shaders")
+19
View File
@@ -743,4 +743,23 @@ namespace Shader
mHotReloadManager->mTriggerReload = true;
}
ShaderManager::DefineMap getDefaultDefines()
{
return {
{ "forcePPL", "0" },
{ "clamp", "1" },
{ "preLightEnv", "0" },
{ "radialFog", "0" },
{ "exponentialFog", "0" },
{ "reverseZ", "0" },
{ "waterRefraction", "0" },
{ "classicFalloff", "1" },
{ "skyBlending", "0" },
{ "disableNormals", "1" },
{ "useGPUShader4", "0" },
{ "useOVR_multiview", "0" },
{ "distorionRTRatio", "0" },
{ "numViews", "1" },
};
}
}
+2
View File
@@ -139,6 +139,8 @@ namespace Shader
bool parseDirectives(std::string& source, std::vector<std::string>& linkedShaderTemplateNames,
const ShaderManager::DefineMap& defines, const ShaderManager::DefineMap& globalDefines,
const std::string& templateName);
ShaderManager::DefineMap getDefaultDefines();
}
#endif
+4 -143
View File
@@ -44,7 +44,6 @@ namespace Shader
* the TypeMemberPair as that uniquely identifies which of those StateAttributes it was we're tracking.
* Not all StateSet features have been added yet - we implement an equivalently-named method to each of the StateSet
* methods called in createProgram, and implement new ones as they're needed.
* When expanding tracking to cover new things, ensure they're accounted for in ensureFFP.
*/
class AddedState : public osg::Object
{
@@ -174,8 +173,7 @@ namespace Shader
};
ShaderVisitor::ShaderRequirements::ShaderRequirements()
: mShaderRequired(false)
, mColorMode(0)
: mColorMode(0)
, mMaterialOverridden(false)
, mAlphaTestOverridden(false)
, mAlphaBlendOverridden(false)
@@ -196,7 +194,6 @@ namespace Shader
ShaderVisitor::ShaderVisitor(
ShaderManager& shaderManager, Resource::ImageManager& imageManager, const std::string& defaultShaderPrefix)
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
, mForceShaders(false)
, mAllowedToModifyStateSets(true)
, mAutoUseNormalMaps(false)
, mAutoUseSpecularMaps(false)
@@ -210,11 +207,6 @@ namespace Shader
{
}
void ShaderVisitor::setForceShaders(bool force)
{
mForceShaders = force;
}
void ShaderVisitor::apply(osg::Node& node)
{
bool needPop = false;
@@ -306,9 +298,6 @@ namespace Shader
if (mAllowedToModifyStateSets)
writableStateSet = node.getStateSet();
const osg::StateSet::TextureAttributeList& texAttributes = stateset->getTextureAttributeList();
bool shaderRequired = false;
if (node.getUserValue("shaderRequired", shaderRequired) && shaderRequired)
mRequirements.back().mShaderRequired = true;
bool softEffect = false;
if (node.getUserValue(Misc::OsgUserValues::sXSoftEffect, softEffect) && softEffect)
@@ -352,12 +341,6 @@ namespace Shader
if (texName == "normalMap")
{
mRequirements.back().mTexStageRequiringTangents = unit;
mRequirements.back().mShaderRequired = true;
if (!writableStateSet)
writableStateSet = getWritableStateSet(node);
// normal maps are by default off since the FFP can't render them, now that we'll use
// shaders switch to On
writableStateSet->setTextureMode(unit, GL_TEXTURE_2D, osg::StateAttribute::ON);
normalMap = texture;
}
else if (texName == "diffuseMap")
@@ -366,7 +349,6 @@ namespace Shader
// Oblivion parallax
if (node.getUserValue("applyMode", applyMode) && applyMode == 4)
{
mRequirements.back().mShaderRequired = true;
mRequirements.back().mDiffuseHeight = true;
mRequirements.back().mTexStageRequiringTangents = unit;
}
@@ -377,23 +359,6 @@ namespace Shader
else if (texName == "bumpMap")
{
bumpMap = texture;
mRequirements.back().mShaderRequired = true;
if (!writableStateSet)
writableStateSet = getWritableStateSet(node);
// Bump maps are off by default as well
writableStateSet->setTextureMode(unit, GL_TEXTURE_2D, osg::StateAttribute::ON);
}
else if (texName == "envMap" && mApplyLightingToEnvMaps)
{
mRequirements.back().mShaderRequired = true;
}
else if (texName == "glossMap")
{
mRequirements.back().mShaderRequired = true;
if (!writableStateSet)
writableStateSet = getWritableStateSet(node);
// As well as gloss maps
writableStateSet->setTextureMode(unit, GL_TEXTURE_2D, osg::StateAttribute::ON);
}
}
else
@@ -450,7 +415,6 @@ namespace Shader
osg::StateAttribute::ON);
mRequirements.back().mTextures[unit] = "normalMap";
mRequirements.back().mTexStageRequiringTangents = unit;
mRequirements.back().mShaderRequired = true;
mRequirements.back().mNormalHeight = normalHeight;
}
}
@@ -494,7 +458,6 @@ namespace Shader
writableStateSet->setTextureAttributeAndModes(
unit, new SceneUtil::TextureType("specularMap"), osg::StateAttribute::ON);
mRequirements.back().mTextures[unit] = "specularMap";
mRequirements.back().mShaderRequired = true;
}
}
}
@@ -606,12 +569,6 @@ namespace Shader
void ShaderVisitor::createProgram(const ShaderRequirements& reqs)
{
if (!reqs.mShaderRequired && !mForceShaders)
{
ensureFFP(*reqs.mNode);
return;
}
/**
* The shader visitor is supposed to be idempotent and undoable.
* That means we need to back up state we've removed (so it can be restored and/or considered by further
@@ -793,107 +750,11 @@ namespace Shader
}
}
void ShaderVisitor::ensureFFP(osg::Node& node)
{
if (!node.getStateSet() || !node.getStateSet()->getAttribute(osg::StateAttribute::PROGRAM))
return;
osg::StateSet* writableStateSet = nullptr;
if (mAllowedToModifyStateSets)
writableStateSet = node.getStateSet();
else
writableStateSet = getWritableStateSet(node);
/**
* We might have been using shaders temporarily with the node (e.g. if a GlowUpdater applied a temporary
* environment map for a temporary enchantment).
* We therefore need to remove any state doing so added, and restore any that it removed.
* This is kept track of in createProgram in the StateSet's userdata.
* If new classes of state get added, handling it here is required - not all StateSet features are implemented
* in AddedState yet as so far they've not been necessary.
* Removed state requires no particular special handling as it's dealt with by merging StateSets.
* We don't need to worry about state in writableStateSet having the OVERRIDE flag as if it's in both, it's also
* in addedState, and gets removed first.
*/
// user data is normally shallow copied so shared with the original stateset - we'll need to copy before edits
osg::ref_ptr<osg::UserDataContainer> writableUserData;
if (osg::ref_ptr<AddedState> addedState = getAddedState(*writableStateSet))
{
if (mAllowedToModifyStateSets)
writableUserData = writableStateSet->getUserDataContainer();
else
writableUserData = getWritableUserDataContainer(*writableStateSet);
unsigned int index = writableUserData->getUserObjectIndex("addedState");
writableUserData->removeUserObject(index);
// O(n log n) to use StateSet::removeX, but this is O(n)
for (auto itr = writableStateSet->getUniformList().begin();
itr != writableStateSet->getUniformList().end();)
{
if (addedState->hasUniform(itr->first))
writableStateSet->getUniformList().erase(itr++);
else
++itr;
}
for (auto itr = writableStateSet->getModeList().begin(); itr != writableStateSet->getModeList().end();)
{
if (addedState->hasMode(itr->first))
writableStateSet->getModeList().erase(itr++);
else
++itr;
}
// StateAttributes track the StateSets they're attached to
// We don't have access to the function to do that, and can't call removeAttribute with an iterator
for (const auto& [type, member] : addedState->getAttributes())
writableStateSet->removeAttribute(type, member);
for (unsigned int unit = 0; unit < writableStateSet->getTextureModeList().size(); ++unit)
{
for (auto itr = writableStateSet->getTextureModeList()[unit].begin();
itr != writableStateSet->getTextureModeList()[unit].end();)
{
if (addedState->hasTextureMode(unit, itr->first))
writableStateSet->getTextureModeList()[unit].erase(itr++);
else
++itr;
}
}
for (const auto& [unit, attributeList] : addedState->getTextureAttributes())
{
for (const auto& [type, member] : attributeList)
writableStateSet->removeTextureAttribute(unit, type);
}
}
if (osg::ref_ptr<osg::StateSet> removedState = getRemovedState(*writableStateSet))
{
if (!writableUserData)
{
if (mAllowedToModifyStateSets)
writableUserData = writableStateSet->getUserDataContainer();
else
writableUserData = getWritableUserDataContainer(*writableStateSet);
}
unsigned int index = writableUserData->getUserObjectIndex("removedState");
writableUserData->removeUserObject(index);
writableStateSet->merge(*removedState);
}
}
bool ShaderVisitor::adjustGeometry(osg::Geometry& sourceGeometry, const ShaderRequirements& reqs)
{
bool useShader = reqs.mShaderRequired || mForceShaders;
bool generateTangents = reqs.mTexStageRequiringTangents != -1;
bool changed = false;
if (mAllowedToModifyStateSets && (useShader || generateTangents))
if (mAllowedToModifyStateSets)
{
// make sure that all UV sets are there
// it's not safe to assume there's one for slot zero, so try and use one from another slot if possible
@@ -923,6 +784,8 @@ namespace Shader
}
}
bool generateTangents = reqs.mTexStageRequiringTangents != -1;
if (generateTangents)
{
osg::ref_ptr<osgUtil::TangentSpaceGenerator> generator(new osgUtil::TangentSpaceGenerator);
@@ -952,8 +815,6 @@ namespace Shader
createProgram(reqs);
}
else
ensureFFP(geometry);
if (needPop)
popRequirements();
-8
View File
@@ -23,10 +23,6 @@ namespace Shader
void setProgramTemplate(const osg::Program* programTemplate) { mProgramTemplate = programTemplate; }
/// By default, only bump mapped objects will have a shader added to them.
/// Setting force = true will cause all objects to render using shaders, regardless of having a bump map.
void setForceShaders(bool force);
/// Set if we are allowed to modify StateSets encountered in the graph (default true).
/// @par If set to false, then instead of modifying, the StateSet will be cloned and this new StateSet will be
/// assigned to the node.
@@ -64,7 +60,6 @@ namespace Shader
void popRequirements();
private:
bool mForceShaders;
bool mAllowedToModifyStateSets;
bool mAutoUseNormalMaps;
@@ -93,8 +88,6 @@ namespace Shader
// <texture stage, texture name>
std::map<int, std::string> mTextures;
bool mShaderRequired;
int mColorMode;
bool mMaterialOverridden;
@@ -125,7 +118,6 @@ namespace Shader
std::string mDefaultShaderPrefix;
void createProgram(const ShaderRequirements& reqs);
void ensureFFP(osg::Node& node);
bool adjustGeometry(osg::Geometry& sourceGeometry, const ShaderRequirements& reqs);
osg::ref_ptr<const osg::Program> mProgramTemplate;
+4 -16
View File
@@ -167,11 +167,6 @@ namespace Terrain
std::vector<osg::ref_ptr<osg::Image>> blendmaps;
mStorage->getBlendmaps(chunkSize, chunkCenter, blendmaps, layerList, mWorldspace);
bool useShaders = mSceneManager->getForceShaders();
if (!mSceneManager->getClampLighting())
useShaders = true; // always use shaders when lighting is unclamped, this is to avoid lighting seams between
// a terrain chunk with normal maps and one without normal maps
std::vector<TextureLayer> layers;
{
for (std::vector<LayerInfo>::const_iterator it = layerList.begin(); it != layerList.end(); ++it)
@@ -185,16 +180,10 @@ namespace Terrain
if (!forCompositeMap && !it->mNormalMap.empty())
textureLayer.mNormalMap = mTextureManager->getTexture(it->mNormalMap);
if (it->requiresShaders())
useShaders = true;
layers.push_back(textureLayer);
}
}
if (forCompositeMap)
useShaders = false;
std::vector<osg::ref_ptr<osg::Texture2D>> blendmapTextures;
for (std::vector<osg::ref_ptr<osg::Image>>::const_iterator it = blendmaps.begin(); it != blendmaps.end(); ++it)
{
@@ -208,8 +197,8 @@ namespace Terrain
int tileCount = mStorage->getTextureTileCount(chunkSize, mWorldspace);
return ::Terrain::createPasses(useShaders, mSceneManager, layers, blendmapTextures, tileCount,
static_cast<float>(tileCount), ESM::isEsm4Ext(mWorldspace));
return ::Terrain::createPasses(mSceneManager, layers, blendmapTextures, tileCount,
static_cast<float>(tileCount), forCompositeMap, ESM::isEsm4Ext(mWorldspace));
}
osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Vec2f& chunkCenter, unsigned char lod,
@@ -302,9 +291,8 @@ namespace Terrain
layer.mDiffuseMap = compositeMap->mTexture;
layer.mParallax = false;
layer.mSpecular = false;
geometry->setPasses(::Terrain::createPasses(
mSceneManager->getForceShaders() || !mSceneManager->getClampLighting(), mSceneManager,
std::vector<TextureLayer>(1, layer), std::vector<osg::ref_ptr<osg::Texture2D>>(), 1, 1.f));
geometry->setPasses(::Terrain::createPasses(mSceneManager, std::vector<TextureLayer>(1, layer),
std::vector<osg::ref_ptr<osg::Texture2D>>(), 1, 1.f, false));
}
else
{
@@ -17,8 +17,6 @@ namespace Terrain
setCullingActive(false);
mFBO = new osg::FrameBufferObject;
getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
}
CompositeMapRenderer::~CompositeMapRenderer() = default;
+22 -87
View File
@@ -4,7 +4,6 @@
#include <osg/Capability>
#include <osg/Depth>
#include <osg/Fog>
#include <osg/TexEnvCombine>
#include <osg/TexMat>
#include <osg/Texture2D>
@@ -154,47 +153,6 @@ namespace
}
};
class TexEnvCombine
{
public:
static const osg::ref_ptr<osg::TexEnvCombine>& value()
{
static TexEnvCombine instance;
return instance.mValue;
}
private:
osg::ref_ptr<osg::TexEnvCombine> mValue;
TexEnvCombine()
: mValue(new osg::TexEnvCombine)
{
mValue->setCombine_RGB(osg::TexEnvCombine::REPLACE);
mValue->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
}
};
class DiscardAlphaCombine
{
public:
static const osg::ref_ptr<osg::TexEnvCombine>& value()
{
static DiscardAlphaCombine instance;
return instance.mValue;
}
private:
osg::ref_ptr<osg::TexEnvCombine> mValue;
DiscardAlphaCombine()
: mValue(new osg::TexEnvCombine)
{
mValue->setCombine_Alpha(osg::TexEnvCombine::REPLACE);
mValue->setSource0_Alpha(osg::TexEnvCombine::CONSTANT);
mValue->setConstantColor(osg::Vec4(0.0, 0.0, 0.0, 1.0));
}
};
class UniformCollection
{
public:
@@ -221,9 +179,9 @@ namespace
namespace Terrain
{
std::vector<osg::ref_ptr<osg::StateSet>> createPasses(bool useShaders, Resource::SceneManager* sceneManager,
std::vector<osg::ref_ptr<osg::StateSet>> createPasses(Resource::SceneManager* sceneManager,
const std::vector<TextureLayer>& layers, const std::vector<osg::ref_ptr<osg::Texture2D>>& blendmaps,
int blendmapScale, float layerTileSize, bool esm4terrain)
int blendmapScale, float layerTileSize, bool isComposite, bool esm4terrain)
{
auto& shaderManager = sceneManager->getShaderManager();
std::vector<osg::ref_ptr<osg::StateSet>> passes;
@@ -253,26 +211,28 @@ namespace Terrain
}
}
if (useShaders)
stateset->setTextureAttributeAndModes(0, it->mDiffuseMap);
stateset->addUniform(UniformCollection::value().mDiffuseMap);
if (layerTileSize != 1.f)
stateset->setTextureAttributeAndModes(0, LayerTexMat::value(layerTileSize), osg::StateAttribute::ON);
if (!blendmaps.empty())
{
stateset->setTextureAttributeAndModes(0, it->mDiffuseMap);
if (layerTileSize != 1.f)
stateset->setTextureAttributeAndModes(
0, LayerTexMat::value(layerTileSize), osg::StateAttribute::ON);
stateset->addUniform(UniformCollection::value().mDiffuseMap);
if (!blendmaps.empty())
{
osg::ref_ptr<osg::Texture2D> blendmap = blendmaps.at(blendmapIndex++);
stateset->setTextureAttributeAndModes(1, blendmap.get());
if (!esm4terrain)
stateset->setTextureAttributeAndModes(1, BlendmapTexMat::value(blendmapScale));
stateset->addUniform(UniformCollection::value().mBlendMap);
}
osg::ref_ptr<osg::Texture2D> blendmap = blendmaps.at(blendmapIndex++);
stateset->setTextureAttributeAndModes(1, blendmap.get());
if (!esm4terrain)
stateset->setTextureAttributeAndModes(1, BlendmapTexMat::value(blendmapScale));
stateset->addUniform(UniformCollection::value().mBlendMap);
}
if (isComposite)
{
stateset->setAttributeAndModes(
shaderManager.getProgram("terrain_composite", { { "blendMap", !blendmaps.empty() ? "1" : "0" } }));
}
else
{
bool parallax = it->mNormalMap && it->mParallax;
bool reconstructNormalZ = false;
@@ -309,31 +269,6 @@ namespace Terrain
stateset->setAttributeAndModes(shaderManager.getProgram("terrain", defineMap));
stateset->addUniform(UniformCollection::value().mColorMode);
}
else
{
// Add the actual layer texture
osg::ref_ptr<osg::Texture2D> tex = it->mDiffuseMap;
stateset->setTextureAttributeAndModes(0, tex.get());
if (layerTileSize != 1.f)
stateset->setTextureAttributeAndModes(
0, LayerTexMat::value(layerTileSize), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(0, DiscardAlphaCombine::value(), osg::StateAttribute::ON);
// Multiply by the alpha map
if (!blendmaps.empty())
{
osg::ref_ptr<osg::Texture2D> blendmap = blendmaps.at(blendmapIndex++);
stateset->setTextureAttributeAndModes(1, blendmap.get());
// This is to map corner vertices directly to the center of a blendmap texel.
if (!esm4terrain)
stateset->setTextureAttributeAndModes(1, BlendmapTexMat::value(blendmapScale));
stateset->setTextureAttributeAndModes(1, TexEnvCombine::value(), osg::StateAttribute::ON);
}
}
passes.push_back(stateset);
}
+2 -2
View File
@@ -24,9 +24,9 @@ namespace Terrain
bool mSpecular = false;
};
std::vector<osg::ref_ptr<osg::StateSet>> createPasses(bool useShaders, Resource::SceneManager* sceneManager,
std::vector<osg::ref_ptr<osg::StateSet>> createPasses(Resource::SceneManager* sceneManager,
const std::vector<TextureLayer>& layers, const std::vector<osg::ref_ptr<osg::Texture2D>>& blendmaps,
int blendmapScale, float layerTileSize, bool esm4terrain = false);
int blendmapScale, float layerTileSize, bool isComposite, bool esm4terrain = false);
}
#endif
@@ -114,5 +114,4 @@ Camera Settings
through OpenGL extensions. The exception is macOS, which has since dropped
development of OpenGL drivers. If unsupported, this setting has no effect.
Note, this will force OpenMW to use shaders as if :ref:`force shaders` was enabled.
The performance impact of this feature should be negligible.
@@ -122,7 +122,6 @@ Fog Settings
By default, the fog becomes thicker proportionally to your distance from the clipping plane set at the clipping distance, which causes distortion at the edges of the screen.
This setting makes the fog use the actual eye point distance (or so called Euclidean distance) to calculate the fog, which makes the fog look less artificial, especially if you have a wide FOV.
Note that the rendering will act as if you have 'force shaders' option enabled with this on, which means that shaders will be used to render all objects and the terrain.
.. omw-setting::
:title: exponential fog
@@ -132,7 +131,6 @@ Fog Settings
:location: :bdg-success:`Launcher > Settings > Visuals > Fog`
Similar to "radial fog" but uses an exponential formula for the fog.
Note that the rendering will act as if you have 'force shaders' option enabled with this on, which means that shaders will be used to render all objects and the terrain.
.. omw-setting::
:title: sky blending
@@ -143,7 +141,6 @@ Fog Settings
Whether to use blending with the sky for everything that is close to the clipping plane.
If enabled the clipping plane becomes invisible.
Note that the rendering will act as if you have 'force shaders' option enabled with this on, which means that shaders will be used to render all objects and the terrain.
.. omw-setting::
:title: sky blending start
@@ -90,3 +90,12 @@ Groundcover Settings
- 50
- 20
- Gentle levels — subtle and restrained.
.. omw-setting::
:title: point lighting
:type: boolean
:range: true, false
:default: true
When enabled, groundcover will receive lighting from point light sources.
@@ -1,16 +1,6 @@
Shaders Settings
################
.. omw-setting::
:title: force shaders
:type: boolean
:range: true, false
:default: false
Force rendering with shaders for all objects, even those that do not strictly need them.
Required if enhancements like shadows or reverse z are enabled.
May have a significant performance impact.
.. omw-setting::
:title: force per pixel lighting
:type: boolean
@@ -30,7 +20,6 @@ Shaders Settings
Restrict lighting to a maximum of (1,1,1) on shader objects.
Prevents overly bright or shifted colors but can dull lighting.
Terrain is always drawn with shaders to prevent seams.
.. omw-setting::
:title: auto use object normal maps
@@ -111,13 +100,12 @@ Shaders Settings
.. omw-setting::
:title: lighting method
:type: string
:range: legacy | shaders compatibility | shaders
:range: shaders compatibility | shaders
:default: shaders compatibility
:location: :bdg-info:`In Game > Settings > Options > Video > Lights` :bdg-success:`Launcher > Settings > Visuals > Lighting`
Controls internal light source handling:
- `legacy`: fixed-function pipeline, max 8 lights per object.
- `shaders compatibility`: removes light limit, better attenuation, recommended for older hardware.
- `shaders compatibility`: recommended for older hardware.
- `shaders`: modern lighting approach, higher light counts, better for modern GPUs.
.. omw-setting::
@@ -10,7 +10,6 @@ Shadows Settings
Enable or disable shadow rendering using shadow mapping.
More realistic but may reduce performance.
Forces shaders usage like :ref:`force shaders`.
.. omw-setting::
:title: number of shadow maps
@@ -142,7 +142,6 @@ Terrain Settings
If this limit is too small, lighting issues arising due to merged objects
being considered a single object, and they may disrupt your gameplay experience.
Consider increasing the 'max lights' setting value in the 'Shaders' section to avoid this issue.
With the Legacy lighting mode this limit can not be increased (only 8 sources can be used).
.. omw-setting::
:title: object paging merge factor
@@ -10,10 +10,6 @@ cracks and other small details.
`Specular mapping`_ is used to vary the shininess/specularity along the surface of an object.
The prerequisite to using these techniques are
`shaders <https://en.wikipedia.org/wiki/Shader>`_.
OpenMW automatically uses shaders for objects with these mapping techniques.
Normal Mapping
##############
@@ -80,7 +76,7 @@ The above settings are not enabled by default to prevent incompatibilities
with mods that may be inadvertently using these naming schemes.
On the topic of shader settings,
you may be interested in these three settings as well: :ref:`force shaders`,
you may be interested in these two settings as well:
:ref:`force per pixel lighting`, and :ref:`clamp lighting`.
In particular, `clamp lighting = false` makes normal maps look much better!
+1 -5
View File
@@ -114,8 +114,6 @@ ForcePerPixelLighting: "Beleuchtung pro Pixel"
ForcePerPixelLightingTooltip: |-
Erzwingt die Verwendung der Beleuchtung pro Pixel. Standardmäßig verwenden nur Bump- und Normal-mapped-Objekte eine Beleuchtung pro Pixel.
Betrifft nur mit Shadern gezeichnete Objekte.
Die Aktivierung der Per-Pixel-Beleuchtung führt zu visuellen Unterschieden zur ursprünglichen Morrowind-Engine, da bestimmte Lichter in Morrowind auf Vertex-Beleuchtung angewiesen sind, um wie beabsichtigt auszusehen.
Beachten Sie, dass Bodendecker-Shader und Partikeleffekte diese Einstellung ignorieren.
@@ -130,7 +128,6 @@ InvertYAxis: "Y-Achse invertieren"
Language: "Sprache"
LanguageNote: "Hinweis: Diese Einstellungen wirken sich nicht auf Texte aus ESM-Dateien aus."
LightingMethod: "Beleuchtungsmethode"
LightingMethodLegacy: "Veraltet"
LightingMethodShaders: "Shader"
LightingMethodShadersCompatibility: "Shader (Kompatibilitätsmodus)"
LightingResetToDefaults: "Einstellungen wirklich zurücksetzen? Das Ändern der „Beleuchtungsmethode“ erfordert einen Neustart."
@@ -142,8 +139,7 @@ LightsFadeStartMultiplier: "Multiplikator für Startwert der Lichtabblendung"
LightsFadeStartMultiplierValue: "Multiplikator für Startwert der Lichtabblendung ({value, number, ::.00})"
LightsFadeStartMultiplierTooltip: "Standard: 0,85\nBruchteil der maximalen Lichtreichweite, bei der Lichtquellen langsam zu verblassen beginnen.\n\nKleinere Werte führen zu einem sanfteren Übergang, der allerdings bereits bei geringerer Entfernung startet; größere Werte machen den Übergang abrupter, betreffen aber nur weiter entfernte Lichtquellen."
LightsLightingMethodTooltip: "Legt die interne Behandlung von Lichtquellen fest.\n\n
„Veraltet“ verwendet immer bis zu 8 Lichtquellen pro Objekt und führt zu Ergebnissen, die denen der Original-Engine am ähnlichsten sind.\n\n
„Shader (Kompatibilitätsmodus)“ entfernt das Maximum von 8 Lichtquellen pro Objekt; Bodenvegetation wird von Lichtquellen beleuchtet. Es wird empfohlen, diese Option für ältere Hardware und Maximalwerte für Lichtquellen nahe 8 zu verwenden.\n\n
„Shader (Kompatibilitätsmodus)“ Es wird empfohlen, diese Option für ältere Hardware und Maximalwerte für Lichtquellen nahe 8 zu verwenden.\n\n
„Shader“ bietet alle Vorteile von „Shader (Kompatibilitätsmodus)“, nutzt aber einen moderneren Ansatz, der größere Maximalwerte für Lichtquellen bei geringen bis keinen Leistungseinbußen ermöglicht. Funktioniert möglicherweise nicht auf älterer Hardware."
LightsMaximumDistance: "Maximale Lichtreichweite"
LightsMaximumDistanceValue: "Maximale Lichtreichweite ({value, number, :: group-off})"
+2 -6
View File
@@ -114,8 +114,6 @@ ForcePerPixelLighting: "Per-Pixel Lighting"
ForcePerPixelLightingTooltip: |-
Force the use of per-pixel lighting. By default, only bump- and normal-mapped objects use per-pixel lighting.
Only affects objects drawn with shaders.
Enabling per-pixel lighting results in visual differences to the original MW engine as certain lights in Morrowind rely on vertex lighting to look as intended.
Note that groundcover shaders and particle effects ignore this setting.
@@ -130,7 +128,6 @@ InvertYAxis: "Invert Y Axis"
Language: "Language"
LanguageNote: "Note: these settings do not affect strings from ESM files."
LightingMethod: "Lighting Method"
LightingMethodLegacy: "Legacy"
LightingMethodShaders: "Shaders"
LightingMethodShadersCompatibility: "Shaders (compatibility)"
LightingResetToDefaults: "Resets to default values, would you like to continue? Changes to lighting method will require a restart."
@@ -142,8 +139,7 @@ LightsFadeStartMultiplier: "Fade Start Multiplier"
LightsFadeStartMultiplierValue: "Fade Start Multiplier ({value, number, ::.00})"
LightsFadeStartMultiplierTooltip: "Default: 0.85\nFraction of maximum distance at which lights will start to fade.\n\nSet this to a low value for slower transitions or a high value for quicker transitions."
LightsLightingMethodTooltip: "Set the internal handling of light sources.\n\n
\"Legacy\" always uses 8 lights per object. It provides results most similar to Morrowind's lighting.\n\n
\"Shaders (compatibility)\" 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.\n\n
\"Shaders (compatibility)\" It is recommended to use this with older hardware and a light limit closer to 8.\n\n
\"Shaders\" carries all of the benefits that \"Shaders (compatibility)\" does, but uses a modern approach that allows for a higher max lights count with little to no performance penalties on modern hardware."
LightsMaximumDistance: "Maximum Light Distance"
LightsMaximumDistanceValue: "Maximum Light Distance ({value, number, :: group-off})"
@@ -159,7 +155,7 @@ MatchSunlightToSunTooltip: |-
This option makes the sun light source's position match the sun's position.
MaxLights: "Max Lights"
MaxLightsValue: "Max Lights ({value, number, :: group-off})"
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."
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 in Morrowind."
MenuHelpDelay: "Menu Help Delay"
MenuTransparency: "Menu Transparency"
MouseAndKeyboard: "Mouse/Keyboard"
+2 -6
View File
@@ -114,8 +114,6 @@ ForcePerPixelLighting: "Éclairage par pixel"
ForcePerPixelLightingTooltip: |-
Force l'usage de l'éclairage par pixel. Par défaut, seuls les objets avec des "bump" et "normal" maps utilisent l'éclairage par pixel.
Affecte uniquement les objets rendus via des shaders.
Activer l'éclairage par pixel donne des résultats visuels différents de ceux du moteur de jeu original, car certaines lumières de Morrowind furent implémentées pour un éclairage par vertex.
Les shaders de végétation au sol et les particules ignorent cette option.
@@ -130,7 +128,6 @@ InvertYAxis: "Inverser l'axe Y"
Language: "Localisation"
LanguageNote: "Note: Ce paramètre n'affecte pas les textes des fichiers ESM."
LightingMethod: "Méthode d'affichage des lumières"
LightingMethodLegacy: "Traditionnelle"
LightingMethodShaders: "Shaders"
LightingMethodShadersCompatibility: "Shaders (mode de compatibilité)"
LightingResetToDefaults: "Voulez-vous réinitialiser les paramètres d'affichage des lumières à leur valeur par défaut ? Ces changements requièrent un redémarrage de l'application."
@@ -142,8 +139,7 @@ LightsFadeStartMultiplier: "Seuil de perte d'éclat lumineux"
LightsFadeStartMultiplierValue: "Seuil de perte d'éclat lumineux ({value, number, ::.00})"
LightsFadeStartMultiplierTooltip: "valeur par défaut: 0.85\nFraction de la distance maximale d'une source à partir de laquelle l'intensité lumineuse commence à décroître.\n\nSélectionnez une valeur basse pour une transition douce ou une valeur plus élevée pour une transition plus abrupte."
LightsLightingMethodTooltip: "Définit la gestion des sources lumineuses :\n\n
\"Traditionnelle\" Chaque objet est éclairé par 8 sources lumineuses. Cet méthode est la plus proche du jeu original.\n\n
\"Shaders (mode de compatibilité)\" supprime la limite des 8 sources lumineuses. Cette méthode permet d'éclairer la végétation au sol. Ce choix est recommandé pour les ordinateurs plus anciens avec un nombre de sources lumineuses proche de 8.\n\n
\"Shaders (mode de compatibilité)\" Ce choix est recommandé pour les ordinateurs plus anciens avec un nombre de sources lumineuses proche de 8.\n\n
\"Shaders\" offre tous les bénéfices apportés par \"Shaders (mode de compatibilité)\", mais utilise une approche moderne. Celle-ci permet, sur du matériel moderne, d'augmenter le nombre de sources lumineuses par objet sans perte de performance."
LightsMaximumDistance: "Distance maximale des sources lumineuses"
LightsMaximumDistanceValue: "Distance maximale des sources lumineuses ({value, number, :: group-off})"
@@ -159,7 +155,7 @@ MatchSunlightToSunTooltip: |-
Cette option aligne la source lumineuse du soleil sur la position réelle du soleil.
MaxLights: "Maximum de sources lumineuses"
MaxLightsValue: "Maximum de sources lumineuses ({value, number, :: group-off})"
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."
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 à ce que l'on voit dans Morrowind."
MenuHelpDelay: "Délai d'affichage du menu d'aide"
MenuTransparency: "Transparence des menus"
MouseAndKeyboard: "Souris/Clavier"
+2 -6
View File
@@ -114,8 +114,6 @@ ForcePerPixelLighting: "Oświetlenie per-piksel"
ForcePerPixelLightingTooltip: |-
Wymusza oświetlenie per-pikselowe. Domyślnie tylko obiekty z mapami wypukłości lub normalnymi używają tej metody.
Dotyczy tylko obiektów renderowanych z użyciem shaderów.
Może powodować różnice wizualne względem oryginalnego silnika Morrowind.
Shadery trawy i efekty cząsteczkowe ignorują to ustawienie.
@@ -130,7 +128,6 @@ InvertYAxis: "Odwróć oś Y"
Language: "Język"
LanguageNote: "Uwaga: te ustawienia nie wpływają na teksty z plików ESM."
LightingMethod: "Metoda oświetlenia"
LightingMethodLegacy: "Klasyczna"
LightingMethodShaders: "Shadery"
LightingMethodShadersCompatibility: "Shadery (kompatybilne)"
LightingResetToDefaults: "Przywrócić domyślne wartości? Zmiany w metodzie oświetlenia wymagają ponownego uruchomienia."
@@ -142,8 +139,7 @@ LightsFadeStartMultiplier: "Mnożnik początku zanikania"
LightsFadeStartMultiplierValue: "Mnożnik początku zanikania ({value, number, ::.00})"
LightsFadeStartMultiplierTooltip: "Domyślnie: 0.85\nProcent maksymalnego zasięgu, w którym światła zaczną zanikać.\n\nNiska wartość = wolniejsze przejścia.\nWysoka wartość = szybsze przejścia."
LightsLightingMethodTooltip: "Ustawia wewnętrzne przetwarzanie źródeł światła.\n\n
\"Klasyczna\" zawsze używa 8 świateł na obiekt. Najbardziej przypomina oryginalne oświetlenie Morrowinda.\n\n
\"Shadery (kompatybilne)\" usuwa limit 8 świateł. Obsługuje również oświetlenie trawy. Zalecane dla starszego sprzętu.\n\n
\"Shadery (kompatybilne)\" Zalecane dla starszego sprzętu.\n\n
\"Shadery\" oferuje te same zalety co wersja kompatybilna, ale działa nowocześnie i pozwala na więcej świateł bez dużych kosztów wydajności."
LightsMaximumDistance: "Maksymalny zasięg światła"
LightsMaximumDistanceValue: "Maksymalny zasięg światła ({value, number, :: group-off})"
@@ -159,7 +155,7 @@ MatchSunlightToSunTooltip: |-
Ta opcja sprawia, że źródło światła słonecznego zgadza się z faktyczną pozycją słońca.
MaxLights: "Maksymalna liczba świateł"
MaxLightsValue: "Maksymalna liczba świateł ({value, number, :: group-off})"
MaxLightsTooltip: "Domyślnie: 8\nMaksymalna liczba świateł na obiekt.\n\nNiska wartość = efekt 'wyskakiwania' świateł, jak w klasycznym trybie."
MaxLightsTooltip: "Domyślnie: 8\nMaksymalna liczba świateł na obiekt.\n\nNiska wartość = efekt 'wyskakiwania' świateł, jak w Morrowind."
MenuHelpDelay: "Opóźnienie pomocy w menu"
MenuTransparency: "Przezroczystość menu"
MouseAndKeyboard: "Mysz i klawiatura"
+2 -6
View File
@@ -114,8 +114,6 @@ ForcePerPixelLighting: "Попиксельное освещение"
ForcePerPixelLightingTooltip: |-
Использовать попиксельное освещение принудительно. По умолчанию его используют только объекты, использующие карты бампа и карты нормалей.
Влияет только на объекты, отрисовываемые шейдерами.
Включение попиксельного освещения приводит к визуальным отличиям по сравнению с оригинальным движком Morrowind, так как некоторые источники света в Morrowind полагаются на повершинное освещение для того, чтобы выглядеть, как задумывалось.
Обратите внимание, что шейдеры растительности и системы частиц игнорируют эту настройку.
@@ -130,7 +128,6 @@ InvertYAxis: "Инвертировать ось Y"
Language: "Язык"
LanguageNote: "Примечание: эти настройки не затрагивают строки из ESM-файлов."
LightingMethod: "Способ освещения"
LightingMethodLegacy: "Устаревший"
LightingMethodShaders: "Шейдеры"
LightingMethodShadersCompatibility: "Шейдеры (режим совм-ти)"
LightingResetToDefaults: "Обнулить настройки освещения? Смена метода освещения вступит в силу только после перезапуска приложения."
@@ -142,8 +139,7 @@ LightsFadeStartMultiplier: "Множитель начала затухания"
LightsFadeStartMultiplierValue: "Множитель начала затухания ({value, number, ::.00})"
LightsFadeStartMultiplierTooltip: "Значение по умолчанию: 0.85\nДоля расстояния (относительно дальности отображения источников света), на которой свет начинает затухать.\n\nНизкие значения ведут к плавному затуханию, высокие - к резкому."
LightsLightingMethodTooltip: "Задает способ обработки источников света.\n\n
\"Устаревший\" всегда использует 8 источников света на объект и выдает освещение, наиболее близкое к таковому в оригинальной игре.\n\n
\"Шейдеры (режим совместимости)\" убирает ограничение в 8 источников света. Этот режим также позволяет освещению влиять на анимированную траву. Рекомендуется использовать этот режим на устаревшем аппаратном обеспечении и с количеством источников света на объект около 8.\n\n
\"Шейдеры (режим совместимости)\" Рекомендуется использовать этот режим на устаревшем аппаратном обеспечении и с количеством источников света на объект около 8.\n\n
\"Шейдеры\" работает аналогично режиму \"Шейдеры (режим совместимости)\", но использует более современный подход, позволяющий использовать большее количество источников света с минимальным влиянием на производительность на современном аппаратном обеспечении."
LightsMaximumDistance: "Дальность отображения источников света"
LightsMaximumDistanceValue: "Дальность отображения источников света ({value, number, :: group-off})"
@@ -159,7 +155,7 @@ MatchSunlightToSunTooltip: |-
Настройка делает так, чтобы направление света от солнца соответствовало его положению.
MaxLights: "Макс. кол-во источников света"
MaxLightsValue: "Макс. кол-во источников света ({value, number, :: group-off})"
MaxLightsTooltip: "Значение по умолчанию: 8\nМаксимальное количество источников света для каждого объекта.\n\nНизкие числа (близкие к значению по умолчанию) приводят к резким перепадам освещения, как при устаревшем методе освещения."
MaxLightsTooltip: "Значение по умолчанию: 8\nМаксимальное количество источников света для каждого объекта.\n\nНизкие числа (близкие к значению по умолчанию) приводят к резким перепадам освещения, как в Morrowind."
MenuHelpDelay: "Задержка всплывающих подсказок"
MenuTransparency: "Прозрачность меню"
MouseAndKeyboard: "Мышь/Клавиатура"
+2 -6
View File
@@ -114,8 +114,6 @@ ForcePerPixelLighting: "Per-pixelljussättning"
ForcePerPixelLightingTooltip: |-
Tvingar användningen av per-pixelljussättning. Som standard är det annars bara objekt med normalkartor som använder per-pixelljussättning.
Denna inställning påverkar endast objekt som ritas med shaderteknik.
Aktivering av per-pixelljussättning kommer ge visuella skillnader jämfört med hur Morrowind ser ut i ordinarie spelmotor.
Detta då visst ljus i Morrowind är beroende av vertexljussättning för att se ut som det var avsett.
@@ -131,7 +129,6 @@ InvertYAxis: "Invertera Y-axeln"
Language: "Språk"
LanguageNote: "Notera: dessa inställningar påverkar inte strängar från ESM-filer."
LightingMethod: "Ljussättningsmetod"
LightingMethodLegacy: "Gammaldags"
LightingMethodShaders: "Shader"
LightingMethodShadersCompatibility: "Shader (kompatibilitet)"
LightingResetToDefaults: "Återställer till ursprungliga värden, vill du fortsätta? Ändringar till ljussättningsmetod kräver omstart."
@@ -143,8 +140,7 @@ LightsFadeStartMultiplier: "Blekningsstartmultiplikator"
LightsFadeStartMultiplierValue: "Blekningsstartmultiplikator ({value, number, ::.00})"
LightsFadeStartMultiplierTooltip: "Förvalt: 0.85\nFraktion av det maximala avståndet från vilket ljuskällor börjar blekna.\n\nVälj lågt värde för långsammare övergång eller högre värde för snabbare övergång."
LightsLightingMethodTooltip: "Välj intern hantering av ljuskällor.\n\n
\"Gammaldags\" använder alltid max 8 ljuskällor per objekt och ger ljussättning likt ett gammaldags spel.\n\n
\"Shader (kompatibilitet)\" tar bort begränsningen med max 8 ljuskällor per objekt. Detta läge aktiverar också ljus på marktäckning. Rekommenderas för äldre hårdvara tillsammans med en ljusbegränsning nära 8.\n\n
\"Shader (kompatibilitet)\" Rekommenderas för äldre hårdvara tillsammans med en ljusbegränsning nära 8.\n\n
\"Shader\" har alla fördelar som \"Shader (kompatibilitet)\" har, med med ett modernt förhållningssätt som möjliggör fler maximalt antal ljuskällor med liten eller ingen prestandaförlust på modern hårdvara."
LightsMaximumDistance: "Maximalt ljusavstånd"
LightsMaximumDistanceValue: "Maximalt ljusavstånd ({value, number, :: group-off})"
@@ -160,7 +156,7 @@ MatchSunlightToSunTooltip: |-
Detta alternativ gör att solljuskällans position matchar solens synliga position.
MaxLights: "Max antal ljuskällor"
MaxLightsValue: "Max antal ljuskällor ({value, number, :: group-off})"
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."
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 liknande det man ser i Morrowind."
MenuHelpDelay: "Menyhjälp, fördröjning" #Unsure in what context this goes
MenuTransparency: "Menytransparens"
MouseAndKeyboard: "Mus/Tangentbord"
@@ -570,7 +570,6 @@
<UserString key="Caption_Text" value="#{OMWEngine:LightsLightingMethodTooltip}"/>
</Widget>
<Widget type="ComboBox" skin="MW_ComboBox" position="0 28 250 24" align="Left Top" name="LightingMethodButton">
<Property key="AddItem" value="legacy"/>
<Property key="AddItem" value="shaders compatibility"/>
<Property key="AddItem" value="shaders"/>
</Widget>
+1 -7
View File
@@ -815,7 +815,6 @@ Logs and settings changed through the launcher and in-game will be saved here.</
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally environment map reflections aren&apos;t affected by lighting, which makes environment-mapped (and thus bump-mapped objects) glow in the dark.
Morrowind Code Patch includes an option to remedy that by doing environment-mapping before applying lighting, this is the equivalent of that option.
Affected objects will use shaders.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
@@ -1122,15 +1121,10 @@ Logs and settings changed through the launcher and in-game will be saved here.</
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
&lt;p&gt; &quot;Legacy&quot; always uses 8 lights per object. It provides results most similar to Morrowind&apos;s lighting.&lt;/p&gt;
&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;
&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;
&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;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Legacy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shaders (compatibility)</source>
<translation type="unfinished"></translation>
+1 -7
View File
@@ -1019,7 +1019,6 @@ Logs and settings changed through the launcher and in-game will be saved here.</
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally environment map reflections aren&apos;t affected by lighting, which makes environment-mapped (and thus bump-mapped objects) glow in the dark.
Morrowind Code Patch includes an option to remedy that by doing environment-mapping before applying lighting, this is the equivalent of that option.
Affected objects will use shaders.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation></translation>
</message>
@@ -1254,8 +1253,7 @@ Logs and settings changed through the launcher and in-game will be saved here.</
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
&lt;p&gt; &quot;Legacy&quot; always uses 8 lights per object. It provides results most similar to Morrowind&apos;s lighting.&lt;/p&gt;
&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;
&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;
&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;</source>
<translation></translation>
</message>
@@ -1263,10 +1261,6 @@ Logs and settings changed through the launcher and in-game will be saved here.</
<source>Lighting Method</source>
<translation></translation>
</message>
<message>
<source>Legacy</source>
<translation></translation>
</message>
<message>
<source>Shaders (compatibility)</source>
<translation></translation>
+3 -10
View File
@@ -818,9 +818,8 @@ Les logs et préférences modifiées y seront sauvegardés.</translation>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally environment map reflections aren&apos;t affected by lighting, which makes environment-mapped (and thus bump-mapped objects) glow in the dark.
Morrowind Code Patch includes an option to remedy that by doing environment-mapping before applying lighting, this is the equivalent of that option.
Affected objects will use shaders.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;En temps normal, les réflexions dues au placage d&apos;environnement (environment map) ne sont pas affectées par l&apos;éclairage de la scène. En conséquence, les objets affectés par le placage d&apos;environnement (et de relief) ont tendance à briller dans le noir. Le &quot;Morrowind Code Patch&quot; a, pour remédier à ça, inclus une option qui applique le placage d&apos;environnement (et de relief) avant d&apos;appliquer l&apos;éclairage. Cette option est son équivalent. Les objets affectés utilisent toujours les shaders.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;En temps normal, les réflexions dues au placage d&apos;environnement (environment map) ne sont pas affectées par l&apos;éclairage de la scène. En conséquence, les objets affectés par le placage d&apos;environnement (et de relief) ont tendance à briller dans le noir. Le &quot;Morrowind Code Patch&quot; a, pour remédier à ça, inclus une option qui applique le placage d&apos;environnement (et de relief) avant d&apos;appliquer l&apos;éclairage. Cette option est son équivalent.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allows MSAA to work with alpha-tested meshes, producing better-looking edges without pixelation. Can negatively impact performance.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
@@ -1125,18 +1124,12 @@ Les logs et préférences modifiées y seront sauvegardés.</translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
&lt;p&gt; &quot;Legacy&quot; always uses 8 lights per object. It provides results most similar to Morrowind&apos;s lighting.&lt;/p&gt;
&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;
&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;
&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;</source>
<translation>&lt;html&gt;&lt;body&gt;&lt;p&gt;Définit la gestion des sources lumineuses :&lt;/p&gt;
&lt;p&gt;&quot;Traditionnelle&quot; Chaque objet est éclairé par 8 sources lumineuses. Cet méthode est la plus proche du jeu original.&lt;/p&gt;
&lt;p&gt;&quot;Shaders (mode de compatibilité)&quot; supprime la limite des 8 sources lumineuses. Cette méthode permet d&apos;éclairer la végétation au sol. Ce choix est recommandé pour les ordinateurs plus anciens avec un nombre de sources lumineuses proche de 8.&lt;/p&gt;
&lt;p&gt;&quot;Shaders (mode de compatibilité)&quot; Ce choix est recommandé pour les ordinateurs plus anciens avec un nombre de sources lumineuses proche de 8.&lt;/p&gt;
&lt;p&gt;&quot;Shaders&quot; offre tous les bénéfices apportés par &quot;Shaders (mode de compatibilité)&quot;, mais utilise une approche moderne. Celle-ci permet, sur du matériel moderne, d&apos;augmenter le nombre de sources lumineuses par objet sans perte de performance.&quot;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>Legacy</source>
<translation>Traditionnelle</translation>
</message>
<message>
<source>Shaders (compatibility)</source>
<translation>Shaders (mode de compatibilité)</translation>
+3 -11
View File
@@ -1038,11 +1038,9 @@ Logi i ustawienia zmienione za pomocą programu uruchamiającego i w grze zostan
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally environment map reflections aren&apos;t affected by lighting, which makes environment-mapped (and thus bump-mapped objects) glow in the dark.
Morrowind Code Patch includes an option to remedy that by doing environment-mapping before applying lighting, this is the equivalent of that option.
Affected objects will use shaders.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Zazwyczaj odbicia z mapy środowiska nie są wpływane przez oświetlenie, co powoduje, że obiekty z mapą środowiska (a więc również z mapą wypukłości) świecą w ciemności.
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Zazwyczaj odbicia z mapy środowiska nie są wpływane przez oświetlenie, co powoduje, że obiekty z mapą środowiska (a więc również z mapą wypukłości) świecą w ciemności.
Morrowind Code Patch zawiera opcję rozwiązującą ten problem przez nakładanie mapy środowiska przed zastosowaniem oświetlenia -- to jest jej odpowiednik.
Obiekty objęte tą opcją będą korzystać z shaderów.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
@@ -1277,22 +1275,16 @@ Logi i ustawienia zmienione za pomocą programu uruchamiającego i w grze zostan
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
&lt;p&gt; &quot;Legacy&quot; always uses 8 lights per object. It provides results most similar to Morrowind&apos;s lighting.&lt;/p&gt;
&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;
&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;
&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;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Ustaw wewnętrzne zarządzanie źródłami światła.&lt;/p&gt;
&lt;p&gt;&quot;Tryb klasyczny&quot; zawsze używa 8 świateł na obiekt. Zapewnia efekty najbardziej zbliżone do oświetlenia w Morrowind.&lt;/p&gt;
&lt;p&gt;&quot;Shadery (kompatybilność)&quot; usuwa limit 8 świateł. Ten tryb włącza także oświetlenie na pokrywie terenu. Zaleca się używać go na starszym sprzęcie z limitem świateł bliskim 8.&lt;/p&gt;
&lt;p&gt;&quot;Shadery (kompatybilność)&quot; Zaleca się używać go na starszym sprzęcie z limitem świateł bliskim 8.&lt;/p&gt;
&lt;p&gt;„Shadery” zawiera wszystkie zalety trybu &quot;Shadery (kompatybilność)&quot;, ale stosuje nowoczesne podejście pozwalające na większą maksymalną liczbę świateł bez lub z minimalnymi spadkami wydajności na nowoczesnym sprzęcie.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>Lighting Method</source>
<translation>Metoda oświetlenia</translation>
</message>
<message>
<source>Legacy</source>
<translation>Tryb klasyczny</translation>
</message>
<message>
<source>Shaders (compatibility)</source>
<translation>Shadery (kompatybilność)</translation>
+2 -10
View File
@@ -927,11 +927,9 @@ Logs and settings changed through the launcher and in-game will be saved here.</
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally environment map reflections aren&apos;t affected by lighting, which makes environment-mapped (and thus bump-mapped objects) glow in the dark.
Morrowind Code Patch includes an option to remedy that by doing environment-mapping before applying lighting, this is the equivalent of that option.
Affected objects will use shaders.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Обычно освещение не должно влиять на карты окружения, из-за чего объекты с картами окружения (в том числе объекты с рельефными текстурами) светятся в темноте.
Morrowind Code Patch предоставляет способ обойти эту проблему, применяя карты окружения перед применением освещения, аналогично этой опции.
Объекты с картами окружения будут использовать шейдеры.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
@@ -1486,18 +1484,12 @@ Logs and settings changed through the launcher and in-game will be saved here.</
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
&lt;p&gt; &quot;Legacy&quot; always uses 8 lights per object. It provides results most similar to Morrowind&apos;s lighting.&lt;/p&gt;
&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;
&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;
&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;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Задает способ обработки источников света.&lt;/p&gt;
&lt;p&gt; &quot;Устаревший&quot; всегда использует 8 источников света на объект и выдает освещение, наиболее близкое к таковому в оригинальной игре.&lt;/p&gt;
&lt;p&gt;&quot;Шейдеры (режим совместимости)&quot; убирает ограничение в 8 источников света. Этот режим также позволяет освещению влиять на анимированную траву. Рекомендуется использовать этот режим на устаревшем аппаратном обеспечении и с количеством источников света на объект около 8.&lt;/p&gt;
&lt;p&gt;&quot;Шейдеры (режим совместимости)&quot; Рекомендуется использовать этот режим на устаревшем аппаратном обеспечении и с количеством источников света на объект около 8.&lt;/p&gt;
&lt;p&gt; &quot;Шейдеры&quot; работает аналогично режиму &quot;Шейдеры (режим совместимости)&quot; но использует более современный подход, позволяющий использовать большее количество источников света с минимальным влиянием на производительность на современном аппаратном обеспечении.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>Legacy</source>
<translation>Устаревший</translation>
</message>
<message>
<source>Shaders (compatibility)</source>
<translation>Шейдеры (режим совместимости)</translation>
+4 -12
View File
@@ -820,11 +820,9 @@ Loggar och inställningar som ändras genom startaren och inne i spelet kommer s
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally environment map reflections aren&apos;t affected by lighting, which makes environment-mapped (and thus bump-mapped objects) glow in the dark.
Morrowind Code Patch includes an option to remedy that by doing environment-mapping before applying lighting, this is the equivalent of that option.
Affected objects will use shaders.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normalt sett påverkas omgivningskartors reflektioner inte av ljus, vilket gör att omgivningskartor (och således så kallade bump mappade objekt) glöder i mörkret.
Morrowind Code Patch inkluderar en inställning att kringå detta genom att lägga omgivningskartor före ljussättningen. Det här är motsvarigheten till den inställningen.
Påverkade objekt kommer använda shaders.
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normalt påverkas inte omgivningskartor (så kallade environment maps) av ljussättningen, vilket gör att objekt med omgivningskartor (och således även objekt med bump mapping) lyser i mörkret.
Morrowind Code Patch har ett alternativ som åtgärdar detta genom att applicera omgivningskartor före ljussättningen. Detta motsvarar det alternativet.
&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
@@ -1131,18 +1129,12 @@ Loggar och inställningar som ändras genom startaren och inne i spelet kommer s
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the internal handling of light sources.&lt;/p&gt;
&lt;p&gt; &quot;Legacy&quot; always uses 8 lights per object. It provides results most similar to Morrowind&apos;s lighting.&lt;/p&gt;
&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;
&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;
&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;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Välj intern hantering av ljuskällor.&lt;/p&gt;
&lt;p&gt; &quot;Gammaldags&quot; använder alltid max 8 ljuskällor per objekt och ger ljussättning likt ett gammaldags spel.&lt;/p&gt;
&lt;p&gt;&quot;Shader (kompatibilitet)&quot; tar bort begränsningen med max 8 ljuskällor per objekt. Detta läge aktiverar också ljus på marktäckning. Rekommenderas för äldre hårdvara tillsammans med en ljusbegränsning nära 8.&lt;/p&gt;
&lt;p&gt;&quot;Shader (kompatibilitet)&quot; Rekommenderas för äldre hårdvara tillsammans med en ljusbegränsning nära 8.&lt;/p&gt;
&lt;p&gt; &quot;Shader&quot; har alla fördelar som &quot;Shader (kompatibilitet)&quot; har, men med ett modernt förhållningssätt som möjliggör fler maximalt antal ljuskällor med liten eller ingen prestandaförlust på modern hårdvara.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>Legacy</source>
<translation>Gammaldags</translation>
</message>
<message>
<source>Shaders (compatibility)</source>
<translation>Shader (kompatibilitet)</translation>
+9 -24
View File
@@ -141,7 +141,7 @@ distant interior fog start = 0
distant interior fog end = 16384
# Determine fog intensity based on the distance from the eye point.
# This makes fogging independent from the viewing angle. Shaders will be used to render all objects.
# This makes fogging independent from the viewing angle.
radial fog = false
# Whether to use exponential formula for fog.
@@ -415,23 +415,13 @@ console history buffer size = 4096
[Shaders]
# Force rendering with shaders, even for objects that don't strictly need them.
# By default, only objects with certain effects, such as bump or normal maps will use shaders.
# With enhancements enabled, such as "enable shadows" and "reverse z", shaders must be used for all objects, as if this setting is true.
# Some settings, such as "clamp lighting" only apply to objects using shaders, so enabling this option may cause slightly different visuals when used at the same time.
# Otherwise, there should not be a visual difference.
force shaders = false
# Force the use of per pixel lighting. By default, only bump and normal mapped objects use per-pixel lighting.
# Only affects objects drawn with shaders (see "force shaders" option).
# Enabling per-pixel lighting can result in visual differences to the original MW engine as
# certain lights in Morrowind rely on vertex lighting to look as intended.
# Note that groundcover shaders and particle effects ignore this setting.
force per pixel lighting = false
# Restrict the amount of lighting that an object can receive to a maximum of (1,1,1).
# Only affects objects that render with shaders (see 'force shaders' option).
# When disabled, terrain is always drawn with shaders to prevent seams between tiles that are and that aren't.
# Setting this option to 'true' results in fixed-function compatible lighting, but the lighting
# may appear 'dull' and there might be color shifts.
# Setting this option to 'false' results in more realistic lighting.
@@ -470,21 +460,15 @@ specular map pattern = _spec
terrain specular map pattern = _diffusespec
# Apply lighting to reflections on the environment-mapped objects like in Morrowind Code Patch.
# Affected objects use shaders.
apply lighting to environment maps = false
# Internal handling of lights, ignored if 'force shaders' is off. "legacy"
# provides fixed function pipeline emulation."shaders compatibility" (default)
# uncaps the light limit, enables groundcover lighting, and uses a modified
# attenuation formula to reduce popping and light seams. "shaders" comes with
# all these benefits and is meant for larger light limits, but may not be
# supported on older hardware and may be slower on weaker hardware when
# 'force per pixel lighting' is enabled.
# "shaders compatibility" (default) Fallback mode designed for older/weaker hardware.
# "shaders" Designed for larger light limits, but may not be supported on older hardware and may be slower
# on weaker hardware when 'force per pixel lighting' is enabled.
lighting method = shaders compatibility
# Use the traditional light attenuation formula.
# This disables OpenMW's adjustment to the formula that ensures point lights can properly fade out.
# When 'lighting method' is set to 'legacy', this setting is always true.
classic falloff = false
# Matches exterior sunlight to the apparent sun orbit
@@ -504,13 +488,11 @@ maximum light distance = 8192
light fade start = 0.85
# Set maximum number of lights per object.
# When 'lighting method' is set to 'legacy', this setting will have no effect.
max lights = 8
# Sets minimum ambient brightness of interior cells. Levels below this threshold will have their
# ambient values adjusted to balance the darker interiors.
# When 'lighting method' is set to 'legacy', this setting will have no effect.
# This setting will also have no effect if 'classic falloff' is true.
# This setting will have no effect if 'classic falloff' is true.
minimum interior brightness = 0.08
# Convert the alpha test (cutout/punchthrough alpha) to alpha-to-coverage.
@@ -1018,7 +1000,7 @@ wait for all jobs on exit = false
[Shadows]
# Enable or disable shadows. Bear in mind that this will force OpenMW to use shaders as if "[Shaders]/force shaders" was set to true.
# Enable or disable shadows
enable shadows = false
# How many shadow maps to use - more of these means each shadow map texel covers less area, producing better looking shadows, but may decrease performance.
@@ -1187,6 +1169,9 @@ stomp mode = 2
# 0 - Gentle levels.
stomp intensity = 1
# Groundcover receives lighting from point lights
point lighting = true
[Lua]
# Enable performance-heavy debug features
+4
View File
@@ -39,6 +39,8 @@ set(SHADER_FILES
compatibility/objects.frag
compatibility/terrain.vert
compatibility/terrain.frag
compatibility/terrain_composite.vert
compatibility/terrain_composite.frag
compatibility/shadows_vertex.glsl
compatibility/shadows_fragment.glsl
compatibility/shadowcasting.vert
@@ -47,6 +49,8 @@ set(SHADER_FILES
compatibility/normals.glsl
compatibility/multiview_resolve.vert
compatibility/multiview_resolve.frag
compatibility/outline.frag
compatibility/outline.vert
compatibility/depthclipped.vert
compatibility/depthclipped.frag
compatibility/gui.vert
+8
View File
@@ -0,0 +1,8 @@
#version 120
uniform vec4 color;
void main()
{
gl_FragData[0] = color;
}
+9
View File
@@ -0,0 +1,9 @@
#version 120
#include "lib/core/vertex.h.glsl"
void main(void)
{
gl_Position = modelToClip(gl_Vertex);
gl_ClipVertex = modelToView(gl_Vertex);
}
@@ -0,0 +1,22 @@
#version 120
varying vec2 uv;
uniform sampler2D diffuseMap;
#if @blendMap
uniform sampler2D blendMap;
#endif
void main()
{
vec2 adjustedUV = (gl_TextureMatrix[0] * vec4(uv, 0.0, 1.0)).xy;
vec4 diffuseTex = texture2D(diffuseMap, adjustedUV);
gl_FragData[0] = vec4(diffuseTex.xyz, 1.0);
#if @blendMap
vec2 blendMapUV = (gl_TextureMatrix[1] * vec4(uv, 0.0, 1.0)).xy;
gl_FragData[0].a *= texture2D(blendMap, blendMapUV).a;
#endif
}
@@ -0,0 +1,10 @@
#version 120
varying vec2 uv;
void main(void)
{
gl_Position = gl_ModelViewMatrix * gl_Vertex;
uv = gl_MultiTexCoord0.xy;
}
+3 -3
View File
@@ -55,7 +55,7 @@ void doLighting(vec3 viewPos, vec3 viewNormal, float shininess, out vec3 diffuse
specularLight = vec3(0.0);
#endif
for (int i = @startLight; i < @endLight; ++i)
for (int i = @startLight; i < PointLightCount; ++i)
{
#if @lightingMethodUBO
int lightIndex = PointLightIndex[i];
@@ -65,8 +65,8 @@ void doLighting(vec3 viewPos, vec3 viewNormal, float shininess, out vec3 diffuse
vec3 lightPos = lcalcPosition(lightIndex) - viewPos;
float lightDistance = length(lightPos);
// cull non-FFP point lighting by radius, light is guaranteed to not fall outside this bound with our cutoff
#if !@classicFalloff && !@lightingMethodFFP
// cull point lighting by radius, light is guaranteed to not fall outside this bound with our cutoff
#if !@classicFalloff
if (lightDistance > lcalcRadius(lightIndex) * 2.0)
continue;
#endif
+17 -31
View File
@@ -62,51 +62,43 @@ uniform int PointLightCount;
float lcalcConstantAttenuation(int lightIndex)
{
#if @lightingMethodPerObjectUniform
return @getLight[lightIndex][0].w;
#elif @lightingMethodUBO
return @getLight[lightIndex].attenuation.x;
return LightBuffer[lightIndex][0].w;
#else
return @getLight[lightIndex].constantAttenuation;
return LightBuffer[lightIndex].attenuation.x;
#endif
}
float lcalcLinearAttenuation(int lightIndex)
{
#if @lightingMethodPerObjectUniform
return @getLight[lightIndex][1].w;
#elif @lightingMethodUBO
return @getLight[lightIndex].attenuation.y;
return LightBuffer[lightIndex][1].w;
#else
return @getLight[lightIndex].linearAttenuation;
return LightBuffer[lightIndex].attenuation.y;
#endif
}
float lcalcQuadraticAttenuation(int lightIndex)
{
#if @lightingMethodPerObjectUniform
return @getLight[lightIndex][2].w;
#elif @lightingMethodUBO
return @getLight[lightIndex].attenuation.z;
return LightBuffer[lightIndex][2].w;
#else
return @getLight[lightIndex].quadraticAttenuation;
return LightBuffer[lightIndex].attenuation.z;
#endif
}
#if !@lightingMethodFFP
float lcalcRadius(int lightIndex)
{
#if @lightingMethodPerObjectUniform
return @getLight[lightIndex][3].w;
return LightBuffer[lightIndex][3].w;
#else
return @getLight[lightIndex].attenuation.w;
return LightBuffer[lightIndex].attenuation.w;
#endif
}
#endif
float lcalcIllumination(int lightIndex, float dist)
{
float illumination = 1.0 / (lcalcConstantAttenuation(lightIndex) + lcalcLinearAttenuation(lightIndex) * dist + lcalcQuadraticAttenuation(lightIndex) * dist * dist);
#if !@classicFalloff && !@lightingMethodFFP
#if !@classicFalloff
// Fade illumination between the radius and the radius doubled to diminish pop-in
illumination *= 1.0 - quickstep((dist / lcalcRadius(lightIndex)) - 1.0);
#endif
@@ -116,42 +108,36 @@ float lcalcIllumination(int lightIndex, float dist)
vec3 lcalcPosition(int lightIndex)
{
#if @lightingMethodPerObjectUniform
return @getLight[lightIndex][0].xyz;
return LightBuffer[lightIndex][0].xyz;
#else
return @getLight[lightIndex].position.xyz;
return LightBuffer[lightIndex].position.xyz;
#endif
}
vec3 lcalcDiffuse(int lightIndex)
{
#if @lightingMethodPerObjectUniform
return @getLight[lightIndex][2].xyz;
#elif @lightingMethodUBO
return unpackRGB(@getLight[lightIndex].packedColors.x) * float(@getLight[lightIndex].packedColors.w);
return LightBuffer[lightIndex][2].xyz;
#else
return @getLight[lightIndex].diffuse.xyz;
return unpackRGB(LightBuffer[lightIndex].packedColors.x) * float(LightBuffer[lightIndex].packedColors.w);
#endif
}
vec3 lcalcAmbient(int lightIndex)
{
#if @lightingMethodPerObjectUniform
return @getLight[lightIndex][1].xyz;
#elif @lightingMethodUBO
return unpackRGB(@getLight[lightIndex].packedColors.y);
return LightBuffer[lightIndex][1].xyz;
#else
return @getLight[lightIndex].ambient.xyz;
return unpackRGB(LightBuffer[lightIndex].packedColors.y);
#endif
}
vec4 lcalcSpecular(int lightIndex)
{
#if @lightingMethodPerObjectUniform
return @getLight[lightIndex][3];
#elif @lightingMethodUBO
return unpackRGBA(@getLight[lightIndex].packedColors.z);
return LightBuffer[lightIndex][3];
#else
return @getLight[lightIndex].specular;
return unpackRGBA(LightBuffer[lightIndex].packedColors.z);
#endif
}