mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-08 09:37:53 +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
|
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();
|
std::vector<std::string> descriptions = node.getDescriptions();
|
||||||
for (auto description : descriptions)
|
for (auto description : descriptions)
|
||||||
{
|
{
|
||||||
@ -255,6 +266,12 @@ namespace Resource
|
|||||||
|
|
||||||
if (descriptionParts.at(0) == "alphatest")
|
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::AlphaFunc::ComparisonFunction mode = getTestMode(descriptionParts.at(1));
|
||||||
osg::ref_ptr<osg::AlphaFunc> alphaFunc (new osg::AlphaFunc(mode, std::stod(descriptionParts.back())));
|
osg::ref_ptr<osg::AlphaFunc> alphaFunc (new osg::AlphaFunc(mode, std::stod(descriptionParts.back())));
|
||||||
node.getOrCreateStateSet()->setAttributeAndModes(alphaFunc, osg::StateAttribute::ON);
|
node.getOrCreateStateSet()->setAttributeAndModes(alphaFunc, osg::StateAttribute::ON);
|
||||||
|
Loading…
Reference in New Issue
Block a user