Blender 3D: Noob to Pro/Add some depth with stereo

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Sebastian Schneider has created a usefull python script that really make Stereo camera very easy in blender.

http://www.noeol.de/s3d/ for more details or follow this tutorial below.


This tutorial contains some tips for how to work with stereo images. I'm writing this to help others, to have my notes easily available, and to let others improve my ideas.

Stereo viewing is to see the same thing from two slightly different angles. This is what humans normally do with our two eyes. There are many ways to view a stereo image. A perfect method is to use a stereo monitor. But they are quite expensive, and many are of very low quality. In the other end of the price-scale you can use crossviewing. Put the two images next to each other, and look at one with one eye, and the other with the other eye. Needs a bit of practice though. A popular solution is red/blue anaglyph glasses, but they give very bad colors.

Contents

[edit] The stereo camera

I wanted a stereo camera rig that was easy to work with. It should have three cameras (center, left right), have an easy way to set separation (should be 1/30 of the distance) and I would only need to work with the center cam (position etc.), to others should just follow.

[edit] Create it

[edit] Manually

  1. Reset the cameras position, rotation and size (you can use ALT+GKEY, ALT+RKEY and ALT+SKEY). You may want to note these values first, so you can change them back later. I just make sure there's an IPO-curve for them, for example by making a keyframe (IKEY).
  2. Create two new cameras. Reset their position, rotation and size too.
  3. Name them Camera.Right and Camera.Left or similar. Set LocX to 1 for Camera.Right and -1 for Camera.Left. (Press NKEY to see data for selected object, in this window you can change name and values.) (Select a camera by clicking RMB several times on the cameras, until the right one is selected.)
  4. Create a new cube (remember to press TAB to exit edit mode). Reset position, rotation and size. Name it Distance Cube and set these values: LocZ: -30. SizeX: 0.1. SizeY: 0.1. SizeZ: 30.
  5. Switch to front view. (NUM1)
  6. Select Camera.Left. Then select Camera while holding down SHIFT so both are selected. Press CTRL+PKEY and press ENTER to register Camera as parent. Then press CTRL+LKEY and select Camera Data. Repeat with right Camera.Right and Distance Cube.

[edit] With a script

I tried making a script that creates the rig, it almost works. Any help finishing it?

import Blender
from Blender import *

# Prepare
scene = Scene.getCurrent()
camera = Object.Get("Camera") # TODO validate that it is a camera
oldLocation = camera.loc
oldRotation = camera.rot
oldSize = camera.size

# Create stuff
c = Camera.New("ortho")
cameraLeft = Object.New("Camera", "Camera.Left")
cameraLeft.link(c)
scene.link(cameraLeft)

c = Camera.New("ortho")
cameraRight = Object.New("Camera", "Camera.Right")
cameraRight.link(c)
scene.link(cameraRight)

dEmpty = Object.New("Empty", "Distance")
scene.link(dEmpty)

# Configure
camera.loc = (0,0,0)
camera.rot = (0,0,0)
camera.size = (1,1,1)

cameraLeft.loc = (-1,0,0)
cameraLeft.rot = (0,0,0)
cameraLeft.size = (1,1,1)

cameraRight.loc = (1,0,0)
cameraRight.rot = (0,0,0)
cameraRight.size = (1,1,1)

dEmpty.loc = (0,0,-60)
dEmpty.rot = (0,0,0)
dEmpty.size = (1,1,1)

scene.update(1)

# Connect
camera.makeParent([cameraLeft, cameraRight, dEmpty], 0, 0)
# do that CTRL+LKEY thing
cameraLeft.link(Camera.Get("Camera"))
cameraRight.link(Camera.Get("Camera")) 

# Reset original values

camera.loc = oldLocation
camera.rot = oldRotation
camera.size = oldSize

# Finish
Blender.Redraw()

[edit] How to use it

  • Never change the cube or the two side-cameras. Only change the center camera. Use that one for positioning, rotation etc.
  • To set the separation: As always, select the center camera. Resize it (with SKEY) so you can see the end of the cube if needed. Point at the end of the cube with the mouse pointer, and press SKEY. Move the mouse pointer to the point of the main motive, that is closes to the camera. The end of the cube may not end exactly there, but that doesn't matter.
  • To render (or preview) with one of the side cameras, select it and press CTRL+NUM0.

[edit] What needs improvement

[edit] The cube is visible

In stead of using a cube, I'd rather use something that doesn't render. It could be an "empty", but see below.

[edit] The cube is hard to see

It can be hard to see where the cube ends, even in a simple scene. You can select the center camera AND the cube, then it is clearly visible. But you must remember to only select the camera, before you insert a keyframe, so your changes to the cube doesn't get saved.

[edit] Distance plane is at infinity

The distance plane is where "zero depth is". When viewing a stereo image, the distance plane is where the medium is. In this rig the distance plane is at infinity, meaning everything is in front of it. While stuff popping out in front of the screen is cooler than stuff being "inside" the screen, it's a lot harder to make it look nice. Specially because with everything in front of the screen, it's easy to get stuff that is just way to close to the viewer. It can get so hard to see that the 3d-effect is completely gone.

A different solution is to make the side cameras point at the end of the cube, or add a plane to the rig, and point at that. But then the cameras are no longer parallel, and that creates distortion.

The compromise solution is to (conceptually) render the images too wide, and then crop the excess from the left side of the left image, and the right side of the right image. The it will look like it points just like in the previously mentioned solution, but without the distortion.

But this give a lot of problems. First, I'd like to do this a smarter way, instead of just following the path describe above. But I don't think that's possible in Blender. (I think povray can actually do this.) So I need to render the image too wide. But if I increase width in output, it actually renders the same width of the motive, but decreases height. Then I need to do some weird math to get the right FOV, and I don't know half the formulas. Cropping must be done outside Blender, and the rest of "the production line" is hard to get back into Blender if wanted.

I guess a couple of planes in the rig close to the cameras could simulate the cropping, but that is of limited value. To make an adjustable distance plane with them seems quite hard to me, it would need some scripting I guess.

[edit] Stereo viewing with the rig

This is where it gets exciting, now you are actually getting something to look at.

  1. Create a new screen, you could call it Stereo View.
  2. The screen should have one big area from side to side.
  3. Set the area to 3D View
  4. Unlock it (The Locks layers and used Camera to Scene-lock)
  5. Select Camera.Right and press CTRL+NUM0
  6. Split the area in half so there is two parts next to each other
  7. In the right area, select Camera.Left and press CTRL+NUM0
  8. Adjust zoom in both areas so the frame that shows what is rendered is completely visible, but fill as much as possible. If you can't make them same size, the two areas are not same size.
  9. Use cross-view method to see the 3d-effect. Look at the left area with the right eye and right area with the left eye. (It's a skill you need to learn and practice.)
  10. Press SHIFT+ALT+AKEY to see your scene animated in stereo.

note from reader: If you cannot see these, there is a lot of help with viewing them on the web. Use a search engine to find them.

another note; you can also render the scenes separately and combine them with gimp/photoshop to be used with 3d-glasses[1]

[edit] Stereo rendering