Skip to content

Commit

Permalink
fix overriding blend mode (#266)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Mar 13, 2021
1 parent 108e28b commit 7d55d9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/ignition/rendering/base/BaseMaterial.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 1 addition & 2 deletions ogre2/src/Ogre2Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7d55d9b

Please sign in to comment.