     vec3 ViewDir  = normalize(ViewDirection);
     vec3 LightDir = normalize(LightDirection);
 
+    float alpha = 1.0f;
+
 #if defined(ExponentialMapping)
     Texcoord = Pow(fract(Texcoord) - 0.5, ExpScale) + 0.5;
 #endif
 
 #if defined(DiffuseMap_Present)
     // Read the diffuse map
+#if defined(DiffuseMap_Alpha)
+    vec4 DiffuseTexColor4 = texture2D(DiffuseMap, Texcoord);
+    vec3 DiffuseTexColor = DiffuseTexColor4.xyz;
+    alpha = DiffuseTexColor4.w;
+#else
     vec3 DiffuseTexColor = texture2D(DiffuseMap, Texcoord).xyz;
+#endif
 
     // Adjust contrast if needed
 #if defined(DiffuseMap_AdjustContrast)

    Final = mix(Final, EnvColor, Fresnel(dot(Normal, ViewDir), EnvReflectance));
#endif

    return Final;
}

void main()
{
    gl_FragColor = vec4(mainFS(), 0);
}

#endif


varying vec3 ViewDirection;
varying vec3 LightDirection;

vec4 mainFS()
{
#if defined(DistanceBasedCutting)
    if (distance(Position, ClipOrigin) > ClipDistance) discard;
