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

This tutorial contains some tips for how to work with stereo images.
Stereo viewing is to see the same thing from two slightly different angles. This is what humans normally do with their 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.

## The stereo camera

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

### Create it
#### Manually

* Reset the cameras position, rotation and size (you can use Alt + G , Alt + R and Alt + S ). 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 ( I ).
* Create two new cameras. Reset their position, rotation and size too.
* Name them Camera.Right and Camera.Left or similar. Set LocX to 1 for Camera.Right and -1 for Camera.Left. (Press N 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.)
* 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.
* Switch to front view. ( 1 )
* Select Camera.Left. Then select Camera while holding down Shift so both are selected. Press Ctrl + P and press Enter to register Camera as parent. Then press Ctrl + L and select Camera Data. Repeat with right Camera.Right and Distance Cube.

#### With a script
### 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 S ) so you can see the end of the cube if needed. Point at the end of the cube with the mouse pointer, and press S . 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 + 0 .

### What needs improvement
#### The cube is visible

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

#### 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.

#### 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. Then 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.

## Stereo viewing with the rig

This is where it gets exciting, now you are actually getting something to look at.
* Create a new screen, you could call it Stereo View.
* The screen should have one big area from side to side.
* Set the area to 3D View
* Unlock it (The Locks layers and used Camera to Scene-lock)
* Select Camera.Right and press Ctrl + 0
* Split the area in half so there is two parts next to each other
* In the right area, select Camera.Left and press Ctrl + 0
* 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.
* 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.)
* Press Shift + Alt + A to see your scene animated in stereo.
If you cannot see these, there is a lot of help with viewing them on the web. Use a search engine to find them.

## Stereo rendering
### Anaglyph

Create two render layers in the Render Layers tab.
Then go the Node Editor and click on the button with a human face. Click on Uses nodes and remove the created items by selecting the items and clicking on Del . Now, using the Add menu, you need to do this diagram:
Once done, return to the Buttons window and select the button Do Composite on the Anim tab:
Then click on the button Render on the Render tab:
You should see your objects as an anaglyph: