Generating stereoscopic images with parallax occlusion mapping
April 22nd, 2008 by Erik Benerdal
I rarely do experimental programming, but I had an idea today that I wanted to try. Maybe it’s not a new idea but at least I thought of it on my own.
Stereoscopic images are usually photos taken by two seperate cameras aimed at the same object but a small distance apart from eachother. The difference in position will let one camera see the object at a slightly different angle than the other. By looking at the two images side by side and crossing your eyes you will experience a 3D effect. Other than the eye-strain it’s a neat effect.
I liked the idea and thought about ways to generate a steroscopic image from a single flat image. The idea I came up with was to fake depth in the original image and then render two snapshots of it from slightly different angles. There’s a popular method employed by game developers for faking depth in otherwise flat textures called Parallax Occlusion Mapping. The idea is to use a heightmap and some clever math to make parts of the image “pop out”.
The implementation was really straight forward. I just found a parallax mapping shader online, converted the code to C++ and threw some sample images at it.
See my results after the break.
Continue reading ‘Generating stereoscopic images with parallax occlusion mapping’
