Sub topic 1
The Camera Object and Its Camera Data
A Blender camera has two related parts:
- A camera object is the item placed in the 3D scene. It has a location, rotation, scale, and object name.
- Camera data stores the optical settings. It includes the lens, sensor size, projection type, clipping distances, and depth-of-field settings.
This separation is similar to a mesh object and its mesh data. Two camera objects can share one camera-data block, although separate data is usually clearer for different shots.
Prerequisites
You should know how to navigate the 3D Viewport, select objects, and distinguish the viewport from a rendered image. You should also know how to open the Properties editor. The Python example assumes that you can run a script in Blender's Scripting workspace.
How the Two Parts Work Together
The camera object determines where the camera is and which direction it faces. The camera data determines how that view is projected onto the image.
For example, moving the camera object changes the viewpoint. Changing its lens changes the field of view without moving the camera. The scene can contain many camera objects, but scene.camera identifies the one Blender uses for rendering.
Adding and Inspecting a Camera
To add a camera manually, use Shift-A > Camera. Select the new object and open the Object Data Properties tab, shown with a camera icon. The Object Properties tab contains transforms. The Object Data Properties tab contains camera settings.
The camera object and its data can have different names. Keeping related names consistent helps in larger scenes. For example, an object named ShotCamera can use a data block also named ShotCamera.
A camera does not need to be visible in the final render. Its object is a control that tells Blender how to observe the scene.
Creating a Camera with Python
The following script creates camera data, creates an object that uses that data, links the object to the current scene collection, and makes it active:
import bpy
scene = bpy.context.scene
camera_data = bpy.data.cameras.new("ShotCamera")
camera_data.lens = 50
camera_data.sensor_width = 36
camera_object = bpy.data.objects.new("ShotCamera", camera_data)
scene.collection.objects.link(camera_object)
camera_object.location = (7.0, -7.0, 5.0)
scene.camera = camera_object
print(f"Active camera: {scene.camera.name}")
print(f"Lens: {scene.camera.data.lens} mm")The call to bpy.data.cameras.new() creates only the data block. The call to bpy.data.objects.new() creates the scene object and connects it to that data. Linking the object makes it part of the scene. Without linking, the camera exists in Blender's data but does not appear in the scene collection.
Common Errors
A camera may fail to render as expected when:
- The camera object was created but not linked to a collection.
scene.camerastill points to a different camera.- The camera faces away from the subject.
- The camera data was changed on a different camera object that shares or does not share the expected data block.
Check both the selected object's transform and the camera named in the Scene Properties.
Exercise
What is the difference between a camera object and camera data, and which setting chooses the camera Blender renders through?
Show answer
The camera object stores the scene position and rotation. Camera data stores optical settings such as the lens and projection. The scene's camera property chooses the camera used for rendering.