- Home /
Is there a way to render a single object with a unique color per active camera?
So, for example: I've got a sphere that has a Diffuse shader on it, and two active cameras in my scene running split-screen. Camera A and Camera B would both be looking at the sphere, and Camera A would render it with red as it's Main Color, and Camera B would render it with blue as it's Main Color.
Is there a way to do this?
One thought I've had is to perhaps create two "worlds" with Camera A being in one and Camera B being in another, and just mirroring all movement between them.
Answer by robertbu · Jan 26, 2014 at 02:25 AM
I'm away from my desk and cannot test it, but it seems to be that Monobehaviour.OnPreRender() might do the job. This callback needs to be on a script attached to the camera. For the camera that needs to see the object in an alternate color, have it change the color in OnPreRender() and restore the color in OnPostRender().
An alternate solution would be to have two of the same objects (but different colors) at the same position (parent/child would do it). Each object would be on a different layer, and the culling mask for each camera would be set to only display one of the two objects.
Your answer
Follow this Question
Related Questions
CommandBuffer's CameraEvent ordering not in sync with shader rendering queue? 1 Answer
Is it possible to only render on one side of a plane? 4 Answers
"Motion vectors" and "depth with normals" from camera's target texture 1 Answer
Uniform Texture, Rendering Problem 0 Answers
object not rendered correctly when i take camera away from object in unity vuforia 0 Answers