- Home /
How to make an object unaffected by image effects but can't be seen through walls?
I have a camera that has a sepia image effect on it, but I have a single object in my scene that I do not want to be affected by this. As such, I created 2 cameras and added that object to its own layer. I parented my original Main Camera to the secondary camera (so they will see the same view) and set the secondary camera to a depth of 1 and clear flags at depth only, while the main camera has a depth of 0 and is set to skybox for clear flags.
The culling mask on the secondary camera is set to only see the layer my object is on, while the Main Camera sees everything except that. The effect it as desired: the object still shows up in color while everything else is sepia. However, I can see this object through walls (which I have on the default layer). In addition, when I look around the scene, the object appears to slightly move with my camera instead of remaining where it is.
How can make walls obstruct my view of this object? I tried putting the walls on a separate layer and making this layer viewable by the secondary camera, which does block the view of the object, but for some reason the sepia no longer shows up. This is probably just me being stupid.
Thanks!
Answer by thebarryman · May 12, 2013 at 04:16 AM
Your clear flag is set to depth only, which means that when it comes time to render your colored object, the depth buffer is cleared. This is what causes your colored object to be seen through walls: there is no depth buffer to depth-test against.
Try setting your secondary camera's clear flag to "don't clear" and see what happens.
Your answer
Follow this Question
Related Questions
Unity - blur on one camera effects the other as well 0 Answers
Rendering a camera in front of a gui element 3 Answers
If camera renders Skybox some objects don't get shown 1 Answer
Blur Effect 0 Answers