Ensure shader requirements are pushed at least once for subgraph

Shaders, if deemed necessary, get attached to the node mentioned by the
top of the requirements stack. Previously an empty stack was incorrectly
assumed to mean no shaders were required, but we found out that was
wrong. We need to put shaders *somewhere*, and the root of the subgraph
we're modifying should be the best place.
depth-refraction
AnyOldName3 2 years ago
parent aee1edaf9e
commit ccdb1bf6b7

@ -212,15 +212,17 @@ namespace Shader
void ShaderVisitor::apply(osg::Node& node)
{
if (node.getStateSet())
bool needPop = false;
if (node.getStateSet() || mRequirements.empty())
{
needPop = true;
pushRequirements(node);
if (node.getStateSet())
applyStateSet(node.getStateSet(), node);
traverse(node);
popRequirements();
}
else
traverse(node);
if (needPop)
popRequirements();
}
osg::StateSet* getWritableStateSet(osg::Node& node)
@ -865,12 +867,12 @@ 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
{
bool needPop = geometry.getStateSet() || mRequirements.empty();
if (needPop)
pushRequirements(geometry);
if (geometry.getStateSet()) // TODO: check if stateset affects shader permutation before pushing it
applyStateSet(geometry.getStateSet(), geometry);
}
if (!mRequirements.empty())
{
@ -889,7 +891,7 @@ namespace Shader
void ShaderVisitor::apply(osg::Drawable& drawable)
{
bool needPop = drawable.getStateSet();
bool needPop = drawable.getStateSet() || mRequirements.empty();
if (needPop)
{
@ -899,8 +901,6 @@ namespace Shader
applyStateSet(drawable.getStateSet(), drawable);
}
if (!mRequirements.empty())
{
const ShaderRequirements& reqs = mRequirements.back();
createProgram(reqs);
@ -926,9 +926,6 @@ namespace Shader
osgaRig->setSourceRigGeometry(sourceOsgaRigGeometry);
}
}
}
else
ensureFFP(drawable);
if (needPop)
popRequirements();

Loading…
Cancel
Save