Creating png with transparent background using CreateScreenshot

Hi everyone-

I am using CreateScreenshotUsingRenderTarget to create PNGs that I then apply to buttons. I can’t figure out how to give them a transparent background. In the playground below I have 2 buttons: one uses a png loaded from an external source and the other uses one created from CreateScreenshotUsingRenderTarget. If you orbit the camera you can see that the latter button does not have a transparent background.

Any ideas?

I hope y’all are having a peaceful , joyful and love-filled holiday wherever you are and however you celebrate! One love! Sending warm greetings from Trenton, New Jersey!

-Flex

In order to have transparent background on screenshots one needs to make scene clear color transparent:
scene.clearColor = new BABYLON.Color4 (0,0,0,0)
Example - https://playground.babylonjs.com/#G3SKYF#1

2 Likes

That works! Thank you.

1 Like