17

I'm trying to set up multiple cameras for a scene set in a room. Is there a way to link object visibility to a specific camera? Ideally, a wall or ceiling would not render if it were in the way of the specified camera.

I've tried to get around this by keyframing Restrict Rendering, but that gets difficult to keep track of. I've also tried adjusting the clipping plane, but that clips too much and would also need to be keyframed if the camera moves.

Thanks!

kopi_bon
  • 1,067
  • 3
  • 10
  • 22
  • 1
    This is not possible as far as I know. Common workflow is to use several scenes instead, each with linked objects but different active cameras. Remove undesired objects on each one. – Duarte Farrajota Ramos Sep 20 '17 at 17:28
  • You can try to use Render Layers. Here's an example: https://www.youtube.com/watch?v=VUETvN-qtvk – Giraldi Feb 03 '24 at 14:03

1 Answers1

14

This is possible using Drivers similar to the method described in the answer to How to change world background based on active camera?

You should set the Pass Index for each of the Camera objects so as to identify each camera.

pass index

Then add the driver to the visibility of the object being controlled - either the eye icon in the Outliner or the Camera icon - depending on whether you want to control the visibility only in the 3D view or in the final render.

add drivers to outliner

Set the Driver expression to :

bpy.context.scene.camera.pass_index == n

Where 'n' is replaced with the pass_index of the camera from which you want that object to be hidden. Repeat for each object, specifying the relevant 'n' for each driver as appropriate.

Changing the active camera should now hide the object from view. Note that the driver will not necessarily update the visibility but will be updated on the next frame change - so animating the change in active camera on a specific frame will now automatically change the visibility of the objects.

Here I had 4 cameras positioned around the objects - with Pass Index of 1,2,3,4 - with the visibility of the objects (Cone, Cylinder, Torus, Icosphere) driven appropriately and the active camera changing on each marker :

animated

Rich Sedman
  • 44,721
  • 2
  • 105
  • 222
  • 1
    Brilliant! Works perfectly. Thanks for your help! – kopi_bon Sep 20 '17 at 21:49
  • 1
    3 years later (2.9beta) this trick doesn't update the viewport but still works fine for renders – pevinkinel Aug 26 '20 at 15:57
  • 1
    I can confirm that it still works in Blender 3.0 (and only for the render view). Another tip is if you want a particular object to show up only for a particular camera, just change it to: bpy.context.scene.camera.pass_index != n – Totomobile Dec 30 '21 at 14:58
  • Works for Render Visibility in Blender 3.2 != tip by @Totomobile is helpful. – Thiagarajan Jul 19 '22 at 10:50