CaptureScreenshotAsTexture behave differently than CaptureScreenshot


I’m using CaptureScreenshotAsTexture to render and store image from my game. Because I need to have nice and smooth masked images and standard Mask component creates jagged output, I implemented shader and material to correctly mask image. Shader is from

The result is nice and smooth, but when I take screenshot using CaptureScreenshotAsTexture, the material is not applied. Using CaptureScreenshot yeild in correct result (material is applied), but since the latter ignore my camera’s background color alpha (which is set to 0), I ended up with image without transaprency. Compare for yourself:



(Note that although here is in the background color with no alpha, this is because I scale it down in MS paint and unfortunatelly it discarded alpha value. Original image has correct background alpha values)

Expected result:
I expect to have output screenshot with material applied and having alpha to 0 where no image is rendered in the scene.

My possible workaround
Since I’m rendering an editor-like environment, I need to take a screenshot using CaptureScreenshot in correct supersize (final image must meet certain dimensions), then load it to memory, crop it and using flood algorithm correct alfa values (where pixel is 100% white).

Is there any other way to solve or workaround this bug (filled as #1053957)?

I believe you need to call this function at end of frame to guarantee that everything renders correctly. Try using a co-routine as detailed in the documentation.