- Home /
Weird behaviour with multiple cameras and image effects
I am trying to implement a layered camera system where different image effects are applied to different layers/cameras and all cameras are stacked on the main view. After having some weird problems and behaviour contradicting the documentation I tried pinpointing the problem with a test app. The testapp results in suprising behaviour (at least suprising to me), so hoping if someone could explain what is happening or if this is due to a bug ?
My test setup is two same size, partially intersecting cubes on own layers and separate camera per layer:
first cube is in layer 'cube1'
second cube is in layer 'cube2'
first camera has "skybox" clear flags, culling = "everything" except layer 'cube2', depth = 1
second camera has "don't clear" flags, culling = "cube2", depth = 2
first camera has "Screen Overlay" image effect with noise pattern
What I was assuming to see was the first cube behind an screen sized noise pattern and the second cube drawn normally on top. However, what I was seeing was this:
It looks like there's some kind of depth fighting going on resulting with the cube2 only partially rendering on top of the first camera. Because I couldn't figure out how to fix I tried playing with rendering quality settings to see if they have any effect and to my suprise enabling antialiasing fixes the problem, i.e. I get this
This fix works in all quality level presets, even in the "fastest" preset.
So the question is why the problem and what does the antialiasing do that fixes the problem? Is there way to fix this programmatically without enabling the AA setting ?
I'm using Unity 4 Pro on Macbook Pro with NVIDIA GeForce 9400M.
Thanks -Julle
The test app is here: http://dl.dropbox.com/u/6457524/imgeffectproblem.unitypackage
Open the "cubes" scene and run to see the problem. To see how the AA fixes the problem go to Edit->Project Settings->Quality and enable AntiAliasin (in any quality level).