Hey,
we are using the DoF 3.4 image effect in most of our scenes. But because there are known problems with transparent materials not writing to the depth buffer,
we are using a 2nd camera that only renders specific layers for this kind of stuff. The 2nd camera is basicaly a duplicate of the main camera and always a child of it.
It’s stripped from all components, has it’s clear flags set to Don’t Clear and a higher depth value than the main camera.
The problem:
When the 2nd camera is active, it somehow interfers with the image effects on the main camera.
For example the DoF effect just doesn’t work. But we have other effects on our cameras too, like SSAO and Bloom effects and they don’t work right too.
Now for the really creapy thing: I started adding some other image effects (like the Fisheye), configured them to don’t actually do anything and started de-/activating some of them.
And with some additional effects, everything seems to work. So I wrote an effect that doesn’t do anything else than doing a simple blit. And that seems to work sometimes, too.
Some additional info:
We need to use deferred rendering, because we need all the shadows we can get.
Every image effect on the main camera is working when we set the 2nd camera to Forward rendering. But we can’t use that, because we need to share the depth buffer between
the two cameras so the objects rendered by the 2nd camera get occluded by objects in the front.
We might even have more additional cameras that render different kind of stuff (for example a selective glow effect).
We are using Unity 3.5.5, target platform is Windows PC.
For clarification I’ve put together a simple example project.
It’s showing the configuration of both cameras. There’s the DoF effect attached to the main camera and the simple blit-effect I mentioned is actually attached 2 times to make it work.
The funny thing is, the DoF is working when both the PostFix effects are active, but when you just deactivate one of them, it stops working.
The link to the project: Microsoft OneDrive
The question:
Can anyone explain that to me? I really don’t understand what’s going on there, why is the 2nd camera interfering with the image effects and why are they working when
there are other effects attached to the camera that don’t do anything? And most importantly, is there a real fix for this problem, are we doing anything wrong?
Or do we have to live with this workaround that can break every time we change anything on our cameras?
I really hope someone can help us.
Thanks in advance.
Max