I have an object which I want to add post-processing effects to, but i don’t want to add post-processing effects to the background. The background camera renders at depth 0, and the object (with the PP effects) renders at depth 1 with another camera. The problem i’m having is that whenever I add the PP effect to the objects camera, it also applies it to the background even though the background is rendered with another camera (which doesn’t have PP effecs applied).
So how would someone go about only applying a PP effect to an object but not the background when the background renders at a lower (camera) depth?
You can use shader tricks… The image post processing effects basically take the frame that was received AFTER all the rendering (the entire frame) and add some kind of effects to the image. It doesn’t know what the objects are, or what shaders they use. All post processing effects know is what you tell them, image-wise. Meaning - you could render a simple mask of your object (the one that is rendered last, without the background) which will be all white. That way, the frame you will get will be all black, except a white area where your object is. You can do that using a simple shader, and can even use the shader replacement feature.
Then, into your post processing event you feed both the original frame, and the mask you created - and make the effect only do its magic only when the appropriate pixel in the template is white…
The guys from PuzzleBloom demonstrated this exact method at Unite a couple of weeks back. Check out the shaders they used at http://robert.cupisz.eu/.
Maybe there’s a more elegant way of doing this… Perhaps there’s a way to control the image effects better, by using the messages that are received on the camera (OnPreCull, OnPreRender, OnPreRender, OnPostRender, OnRenderImage, OnRenderObject, OnWillRenderObject) combined with Camera.current to figure out which of the cameras is rendering right now. Maybe you can somehow change the render order using those. Try fiddling around with WHEN the image post-processing script runs (on which of the calls), and maybe even try changing the rendering order, and compose the image yourself using the post processing scripts…
Sorry I can’t help you with concrete stuff here, but I haven’t played with image effects enough.