Quantcast
Channel: Questions in topic: "post processing"
Viewing all articles
Browse latest Browse all 713

Save image from camera with post processing.

$
0
0
Since formatting in Unity Answers is awful, here is the StackOverflow post with pretty formatting: https://stackoverflow.com/questions/61167603/save-image-from-unity-camera-with-post-processing-effects ---------- I have a separate camera from my main camera, whose purpose is to take screenshots at different angles. Hierarchy as such:
Screenshot Camera > Main Camera>> GUI Camera>>> Canvas>>>> Image
- The main camera captures the 3D scene just like a normal main camera would, including post-processing components. - The GUI camera captures just the UI layer. - The canvas and image are simply a watermark, rendered by the GUI camera. - I point both the main camera and GUI camera to the same target render texture. The result of the render texture appears to be correct.

Then I convert to a normal Texture2D so it can be saved:

RenderTexture.active = renderTexture;
destination.ReadPixels(new Rect(0f, 0f, renderTexture.width, renderTexture.height), 0, 0);
destination.Apply();

However, during that conversion, the dark areas turn transparent, and light areas remain correct. It's very strange.
The above screenshot is placed on top of black to make it easier to see. (It's not exactly the same as the render texture picture because I took them at different times, but close enough to make the comparison.)
I have found if I disable post-processing, everything works as intended, no changes required.
I have tinkered with color linearity, removing the UI camera, and changing texture color formats. What is stranger yet, is I use almost the same solution elsewhere in the same project, and that one works.

Viewing all articles
Browse latest Browse all 713

Trending Articles