Alpha and scene clear color while taking a screenshot

Yes, using ALPHA_ONEONE_ONEONE sadly isn’t an option for me. I need to be able to generate the images I want of many complex scenes and I can’t imagine changing the alpha blending to ONEONE will work everywhere without breaking the original scenes.

I could also possibly apply some image transformations to the transparent .png in post by using GIMP or ImageMagick, I already have a pipeline setup for this. But I can’t imagine you would know what image transformations would have to be applied in order for it to consistently give the same result?

Also as some extra information, this is closer to my setup:

https://playground.babylonjs.com/#AMTLDQ#24

Here the clear color is transparent but the canvas has a background color. This also shows my issue better, being that (in this setup) the screenshot function does not return the same result as what you see.

I think the fundamental problem is that the .png file format doesn’t support pre-multiplied alpha, so when a .png file is displayed, the alpha channel is applied to data that has already been multiplied by the alpha channel.

If you want to render a .png file correctly, you can set the alpha channel to 1 for all pixels. I can’t really think of any other way to make it work…

1 Like

I suppose what might be the only solution for me woulb be to only mix the transparent part of a model with the (opaque) clear color, and make all the truly transparent pixels in the scene export transparent. Is there a way to do this in Babylon? I can imagine doing this during post processing, but preferably of course it would be nicer if I could just do it through Babylon itself.

Blending (when enabled) is applied in the same way to all pixels. It is not possible to activate/deactivate or modify the type of blending per pixel (if I understand correctly what you’re trying to do). So you’ll have to do it “by hand” if you want to perform custom processing.