mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 12:54:00 +00:00
Set depth testing for alpha blend & test, depth writes off for blend.
This commit is contained in:
parent
89982eb9e3
commit
40497d6fe5
@ -244,6 +244,17 @@ namespace Resource
|
||||
|
||||
void apply(osg::Node& node) override
|
||||
{
|
||||
bool osgDepthCreated(false);
|
||||
|
||||
if (node.getOrCreateStateSet()->getRenderingHint() == osg::StateSet::TRANSPARENT_BIN)
|
||||
{
|
||||
osg::ref_ptr<osg::Depth> depth = SceneUtil::createDepth();
|
||||
depth->setWriteMask(false);
|
||||
osgDepthCreated = true;
|
||||
|
||||
node.getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
std::vector<std::string> descriptions = node.getDescriptions();
|
||||
for (auto description : descriptions)
|
||||
{
|
||||
@ -255,6 +266,12 @@ namespace Resource
|
||||
|
||||
if (descriptionParts.at(0) == "alphatest")
|
||||
{
|
||||
if (!osgDepthCreated)
|
||||
{
|
||||
osg::ref_ptr<osg::Depth> depth = SceneUtil::createDepth();
|
||||
node.getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
osg::AlphaFunc::ComparisonFunction mode = getTestMode(descriptionParts.at(1));
|
||||
osg::ref_ptr<osg::AlphaFunc> alphaFunc (new osg::AlphaFunc(mode, std::stod(descriptionParts.back())));
|
||||
node.getOrCreateStateSet()->setAttributeAndModes(alphaFunc, osg::StateAttribute::ON);
|
||||
|
Loading…
Reference in New Issue
Block a user