Hi,
I’ve a problem to take a screenhot using “depth only” camera and a 3d object (sphere) with a material with transparent shader.
The pixels in RenderTexture have the correct color (R,G,B) but alpha channel is always 0!
This is my code to take the screenshot
void LateUpdate()
{
if (takeScreenshot)
{
RenderTexture rt = new RenderTexture(resWidth, resHeight, 24, RenderTextureFormat.ARGB32);
pCamera.targetTexture = rt;
screenShot = new Texture2D(resWidth, resHeight, TextureFormat.ARGB32, false);
pCamera.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
pCamera.targetTexture = preview;
RenderTexture.active = null;
Destroy(rt);
screenShot.Apply();
takeScreenshot = false;
}
}
Is it the correct way?
How can i have what i need?
Thanks