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.
I just did a test with my post fx asset and I had to make the overlay ( gui ) clear solid with alpha as zero then use a transparent blend mode in post fx shader to overlay gui properly ( so only overlay is grey )
I guess u could render a depth texture and pass that to the post fx shader too ( might be slower than above method )
If there is a better way id really like to know myself
And yes for an overlay to have a different effect then main cam … that camera would have to render to a rendertexture otherwise the gui and game scene are already rendered in the screen buffer
Ok so you suggest that Camera2 renders to a Render Texture.
This texture will be used with a material using my grayscale shader.
But what should I do after that? How to apply this material to see my overlay displayed above Camera1?
It would basically be a transparent shader that adds greyscale… taking the rendertexture and drawing it to screen ( so you have to clear the camera 2 solid black with alpha 0 )
About what you suggested earlier (solid black + alpha 0)… what about semi-transparent pixels? In my overlay I use semi transparent sprites, and setting solid color + black + alpha 0 on camera overlay make these semi-transparent pixels not visible
Thanks a lot for your help… but… there is a problem here.
As you can see, there is a clear problem on game view
Any idea?
I just render the camera overlay in a render texture and then I use Graphics.DrawTexture on repaint event on Camera1.
Is it the right thing to do ?