Post processing effect to a '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.

Are you rendering second camera to a render texture ? or just applying effect to the screen ?

The second camera is directly used as a camera… I’m not using a render texture… Should I?

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?

Sorry I’m very new to post-processing effects :frowning:

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 )

Ive actually done all this work already and there is nothing faster

Post FX Studio

Can make just about any effect

Ho that’s nice!

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 :frowning:

r u setting a transparent blend mode in the shader ? can u pastebin your shader ?

and the gui elements are using a shader that writes to alpha channel as well ?

Another option would be make it additive then u wont have to worry about alpha channel

This is my post-processing shader : http://pastie.org/private/kiwufaizaii1fcyj6f47a
And my GUI elements use the default sprite shader.

here try this … i changed a few things to make it faster as well in frag part

http://pastebin.com/wQUpVxZa

This is untested … but it should work

Thanks a lot for your help… but… there is a problem here.

As you can see, there is a clear problem on game view :slight_smile:
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 ?

Thanks again.

I use Graphics.DrawMeshNow ( i think DrawTexture is basically same thing just uses its own quad )

mymaterial.SetPass(0);
Graphics.DrawMeshNow ( _mesh, icamtrans.position, icamtrans.rotation );

is the problem those extra lines ?

are you clearing the bottom camera as well to solid black ?

If you PM me a link to a simple project that shows all this … i can take a look real quick