mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-29 04:06:40 +00:00
Merge branch 'shadervisitor' into 'master'
Attach shaders to geometry that lacks a stateset if necessary (bug #7251) See merge request OpenMW/openmw!2782
This commit is contained in:
commit
3d8acf17bd
3 changed files with 39 additions and 56 deletions
|
@ -226,6 +226,7 @@
|
||||||
Bug #6937: Divided by Nix Hounds quest is broken
|
Bug #6937: Divided by Nix Hounds quest is broken
|
||||||
Bug #7008: Race condition on initializing a vector of reserved node names
|
Bug #7008: Race condition on initializing a vector of reserved node names
|
||||||
Bug #7121: Crash on TimeStamp construction with invalid hour value
|
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 #890: OpenMW-CS: Column filtering
|
||||||
Feature #1465: "Reset" argument for AI functions
|
Feature #1465: "Reset" argument for AI functions
|
||||||
Feature #2491: Ability to make OpenMW "portable"
|
Feature #2491: Ability to make OpenMW "portable"
|
||||||
|
|
|
@ -612,9 +612,6 @@ namespace MWRender
|
||||||
mRootNode->getOrCreateStateSet()->setAttributeAndModes(clipcontrol, osg::StateAttribute::ON);
|
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());
|
SceneUtil::setCameraClearDepth(mViewer->getCamera());
|
||||||
|
|
||||||
updateProjectionMatrix();
|
updateProjectionMatrix();
|
||||||
|
|
|
@ -864,73 +864,58 @@ namespace Shader
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderVisitor::apply(osg::Geometry& geometry)
|
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);
|
pushRequirements(geometry);
|
||||||
|
if (geometry.getStateSet()) // TODO: check if stateset affects shader permutation before pushing it
|
||||||
applyStateSet(geometry.getStateSet(), geometry);
|
applyStateSet(geometry.getStateSet(), geometry);
|
||||||
}
|
|
||||||
|
|
||||||
if (!mRequirements.empty())
|
|
||||||
{
|
|
||||||
const ShaderRequirements& reqs = mRequirements.back();
|
const ShaderRequirements& reqs = mRequirements.back();
|
||||||
|
|
||||||
adjustGeometry(geometry, reqs);
|
adjustGeometry(geometry, reqs);
|
||||||
|
|
||||||
createProgram(reqs);
|
createProgram(reqs);
|
||||||
}
|
|
||||||
else
|
|
||||||
ensureFFP(geometry);
|
|
||||||
|
|
||||||
if (needPop)
|
|
||||||
popRequirements();
|
popRequirements();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderVisitor::apply(osg::Drawable& drawable)
|
void ShaderVisitor::apply(osg::Drawable& drawable)
|
||||||
{
|
|
||||||
bool needPop = drawable.getStateSet();
|
|
||||||
|
|
||||||
if (needPop)
|
|
||||||
{
|
{
|
||||||
pushRequirements(drawable);
|
pushRequirements(drawable);
|
||||||
|
|
||||||
if (drawable.getStateSet())
|
if (drawable.getStateSet())
|
||||||
applyStateSet(drawable.getStateSet(), drawable);
|
applyStateSet(drawable.getStateSet(), drawable);
|
||||||
}
|
|
||||||
|
|
||||||
if (!mRequirements.empty())
|
|
||||||
{
|
|
||||||
const ShaderRequirements& reqs = mRequirements.back();
|
const ShaderRequirements& reqs = mRequirements.back();
|
||||||
createProgram(reqs);
|
createProgram(reqs);
|
||||||
|
|
||||||
if (auto rig = dynamic_cast<SceneUtil::RigGeometry*>(&drawable))
|
if (auto rig = dynamic_cast<SceneUtil::RigGeometry*>(&drawable))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geometry> sourceGeometry = rig->getSourceGeometry();
|
osg::ref_ptr<osg::Geometry> sourceGeometry = rig->getSourceGeometry();
|
||||||
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
|
if (sourceGeometry)
|
||||||
|
{
|
||||||
|
sourceGeometry->accept(*this);
|
||||||
rig->setSourceGeometry(sourceGeometry);
|
rig->setSourceGeometry(sourceGeometry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (auto morph = dynamic_cast<SceneUtil::MorphGeometry*>(&drawable))
|
else if (auto morph = dynamic_cast<SceneUtil::MorphGeometry*>(&drawable))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geometry> sourceGeometry = morph->getSourceGeometry();
|
osg::ref_ptr<osg::Geometry> sourceGeometry = morph->getSourceGeometry();
|
||||||
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
|
if (sourceGeometry)
|
||||||
|
{
|
||||||
|
sourceGeometry->accept(*this);
|
||||||
morph->setSourceGeometry(sourceGeometry);
|
morph->setSourceGeometry(sourceGeometry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (auto osgaRig = dynamic_cast<SceneUtil::RigGeometryHolder*>(&drawable))
|
else if (auto osgaRig = dynamic_cast<SceneUtil::RigGeometryHolder*>(&drawable))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<SceneUtil::OsgaRigGeometry> sourceOsgaRigGeometry = osgaRig->getSourceRigGeometry();
|
osg::ref_ptr<SceneUtil::OsgaRigGeometry> sourceOsgaRigGeometry = osgaRig->getSourceRigGeometry();
|
||||||
osg::ref_ptr<osg::Geometry> sourceGeometry = sourceOsgaRigGeometry->getSourceGeometry();
|
osg::ref_ptr<osg::Geometry> sourceGeometry = sourceOsgaRigGeometry->getSourceGeometry();
|
||||||
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
|
if (sourceGeometry)
|
||||||
{
|
{
|
||||||
|
sourceGeometry->accept(*this);
|
||||||
sourceOsgaRigGeometry->setSourceGeometry(sourceGeometry);
|
sourceOsgaRigGeometry->setSourceGeometry(sourceGeometry);
|
||||||
osgaRig->setSourceRigGeometry(sourceOsgaRigGeometry);
|
osgaRig->setSourceRigGeometry(sourceOsgaRigGeometry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
ensureFFP(drawable);
|
|
||||||
|
|
||||||
if (needPop)
|
|
||||||
popRequirements();
|
popRequirements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue