Applying image effects to just one camera in a multi-camera setup?

Hey all,

I’m working on an AR project that’s compositing 2 cameras: one that’s the external camera feed of the real world, the other is for the virtual objects that are being added on top of it.

It’s a fairly simple setup:

Real Camera is assigned to depth 0

Virtual Camera is assigned to depth 1 with no clear flags, so it renders on top of the Real Camera, like so:



So far I’ve just been using trying to apply the default Unity image effect shader, which inverts colors. I created a material with that shader, and applied it using:

    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Graphics.Blit(source, destination, postprocessMaterial);
    }

My problem is I only want the effect to apply to the Virtual Camera, like so:

However, even though I only put the script on the Virtual Camera it applies the effect to both the Virtual and Real Cameras, like so:

Is there a way to apply an image effect to only one camera?

I’ve seen suggestions about using a stencil buffer, but I’m not sure how it’d apply here. If possible, I’d prefer not to use custom materials/shaders for the objects in the scene, only for the image effect on the camera. Any help would be greatly appreciated!

Hey all, for anyone looking into this in the future I found a pretty good solution here: Unity & Vuforia - How to mask Image Effects e.g. Bloom

1 Like