Restrict object visibility to single camera?

Hey all,

Is there a method to have an object visible in one camera but not in another? I want to restrict which cameras can see which objects in the same scene. For instance two cameras could be aimed from different angles at a red and a green cube. In one viewport both would be visible but in the second only the red one would be visible?

Interested in that too. It’s already possible since there’s a per material option that toggles visibility to shadow buffering cameras.

two scenes

Overlaying scenes?
Add scene on camera one, remove scene on camera two?

Two scenes or using an overlay won’t work. Already using an overlay for UI elements and doubling almost everything in the scene for the effect isn’t really a workable solution. Oh well.

one scene for each camera

Why shouldn’t it be workable? Two cameras already double the number of faces to be rendered.

I read somewhere here on forums that there’s render layers python api in KX_Scene, but I’ve searched in the doc for that with no luck.

And no, different scenes won’t work since it would draw over/under every occluder in the way.

I wonder what you want to show with your different cameras. Without knowing more details of the use case it is hard to suggest a sufficient solution.

In GLSL as an offscreen render, sight based AI, … Etc.
It’s not a matter of knowing a way around to reach desired result, but a matter of knowing the actual method for it since I’m sure that I saw an example for it here.

i dont know if its even viable for multiple objects, but i figured it out for one object:
untitled.blend (564 KB)

im using properties and visibility.

controls
1 = camera one
2 = camera two

I do not know what an off-screen render is and why it should not render existing objects.
Why should a “sight based” enemy should not see existing objects? This sounds more like the object should not be present at all.

I ask for the use-case as there is no simple method to get this effect. Basically if you want to let one camera see different meshes as the other one, you need to feed them with different meshes.

You might consider the fact, that each render is processed in an own time slot. E.g. you could manipulate the data between the renders. But I really do not know if that is even possible.

One crazy way would effectively half your frame-rate (simple game could be 120+hz /2 = playable 60).
Use one frame where the object is set to visible in one camera( or video texture), and the next frame, when object is invisible on the other.

Thanks, this looks like a good start, but it only works when only one cam is activated, right?
So If you would have some kind of split-screen setup, which uses more than one camera at a time it wouldn’t work I guess…Is there a solution when using multiple cams at once?

Sorry for the bump, I forgot to keep track of the thread.

@Monster, as a way to detect enemies by rendering them only. Link for something similar

And no it’s not a hard or uncommon thing. How are shadow buffering cameras not rendering objects with shadows disabled?

I asked that because it is just not that easy. It is not build in (as for shadows).

Sometimes there are other options to achieve the goal (which does not necessarily need to match the question.) That is why I ask.

I think I can remember a thread where someone was analyzing the videotexture buffer.