- Home /
Post processing effect on depth only camera.
Hi,
I want to apply a post processing effect to a Camera with a culling mask set as Depth only.
My configuration is :
Camera 1: renders the game, depth set to 0, culling mask set to SolidColor
Camera 2: renders the UI, depth set to 1, culling mask sef to Depth Only
I'd like to apply a simple "Grayscale mode" shader (renders everything in grayscale) to the content of Camera 2 because I want this effect applied only to the UI.
But as the Camera 2 is rendered after the Camera 1, the post-processing effect is also applied to Camera 1' content.
How could I do something as simple as this?
Thanks in advance for your help.
You'll need to code yourself a shader into which you'll submit the UI camera's render texture. The UI cam should render with a background color. The shader should draw the UI's RT to the screen, presumably using additive or alpha blending, and NOT draw the UI cam's background color. If you can depth-test your UI elements, that opens other avenues. The script to accomplish this should probably follow the ImageEffect design pattern, and reside on the main camera. It should manually render the UI camera during its OnPostRender(), then Blit() the result to the screen through your custom shader.
Answer by MakeCodeNow · Sep 04, 2014 at 04:20 AM
You have two options:
1) Have a custom UI shader that can blend between color and grayscale, using a float or bool shader param. Set this param based on your UI state.
2) Render the UI to a unique Render Target, clearing color and depth and writing destination alpha. After color and scene are rendered, blit the UI texture on top of the scene texture.
Thanks for your answer. Is it common to have several full screen post processing effects?