Stereoscopic 3D Glasses Tutorial

From Wiki
Jump to navigation Jump to search


Stereoscopic imaging works on the principle that each eye sees a slightly altered image, which are then combined in our mind to form a 3D mental picture. In photography, this is accomplished by moving two cameras slightly apart from each other to simulate the distance separating our eyes, and then taking two photographs. However, stereoscopic images can also be created using a program like POV-Ray. In this tutorial I will explain how to render and display stereoscopic images of LDraw models using LDView and POV-Ray, as well as a special stereo image program called StereoPhoto Maker and a cheap stereoscope you can purchase on Amazon.


Step 1: Using MLCAD and LDView

The first thing you want to do is create your LDraw model in MLCad, LDCad, or whatever 3D modeler you prefer. When you are done, load your model in LDView and position your camera where you intend to view the scene from. In my case, I used the default camera orientation. When your camera is positioned properly, go to the "File > Export..." dialog, and export your model to a POV-Ray file. Again, I used the default settings, but you can change them to whatever you want to increase the render quality and so forth.

Step 2: Using POV-Ray

Once you've exported your model in LDView, you should open the file in POV-Ray. If you are using POV-Ray version 3.7 and LDView version 4.1, the first thing you will want to do is insert the following code at the top of the file. Otherwise, the colors will all be messed up. Future versions of LDView may not suffer cause this problem.

#version 3.6

Once you have inserted the above code, scroll down to the section labeled "camera" and replace the camera code block with the following.

// Camera
#ifndef (LDXSkipCamera)
	#declare camera_eye = 1;			// -1 = no eye, 0 = left eye, 1 = right eye
	#declare LDXCamAspect = image_width/image_height;
	camera {
		location	LDXCameraLoc
		sky		LDXCameraSky
		right		LDXCamAspect * < -1,0,0 >
		look_at		LDXCameraLookAt
		angle		57.822403
		#switch (camera_eye)
			#case (0)
				#include ""
				translate	-LDXCameraLookAt
				Axis_Rotate_Trans(y, +5/2)
				translate	+LDXCameraLookAt
			#case (1)
				#include ""
				translate	-LDXCameraLookAt
				Axis_Rotate_Trans(y, -5/2)
				translate	+LDXCameraLookAt

Note the variable named "camera_eye". This variable controls which "eye" is being simulated. 0 means the left eye, 1 means the right eye. For now, leave this variable set to 1.

To get good results, you want to render your image at a very high resolution. Each output image needs to be roughly 3 inches wide and 3 inches tall, and a dpi (dots-per-inch) value of 1200 is a good target when printing on most home inkjet printers. Therefore, you want to render at 3600 x 3600 pixels (1200 dpi multiplied by 3 inches = 3600 dots or pixels).

Since 3600 pixels by 3600 pixels is not one of the default output image resolutions, you will have to either edit the POV-Ray INI file, or type some extra command-line options into the POV-Ray input bar. For the sake of brevity, I will ignore editing the INI file, and instead tell you to type the following into the input bar.

+W3600 +H3600