Rendering images in 3D for your 3D TV with POV-ray.

Having a little bit of spare time this week, and being aware of the broadcast of “The Day Of The Doctor” in 3D, I have turned my attention to making sure the 3D function of my TV is working properly.

The problem is content, or how to get it without paying for it. A solution would be to make it from resources already available for free.

There are many Ray-tracing software packages available, one of those is POV-Ray.
I’m using version 3.6, I know version 3.7 is now available but there might be unanticipated features. In common with some of my other compute-oriented posts I’m using Ubuntu Linux. Pre-compiled windows binaries of POV-Ray, Imagemagick and EXIFTool are available.
I acknowledge the hard work and expertise of Friedrich A. Lohmüller with his excellent pages on the subject of rendering stereo pairs with POV-Ray here.

I have tested the output with my Panasonic TX-P42UT50B TV and the corresponding 3D glasses for it.

After installing POV-Ray, and checking you have the other software Imagemagick and EXIFTool available, you need to choose a POV-Ray scene file to render. For my test I used the woodbox.pov scene from the folder /scenes/advanced.

You will need to modify the scene file, so copy it and insert the lines which begin “// stereo view:“. The the scene file will have a camera declaration already, so make a note of the location and look_at co-ordinates. Copy these in to the stereo camera section, then you can delete the now-redundant (non-stereo) camera declaration. Save the scene file.

On Friedrich A. Lohmüller’s page there is a short .ini file. You need to copy this file to your work folder. You must use the same name for your scene file, and the .ini file. This .ini file automates the rendering of the left and right eye images.

At this point it is a good idea to do a low-resolution test render of your image. If your scene file is called test.pov and you should have a file called test.ini in the same folder. Run this command:

povray test.ini +Itest.pov +Otest.tga +W480 +H270 +FT

The result should be two images. You can view them in your favourite image viewer, but if you want to view them in 3D there is a simple way to do that. Run this command:

montage test1.tga test2.tga -geometry +0+0 stereo.png

To make a side-by-side image suitable for cross-eyed viewing.

You might find the camera is too close, or too far away from your scene. You can adjust the camera location by changing it’s position as defined on the line:

#declare Camera_Position=<x,y,x>;

What you’re actually changing is the centre-point between the two viewing positions, left and right. Re-render the preview until you’re happy with it. When you are ready to move on to the next stage do this:

povray test.ini +Itest.pov +Otest.tga +W1920 +H1080 +FT +A0.3

It’s probably a good idea to make yourself a cup of tea at this point. When the rendering is complete, the next task is to make the images viewable on your TV. Convert them to the JPEG format:

convert test1.tga -quality 85 test_R.jpg
convert test2.tga -quality 85 test_L.jpg

This last step is to convince the TV that the images were created at the same time, use EXIFTool to make the Create Date tag on both images identical. Note that the content of the tag does not need to be accurate, just match on both images:

exiftool -CreateDate=201311191000 test_L.jpg -overwrite_original
exiftool -CreateDate=201311191000 test_R.jpg -overwrite_original

Copy the images to an SD card, and insert that in to your TV. With my TV, you need to tell it that you want to view a stereo pair. Having started the photo viewer on the TV, press Option and it’s the second menu entry. Choose the left image first with the red button. The letter L appears before R in the alphabet, and the TV always sorts the images in the same way.

Advertisements

Tags: , , , ,

2 Responses to “Rendering images in 3D for your 3D TV with POV-ray.”

  1. Jim Holsenback Says:

    Interesting post. I’d bet that you’d be much happier using version 3.7 unix build. It supports SMP (multi-core) operation so it’s sure to out perform version 3.6 … especially since you seemed to be indicating that you are running the windows binaries. Is that via Wine, or some other emulator?

  2. barrowbiker Says:

    I’m running the version 3.6 Linux version, I acknowledge that there is a Windows version only because there are still more Windows users than Linux users out there.
    I’m sorry that wasn’t clear.
    I will try substituting version 3.7 of POV-Ray, to see if it makes any difference. Historically I’m never in a rush to install the bleeding-edge newest versions of software, currently I am still using Ubuntu 12.10 despite version 13.10 being available.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: