1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-09 21:44:54 +00:00

Attach shaders to geometry that lacks a stateset if necessary

This commit is contained in:
Alexei Dobrohotov 2023-02-28 18:50:30 +03:00
parent a9fdb51041
commit 6aef366fd3
3 changed files with 34 additions and 58 deletions

View File

@ -225,6 +225,7 @@
Bug #6937: Divided by Nix Hounds quest is broken
Bug #7008: Race condition on initializing a vector of reserved node names
Bug #7121: Crash on TimeStamp construction with invalid hour value
Bug #7251: Force shaders setting still renders some drawables with FFP
Feature #890: OpenMW-CS: Column filtering
Feature #1465: "Reset" argument for AI functions
Feature #2491: Ability to make OpenMW "portable"

View File

@ -612,9 +612,6 @@ namespace MWRender
mRootNode->getOrCreateStateSet()->setAttributeAndModes(clipcontrol, osg::StateAttribute::ON);
}
// Assign a default shader on root to handle empty statesets
mResourceSystem->getSceneManager()->recreateShaders(mRootNode, "objects");
SceneUtil::setCameraClearDepth(mViewer->getCamera());
updateProjectionMatrix();

View File

@ -864,43 +864,25 @@ namespace Shader
}
void ShaderVisitor::apply(osg::Geometry& geometry)
{
bool needPop = (geometry.getStateSet() != nullptr);
if (geometry.getStateSet()) // TODO: check if stateset affects shader permutation before pushing it
{
pushRequirements(geometry);
if (geometry.getStateSet()) // TODO: check if stateset affects shader permutation before pushing it
applyStateSet(geometry.getStateSet(), geometry);
}
if (!mRequirements.empty())
{
const ShaderRequirements& reqs = mRequirements.back();
adjustGeometry(geometry, reqs);
createProgram(reqs);
}
else
ensureFFP(geometry);
if (needPop)
popRequirements();
}
void ShaderVisitor::apply(osg::Drawable& drawable)
{
bool needPop = drawable.getStateSet();
if (needPop)
{
pushRequirements(drawable);
if (drawable.getStateSet())
applyStateSet(drawable.getStateSet(), drawable);
}
if (!mRequirements.empty())
{
const ShaderRequirements& reqs = mRequirements.back();
createProgram(reqs);
@ -926,11 +908,7 @@ namespace Shader
osgaRig->setSourceRigGeometry(sourceOsgaRigGeometry);
}
}
}
else
ensureFFP(drawable);
if (needPop)
popRequirements();
}