mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
Merge branch 'amaranth' into 'master'
Add polygon offset to decals in Skyrim models, reducing Z-fighting See merge request OpenMW/openmw!3237
This commit is contained in:
commit
c80a8d5293
2 changed files with 28 additions and 0 deletions
|
@ -141,6 +141,7 @@ namespace Nif
|
||||||
|
|
||||||
bool doubleSided() const { return (flags2 >> 4) & 1; }
|
bool doubleSided() const { return (flags2 >> 4) & 1; }
|
||||||
bool treeAnim() const { return (flags2 >> 29) & 1; }
|
bool treeAnim() const { return (flags2 >> 29) & 1; }
|
||||||
|
bool decal() const { return (flags1 >> 26) & 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BSShaderLightingProperty : public BSShaderProperty
|
struct BSShaderLightingProperty : public BSShaderProperty
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <osg/FrontFace>
|
#include <osg/FrontFace>
|
||||||
#include <osg/Material>
|
#include <osg/Material>
|
||||||
#include <osg/PolygonMode>
|
#include <osg/PolygonMode>
|
||||||
|
#include <osg/PolygonOffset>
|
||||||
#include <osg/Stencil>
|
#include <osg/Stencil>
|
||||||
#include <osg/TexEnv>
|
#include <osg/TexEnv>
|
||||||
#include <osg/TexEnvCombine>
|
#include <osg/TexEnvCombine>
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
#include <components/nif/niffile.hpp>
|
#include <components/nif/niffile.hpp>
|
||||||
#include <components/nif/node.hpp>
|
#include <components/nif/node.hpp>
|
||||||
#include <components/nif/property.hpp>
|
#include <components/nif/property.hpp>
|
||||||
|
#include <components/sceneutil/depth.hpp>
|
||||||
#include <components/sceneutil/morphgeometry.hpp>
|
#include <components/sceneutil/morphgeometry.hpp>
|
||||||
#include <components/sceneutil/riggeometry.hpp>
|
#include <components/sceneutil/riggeometry.hpp>
|
||||||
#include <components/sceneutil/skeleton.hpp>
|
#include <components/sceneutil/skeleton.hpp>
|
||||||
|
@ -2479,6 +2481,31 @@ namespace NifOsg
|
||||||
mat->setShininess(osg::Material::FRONT_AND_BACK, shaderprop->mGlossiness);
|
mat->setShininess(osg::Material::FRONT_AND_BACK, shaderprop->mGlossiness);
|
||||||
emissiveMult = shaderprop->mEmissiveMult;
|
emissiveMult = shaderprop->mEmissiveMult;
|
||||||
specStrength = shaderprop->mSpecStrength;
|
specStrength = shaderprop->mSpecStrength;
|
||||||
|
if (shaderprop->decal())
|
||||||
|
{
|
||||||
|
osg::StateSet* stateset = node->getOrCreateStateSet();
|
||||||
|
if (!mPushedSorter && !hasSortAlpha)
|
||||||
|
stateset->setRenderBinDetails(1, "SORT_BACK_TO_FRONT");
|
||||||
|
osg::ref_ptr<osg::PolygonOffset> polygonOffset(new osg::PolygonOffset);
|
||||||
|
polygonOffset->setUnits(SceneUtil::AutoDepth::isReversed() ? 1.f : -1.f);
|
||||||
|
polygonOffset->setFactor(SceneUtil::AutoDepth::isReversed() ? 0.65f : -0.65f);
|
||||||
|
stateset->setAttributeAndModes(polygonOffset, osg::StateAttribute::ON);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Nif::RC_BSEffectShaderProperty:
|
||||||
|
{
|
||||||
|
auto shaderprop = static_cast<const Nif::BSEffectShaderProperty*>(property);
|
||||||
|
if (shaderprop->decal())
|
||||||
|
{
|
||||||
|
osg::StateSet* stateset = node->getOrCreateStateSet();
|
||||||
|
if (!mPushedSorter && !hasSortAlpha)
|
||||||
|
stateset->setRenderBinDetails(1, "SORT_BACK_TO_FRONT");
|
||||||
|
osg::ref_ptr<osg::PolygonOffset> polygonOffset(new osg::PolygonOffset);
|
||||||
|
polygonOffset->setUnits(SceneUtil::AutoDepth::isReversed() ? 1.f : -1.f);
|
||||||
|
polygonOffset->setFactor(SceneUtil::AutoDepth::isReversed() ? 0.65f : -0.65f);
|
||||||
|
stateset->setAttributeAndModes(polygonOffset, osg::StateAttribute::ON);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue