@@ -151,17 +151,17 @@ void Ogre2Material::SetAlphaFromTexture(bool _enabled,
151
151
double _alpha, bool _twoSided)
152
152
{
153
153
BaseMaterial::SetAlphaFromTexture (_enabled, _alpha, _twoSided);
154
+ Ogre::HlmsBlendblock block;
154
155
if (_enabled)
155
156
{
156
- Ogre::HlmsBlendblock block;
157
- block.setBlendType (Ogre::SBT_TRANSPARENT_ALPHA);
158
157
this ->ogreDatablock ->setAlphaTest (Ogre::CMPF_GREATER_EQUAL);
158
+ block.setBlendType (Ogre::SBT_TRANSPARENT_ALPHA);
159
159
this ->ogreDatablock ->setBlendblock (block);
160
- this ->ogreDatablock ->setTwoSidedLighting (_twoSided);
161
160
}
162
161
else
163
162
{
164
163
this ->ogreDatablock ->setAlphaTest (Ogre::CMPF_ALWAYS_PASS);
164
+ this ->ogreDatablock ->setBlendblock (block);
165
165
}
166
166
this ->ogreDatablock ->setAlphaTestThreshold (_alpha);
167
167
this ->ogreDatablock ->setTwoSidedLighting (_twoSided);
@@ -455,6 +455,17 @@ void Ogre2Material::SetTextureMapImpl(const std::string &_texture,
455
455
456
456
this ->ogreDatablock ->setTexture (_type, texLocation.xIdx , texLocation.texture ,
457
457
&samplerBlockRef);
458
+
459
+ // disable alpha from texture if texture does not have an alpha channel
460
+ // otherwise this becomes a transparent material
461
+ if (_type == Ogre::PBSM_DIFFUSE)
462
+ {
463
+ if (this ->TextureAlphaEnabled () && !texLocation.texture ->hasAlpha ())
464
+ {
465
+ this ->SetAlphaFromTexture (false , this ->AlphaThreshold (),
466
+ this ->TwoSidedEnabled ());
467
+ }
468
+ }
458
469
}
459
470
460
471
// ////////////////////////////////////////////////
0 commit comments