From 7d55d9b24a805875258975cb7d48c072e3a55493 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Sat, 13 Mar 2021 00:21:35 -0800 Subject: [PATCH] fix overriding blend mode (#266) Signed-off-by: Ian Chen --- include/ignition/rendering/base/BaseMaterial.hh | 3 ++- ogre2/src/Ogre2Material.cc | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ignition/rendering/base/BaseMaterial.hh b/include/ignition/rendering/base/BaseMaterial.hh index f77200659..8d6907e3c 100644 --- a/include/ignition/rendering/base/BaseMaterial.hh +++ b/include/ignition/rendering/base/BaseMaterial.hh @@ -873,9 +873,10 @@ namespace ignition this->SetSpecular(_material->Specular()); this->SetEmissive(_material->Emissive()); this->SetShininess(_material->Shininess()); - this->SetTransparency(_material->Transparency()); this->SetAlphaFromTexture(_material->TextureAlphaEnabled(), _material->AlphaThreshold(), _material->TwoSidedEnabled()); + // override transparency / blend setting after setting alpha from texture + this->SetTransparency(_material->Transparency()); // override depth check / depth write after setting transparency this->SetDepthCheckEnabled(_material->DepthCheckEnabled()); this->SetDepthWriteEnabled(_material->DepthWriteEnabled()); diff --git a/ogre2/src/Ogre2Material.cc b/ogre2/src/Ogre2Material.cc index c57189116..73ba89919 100644 --- a/ogre2/src/Ogre2Material.cc +++ b/ogre2/src/Ogre2Material.cc @@ -157,17 +157,16 @@ void Ogre2Material::SetAlphaFromTexture(bool _enabled, double _alpha, bool _twoSided) { BaseMaterial::SetAlphaFromTexture(_enabled, _alpha, _twoSided); - Ogre::HlmsBlendblock block; if (_enabled) { this->ogreDatablock->setAlphaTest(Ogre::CMPF_GREATER_EQUAL); + Ogre::HlmsBlendblock block; block.setBlendType(Ogre::SBT_TRANSPARENT_ALPHA); this->ogreDatablock->setBlendblock(block); } else { this->ogreDatablock->setAlphaTest(Ogre::CMPF_ALWAYS_PASS); - this->ogreDatablock->setBlendblock(block); } this->ogreDatablock->setAlphaTestThreshold(_alpha); this->ogreDatablock->setTwoSidedLighting(_twoSided);