Material Transparency is not working with some png files

Hi There,
I just ran into to cases, where the Alpha in Stride Textures is not working right.

  1. I have a png with Alpha Background. This I use for a material and I use blend (transparency) for fading in and out. one png file works and the other doesn’t fade into alpha. just fades out the color and the rest remains white. Both I generated with photoshop. But I can not create another working png Image.
    I’ll upload a patch with the bug.

Alpha_Bug.zip (52.6 KB)

I think it is caused by the default for Intensity of the Emissive node inside TextureMaterial not being set correctly when no IO-box is attached. Could be considered a bug. For now you can make a copy of the TextureMaterial and “fix” it yourself. Or use PBRMaterial instead which also seems to work.

2 Likes

always trying to understand what goes on with colors in the pipeline, i just spent considerable time to understand what’s going on here (suspecting a unfortunate combination of premultiplied alpha and sRGB/linear conversion (and non of my “solutions” worked).

i’d never have suspected the emissive feature and a non-existant IOBox to be the culprit. thanks @bjoern !

and @ravel :
your images are quite different even though they appear to be similar. while one is straight black and the “hand” is just in the alpha channel, the other does have info in color and alpha channel. premultiplication on import diminishes the effect, but they do behave different…

thank you . I was not thinking at all it would be an emissive setting.

did some more digging as the suggestion to set Emissive Intensity to zero only works in the special case where color does not matter, as colors will be turned to grayscale:

on the other hand, the vanilla TextureMaterial will not work as expected as colors will increase brightness (?) and wash out

what does work as expected is to use the Rendering pipeline with the ConstantColorTextured shader and AlphaBlend (RenderEntity on the Transparent RenderStage)

This has the drawback of leaving the Entity/Material pipeline (and therefore probably losing stuff like instancing).

i’d be curious what a nice solution of this would be while NOT leaving the Material pipeline. maybe a material extension with a custom shader?

Alpha_Bug_strategies.zip (281.6 KB)

You can fade the Intensity at the same time as the Alpha value or multiply the colors of the incoming texture with it.

Alpha_Bug_strategies_b.7z (278.7 KB)

1 Like

ah yes, that’s probably the preferred solution as it does not need an extra shaderpass for the texture.

makes sense, as the Blend transparency feature expects premultiplied alpha. therefore you could also use the vanilla Premultiply texture filter instead of a custom one.