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 cameraEdit
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.
- Reset the cameras position, rotation and size (you can use + , + and + ). 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 ( ).
- 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 to see data for selected object, in this window you can change name and values.) (Select a camera by clicking several times on the cameras, until the right one is selected.)
- Create a new cube (remember to press 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. ( )
- Select Camera.Left. Then select Camera while holding down so both are selected. Press + and press to register Camera as parent. Then press + and select Camera Data. Repeat with right Camera.Right and Distance Cube.
With a scriptEdit
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()
How to use itEdit
- 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 ) so you can see the end of the cube if needed. Point at the end of the cube with the mouse pointer, and press . 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 + .
What needs improvementEdit
The cube is visibleEdit
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 seeEdit
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 infinityEdit
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 rigEdit
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 +
- Split the area in half so there is two parts next to each other
- In the right area, select Camera.Left and press +
- 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 + + 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.
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. 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: