Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Postprocessing loses alpha value when taking screenshot

Discussion in 'Image Effects' started by Wattosan, Jan 24, 2018.

  1. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    Hello,

    I have written some code to take a screenshot of a specific area on the camera. The code boils down to this:

    Code (CSharp):
    1. renderTexture = new RenderTexture(Screen.width, Screen.height, 32);
    2. screenShot = new Texture2D(Mathf.Abs((int)rect.width), Mathf.Abs((int)rect.height), TextureFormat.ARGB32, false);
    3.  
    4. RenderTexture.active = renderTexture;
    5. camera.targetTexture = renderTexture;
    6. camera.Render();
    7.  
    8. screenShot.ReadPixels(rect, 0, 0);
    9. screenShot.Apply();
    10.  
    11. cam.targetTexture = null;
    12. RenderTexture.active = null;
    13.  
    14. // And saving into file below (filename -> EncodeToPNG() -> write file
    15.  
    This has worked very well. And the screenshots have their alpha applied correctly. Screenshot is see-through/alphad where it should be.

    However, adding the PostProcessingStack to the camera object and applying some effects, nulls the alpha stuff. Instead of the resulting screenshot being see-through, it is totally black where it should be alpha. It's as if the alpha component of the ARGB is lost or not taken into account.

    Any help is much appreciated.
    Thank you!
     
  2. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    Bump!

    Should I post this in another subforum? Or am I in a correct one?
     
  3. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456