Render UI on a Separate Camera without losing Image Effects?
I'm having the worst time trying to figure out how to do this. I currently need Canvas - Screen Space Camera set so that I can apply a bloom effect to my HUD. The problem is, when that mode is set, objects can occlude the UI which is very bad. I cant use overlay, because that doesn't work with the image effects.
I've tried creating a separate camera to render just the UI, setting it to Clear Depth Only and setting it's depth higher than the main camera, but as has been the case since Unity 3, this clears all image effects on the main camera. I can get bloom on the UI camera to work just fine, and it works in the scene from the main camera as well, but SSAO doesn't work because it requires depth information from the main camera, not the UI camera.
Is there any way I can do this? Is there a way to force UI to draw on top of everything while in Screen Space Camera mode? I've been able to sort of achieve this effect with setting the shader to ZTest Always, but then that destroys the ability to do stencil masking, which I need for the circular minimap.
Here is the way I need the UI to look:
Answer by McMayhem · Oct 15, 2015 at 04:29 PM
As it turns out, setting ZTest Always is the best approach here. Now the reason I didn't like this approach before is becaus on its own, it ignores masking. This became an issue for my radial minimap. However, I was able to create a solution to this as well by creating a second shader that handles masking of elements, uses ZTest Always to draw over geometry and additionally uses the Render Queue tag to make sure the mask doesn't draw on top of the elements within its hierarchy.
The result is a HUD that can be drawn on the Main Camera using Screen Space Camera Canvas setting.
It's hard to show how this works since the UI now doesn't get occluded with geometry, but here's the final product:
[Can't currently use URL link for image attachments?] http://www.viewpointgames.net/Downloads/uisuccess.jpg
I'm going to use this to answer some questions that other people have had regarding this specific issue. Hopefully it will work for their situations as well!
Your answer
Follow this Question
Related Questions
Canvas scaling for triple monitor setups (NVIDIA Surround / AMD Eyefinity) 0 Answers
Prevent World Space canvas render mode to overlay other game objects 0 Answers
how do i update specific Canvas Ui text? 1 Answer
Why button changes canvas group alpha value? 0 Answers
How would I Consistantly 'Snap' a UI Element to the Edge of a Camera? 1 Answer