I have a separate camera from my main camera, whose purpose is to take screenshots, or render a "live feed" of the action, at different angles. Hierarchy as such:
- The game object labeled as "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 have removed this and it has no bearing on the issue at hand.
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 in the inspector.
One way or another, it appears that I can only get access to the "bloom," and nothing else:
(On black so it's easier to see.)
If I assign the render texture onto a Raw Image canvas element, it only shows the "bloom."
If I try to convert the render texture to a regular texture, it also only shows the "bloom."
RenderTexture.active = renderTexture;
destination.ReadPixels(new Rect(0f, 0f, renderTexture.width, renderTexture.height), 0, 0);
destination.Apply();
(I have also tried AsyncGPUReadback. Its resulting texture looks like a flat gray without variance in the inspector.)
I have found if I disable post-processing, everything works as intended, no changes required. Of course, I am missing the post processing, which I want!
Somehow, somewhere, Unity is getting data external of the texture itself, depending on context:
- Using Unity's ReadPixels method only picks up the "bloom."
- Using Unity's EncodeToPNG method only picks up the "bloom."
- Putting the RenderTexture on a Raw Image only picks up the "bloom."
- If I use a separate PNG encoder using the same Color32 data, I get the final correct image.
- The inspector successfully renders the final correct image.
I have actually run into this issue multiple times, and never found a proper solution, and definitely never a real-time solution, which I now desperately need.