@@ -123,6 +123,7 @@ public class BabylonCustomAttributeDecorator : MaterialDecorator
123123 public const string EnvironmentIntensityStr = "babylonEnvironmentIntensity" ;
124124 public const string SpecularIntensityStr = "babylonSpecularIntensity" ;
125125 public const string TransparencyModeStr = "babylonTransparencyMode" ;
126+ public const string UseAlphaFromDiffuseTextureStr = "babylonUseAlphaFromDiffuseTexture" ;
126127
127128 public static IEnumerable < string > ListPrivatePropertyNames ( )
128129 {
@@ -135,6 +136,7 @@ public static IEnumerable<string> ListPrivatePropertyNames()
135136 yield return EnvironmentIntensityStr ;
136137 yield return SpecularIntensityStr ;
137138 yield return TransparencyModeStr ;
139+ yield return UseAlphaFromDiffuseTextureStr ;
138140 }
139141
140142 public BabylonCustomAttributeDecorator ( IIGameMaterial node ) : base ( node )
@@ -151,6 +153,7 @@ public BabylonCustomAttributeDecorator(IIGameMaterial node) : base(node)
151153 public float EnvironementIntensity => Properties ? . GetFloatProperty ( EnvironmentIntensityStr , 1.0f ) ?? 1.0f ;
152154 public float SpecularIntensity => Properties ? . GetFloatProperty ( SpecularIntensityStr , 1.0f ) ?? 1.0f ;
153155 public int TransparencyMode => Properties ? . GetIntProperty ( TransparencyModeStr , 0 ) ?? 0 ;
156+ public bool UseAlphaFromDiffuseTexture => Properties ? . GetBoolProperty ( UseAlphaFromDiffuseTextureStr , false ) ?? false ;
154157 }
155158
156159 /// <summary>
@@ -337,6 +340,7 @@ private void ExportMaterial(IIGameMaterial materialNode, BabylonScene babylonSce
337340 private void ExportStandardMaterial ( IIGameMaterial materialNode , IIPropertyContainer attributesContainer , IStdMat2 stdMat , BabylonScene babylonScene , BabylonStandardMaterial babylonMaterial )
338341 {
339342 bool isTransparencyModeFromBabylonAttributes = false ;
343+ bool useAlphaFromDiffuseTexture = false ;
340344 if ( attributesContainer != null )
341345 {
342346 IIGameProperty babylonTransparencyModeGameProperty = attributesContainer . QueryProperty ( "babylonTransparencyMode" ) ;
@@ -345,8 +349,16 @@ private void ExportStandardMaterial(IIGameMaterial materialNode, IIPropertyConta
345349 babylonMaterial . transparencyMode = babylonTransparencyModeGameProperty . GetIntValue ( ) ;
346350 isTransparencyModeFromBabylonAttributes = true ;
347351 }
352+
353+ IIGameProperty babylonUseAlphaFromDiffuseTextureGameProperty = attributesContainer . QueryProperty ( "babylonUseAlphaFromDiffuseTexture" ) ;
354+ if ( babylonUseAlphaFromDiffuseTextureGameProperty != null )
355+ {
356+ useAlphaFromDiffuseTexture = babylonUseAlphaFromDiffuseTextureGameProperty . GetBoolValue ( ) ;
357+ }
348358 }
349359
360+ babylonMaterial . useAlphaFromDiffuseTexture = useAlphaFromDiffuseTexture ;
361+
350362 if ( isTransparencyModeFromBabylonAttributes == false || babylonMaterial . transparencyMode != 0 )
351363 {
352364 // The user specified value in 3ds Max is opacity
@@ -548,6 +560,7 @@ private void ExportStandardMaterial(IIGameMaterial materialNode, IIPropertyConta
548560 excludeAttributes . Add ( "babylonUnlit" ) ;
549561 excludeAttributes . Add ( "babylonMaxSimultaneousLights" ) ;
550562 excludeAttributes . Add ( "babylonTransparencyMode" ) ;
563+ excludeAttributes . Add ( "babylonUseAlphaFromDiffuseTexture" ) ;
551564
552565 // Export the custom attributes of this material
553566 babylonMaterial . metadata = ExportExtraAttributes ( materialNode , babylonScene , excludeAttributes ) ;
0 commit comments