Tuesday, August 5, 2014

Creating Stereo Renders in Blender

Recently I've been playing around with my Google Cardboard Viewer, and one of the things that I wanted more of was 3d content that could be viewed through cardboard. I eventually fired up blender and looked around for some resources on making stereoscopic 3d images. The first thing I found was Sebastian Schneider's plugin that automates the creation of a number of stereo cameras. The plugin didn't work great in the latest version of blender (2.71 while I was working on this) but does get most of the flow done.

I started with an animated cube, coming from behind the zero-parallax plane towards the cameras, and then retreating back behind it. In order to be able to render two cameras at once in blenders node compositor, you have to duplicate the scene, and then set default cameras for each scene. So after setting up the cameras, I duplicated the scene (Something I learned later that Sebastian's plugin does... although it complains while doing it). I then set up some nodes to render, lens distort, scale, transform, and mix the two scenes. Here's a shot of the node graph:

Unfortunately the effect wasn't great. Perhaps because there wasn't anything to compare distance against.

I then decided that maybe some more complex geometry would help. So I went and grabbed Andy Goralczyk's Creature Factory 2 turntable asset. I turned on the stereo cameras, set up the nodes, and rendered a shot. I quickly found that with a scene that takes ~20 minutes to render, that it might actually not be a great idea to render both shots together, distort, scale, and transform the beautiful renders while tweaking with the params. So I decided to go through a slightly different workflow. I would render each camera separately to a sequence folder. Then set up a different blend file to composite, and produce the images/videos. Here's the first render, that I posted on g+ that went through the original workflow:

Here's a few shots of the new workflow, that allowed me to scale out my renders to 4 different machines to make the overall process a bit faster. Also note that I scaled down the distance between the cameras to improve the perception of the size of the creatures.

And finally here is the HD Turntable Render, viewed best in Google Cardboard:

Making Stereo Pictures

So I've been messing around with Google Cardboard and one of the things that I wanted to do was create 3d pictures that I could view through cardboard. I remember one of my friends back in the day with the HTC EVO 3D, a phone that could take, and somewhat view 3d pictures. The phone had duel cameras on the back of the phone, and when you took a picture it would snap a picture from both cameras.

I just decided to slap my nexus 5 and my wife's nexus 5 together and take a few pictures to see how well I could reproduce the effect. Turns out it works quite well. Here's the 3 pictures that turned out decently:

In essence, you just put the two phone/cameras at the same level, and then distance them about eye distance from each other, make sure that they are focused on the same target, and that they aren't facing said target, but are both pointed parallel down range. Snap the pics at about the same time.

Now take the two photos, open up your favorite photo editor, scale them down, and place them side by side, view in cardboard and enjoy a surprisingly decent 3d image.

Some things that you may want to do would be to color balance, and generally do everything you can to make sure the two images look near identical.