Alpha and scene clear color while taking a screenshot

Hello, I’m trying to create a screenshot of my scene which contains alpha blended materials. Normally my Babylon scene has a clear color of Color4(1,1,1,1). But I need to have my object separate in the image so I can overlay it later on top of other images.

Now when I take a screenshot the objects with alpha below 1, it gets faded when I set the clear color to a transparent Color4(1,1,1,0). Even though my default clear color is white normally and it visually looks the same. when I overlay this screenshot with the transparent clear color on top of for example a white background it doesn’t obtain the same color either as the opaque clear color screenshot.

Is it possible to get a screenshot with the same “opacity” as a scene with an opaque clear color?

A scene to demonstrate what I mean (change the indicated lines):

Setting it to Color4(0,0,0,0) seems to fix it. This makes little sense to me however, can someone explain this behaviour?


(0,0,0,0) is the right color because of the alpha mode used, which is ALPHA_COMBINED (note that your code is doing mat.alphaMode = BABYLON.PBRMaterial.MATERIAL_ALPHABLEND, which is wrong, it should be mat.alphaMode = BABYLON.Constants.ALPHA_COMBINE, but it happens that MATERIAL_ALPHABLEND==ALPHA_COMBINE==2!).

ALPHA_COMBINE is computing the final color as SRC_ALPHA * SRC_COLOR + (1 - SRC_ALPHA) * DEST_COLOR

So, if you clear with (0,0,0,0), DEST_COLOR = (0,0,0) and the final color will only depend on SRC_COLOR. If you clear with (1,1,1,0), the final color will be a mix (depending on source alpha) of the source color and white.