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 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.