Povray I: Beginning with Povray

ArticleCategory: [Choose a category for your article]


AuthorImage:[Here we need a little image from you]

[Photo of the Author]

TranslationInfo:[Author and translation history]

original in es Antonio Castro 

es to en David Escorial

AboutTheAuthor:[A small biography about the author]

Computer Science is my profession and also part of my free time. I like to share my hobby, as everyone probably does. I admit it! I am one of those strange characters who dislikes windoze.

Abstract:[Here you write a little summary]

This article begins a series about the Povray raytracer. The purpose of the current article is to help novice Linux users to get started with POV-Ray.

ArticleIllustration:[This is the title picture for your article]


ArticleBody:[The article body]


Povray (Persistence of Vision Raytracer) is basically a ray tracer. It is hard to explain what this term means without getting into a number of details so let's save a detailed explanation of what a ray tracer is for future articles. For the moment it suffices to sketch the concept of raytracing: It is a technique to render imaginary scenes defined in the computer through the use of models, which declare the existence of objects and their shapes, as well as points, light sources and a camera. The computer tries to render an image as realistic as possible while maintaining a minimum processing time.

When possible POV-Ray tries to imitate nature. Sometimes POV-Ray has to settle for just imitating or simulating a natural effect. Without such shortcuts it would be impossible to render an image in a reasonable amount of time. Raytracing algorithms work by computing a large amount of rays (like light beams), however these rays do not behave like real optical rays. In nature, rays originate in light sources, move in space and whenever they encounter a physical obstacle (i.e a surface) they scatter, generating a new ray that goes from the point on impact to the retina's viewer or the camera's film. On the other hand, in a raytracer rays move backwards, from the viewer or film to the objects and then back to the light sources. We will leave a detailed explanation as to why and how of this algorithm for the next article.

The quality of Povray is excellent and is comparable to most commercial raytracers. Commercial design products based on raytracing do have integrated tools for designing comfortably all sort of objects.

In the case of Povray, it is possible to use modelers from different independent companies or format filters, and in general the user has a great variety of tools available. This does not mean that it is impossible to achieve a beautiful or even fantastic design using exclusively Povray. Imagination is all that is required.

Another important point is that the source code is public, allowing us to examine the various techniques used. Povray's copyright is described in Appendix A of the manual, as Linux it is a freeware license. Check out the details in the original license.

There is a Povray manual available in a text version (easy for fast browsing), in HTML and postscript formats. If you think to print out the postscript file, you should prepare about 600 sheets; huge because of the great possibilities of Povray, but do not feel intimidated. In the present article you will be able to try out Povray and in next articles we will learn basic concepts.

With Povray we enter the world of computer science through the front door, all thanks to its wonderful technical capabilities. My concept of computer science is based on the notion that although pure technologies can help us to obtain images with high realism, nevertheless artistic value does not equal realism nor technology itself. Technology is a valuable assistant, but everything that has real artistic value has to be conceived in our minds first. The idea is the main goal.

Many times I like to play with the concepts of realism and fantasy. Computer science allows us to play this game of one and a thousand shapes creating an interesting conflict for the viewer.
I keep a small image gallery created using Povray at:


Here is an example, a hybrid design: an airplane, a sailing ship and a seagull.

Seagull 1 

Seagull 1

In this first image we can see more likely a seagull.


Seagull 2 

Seagull 2

However, from a second perspective you can say that it resembles more an airplane while it is still the same object.

The object has the silhoulette of a seagull. In the upper part, it has a transparent cockpit and two pilots are easily visible. The pigmentation is strange but with the raytracing these pictures can achieve a degree of astonishing realism.

If you show these pictures to a 5-year old child, and ask him what he sees, he will likely answer that it is a photo, not a drawing. Showing the same pictures to an adult, would perhaps reveal that the person has some difficulties to classify it. The person will say that it is clearly neither a drawing nor a photo. Maybe he will know that it was produced by a computer, but how can a machine create this strange and beautiful scene?

This kind of effect is the one I seek in my designs. Conflicting images where synthetic and artificial are put together in harmony with several realistic features. For this to do you need without a doubt imagination and a good knowledge of the technique. On the other hand, to get very realistic images, you should have a complete control over the technique, but maybe this can not be necessarily called art.

I have truly spent many very good times with Povray and I'm sure that anyone that gets to know it will enjoy it the same.  

Some of the most important features of Povray

How to obtain Povray

Povray can be obtained by ftp.
The official site where you can get it, is the following:


There is also an electronic magazine about povray, however, it looks abandoned, it keeps some good issues that first appeared when the Povray 3.0 was released.


There are lots of MIRRORS but none of them are official.




Index: (15-January-1998) ftp.povray.org

Here, we enclose a short listing of the contents of the official site.


   lrwxr-xr-x  1 povray  vuser   15 Aug 24 11:12 HEADER -> povray/.message
   drwxr-xr-x  5 povray  vuser  512 Aug 24 13:13 povray
   -rw-r--r--   1 povray  vuser   305 Jan  9 01:30 .message
   lrwxr-xr-x   1 povray  vuser     8 Aug 24 13:13 HEADER -> .message
   dr-xr-xr-x   2 povray  vuser  1536 Aug 24 13:13 Hall-Of-Fame
   -r--r--r--   1 povray  vuser  3262 Aug 24 10:52 MIRRORS
   dr-xr-xr-x  10 povray  vuser   512 Aug 24 11:14 Official-3.0
   -r--r--r--   1 povray  vuser  3262 Aug 24 10:52 README.MIRRORS
   -r--r--r--   1 povray  vuser  3731 Aug 24 10:52 README.MIRRORS.HTML
   dr-xr-xr-x   2 povray  vuser  1024 Aug 24 13:13 Ray-Tracing-News
   -r--r--r--  1 1017  1017  235235 May 14  1996 6x86.jpg
   -r--r--r--  1 1017  1017  393630 Sep 30  1994 6z4.jpg
   -r--r--r--  1 1017  1017     308 Sep 30  1994 6z4jpg.txt
   -r--r--r--  1 1017  1017  154256 Oct 13  1995 astplant.jpg
   -r--r--r--  1 1017  1017    2991 Oct 13  1995 astplant.txt
   -r--r--r--  1 1017  1017  110322 Sep 30  1994 ballz5.gif
   -r--r--r--  1 1017  1017  287164 Dec  8  1994 bell_jar.jpg
   -r--r--r--  1 1017  1017   57111 Oct 13  1995 bkntools.jpg
   -r--r--r--  1 1017  1017     610 Oct 13  1995 bkntools.txt
   -r--r--r--  1 1017  1017  331058 Sep 30  1994 brass.jpg
   -r--r--r--  1 1017  1017     254 Sep 30  1994 brass.txt
   -r--r--r--  1 1017  1017  284250 Sep 30  1994 bug1.gif
   -r--r--r--  1 1017  1017  279273 Sep 30  1994 camera.jpg
   -r--r--r--  1 1017  1017  367490 Oct 13  1995 crane.jpg
   -r--r--r--  1 1017  1017    2650 Oct 13  1995 crane.txt
   -r--r--r--  1 1017  1017  101473 Sep 30  1994 dragons.jpg
   -r--r--r--  1 1017  1017  295129 Sep 30  1994 frosty.gif
   -r--r--r--  1 1017  1017  777531 Sep 30  1994 frosty.tga.zip
   -r--r--r--  1 1017  1017   88350 Sep 30  1994 geodome.jpg
   -r--r--r--  1 1017  1017    2252 Sep 30  1994 geodome.txt
   -r--r--r--  1 1017  1017   11801 Sep 30  1994 geosmall.gif
   -r--r--r--  1 1017  1017  356889 Oct 13  1995 gofood1.jpg
   -r--r--r--  1 1017  1017     483 Oct 13  1995 gofood1.txt
   -r--r--r--  1 1017  1017  375781 Oct 13  1995 gogadget.jpg
   -r--r--r--  1 1017  1017     825 Oct 13  1995 gogadget.txt
   -r--r--r--  1 1017  1017   72337 Oct 13  1995 info_hwy.jpg
   -r--r--r--  1 1017  1017    1796 Oct 13  1995 info_hwy.txt
   -r--r--r--  1 1017  1017  109462 Oct 13  1995 jmwarmup.jpg
   -r--r--r--  1 1017  1017    3346 Oct 13  1995 jmwarmup.txt
   -r--r--r--  1 1017  1017     628 Sep 30  1994 julia.txt
   -r--r--r--  1 1017  1017   50762 Sep 30  1994 kettle.jpg
   -r--r--r--  1 1017  1017  295555 Sep 30  1994 kkteaset.jpg
   -r--r--r--  1 1017  1017      96 Sep 30  1994 kkteaset.txt
   -r--r--r--  1 1017  1017  151503 Sep 30  1994 lionfish.gif
   -r--r--r--  1 1017  1017     112 Sep 30  1994 mindmaz1.txt
   -r--r--r--  1 1017  1017  341101 Sep 30  1994 museum.jpg
   -r--r--r--  1 1017  1017     564 Sep 30  1994 museum.txt
   -r--r--r--  1 1017  1017  364856 Aug 19  1995 pcktwtch.gif
   -r--r--r--  1 1017  1017     580 Aug 19  1995 pcktwtch.txt
   -r--r--r--  1 1017  1017  590679 Jan 29  1996 pcktwtch.zip
   -r--r--r--  1 1017  1017     417 Sep 30  1994 pclock.txt
   -r--r--r--  1 1017  1017  213426 Sep 30  1994 plntscap.gif
   -r--r--r--  1 1017  1017    2558 Sep 30  1994 plntscap.txt
   -r--r--r--  1 1017  1017  125648 Oct 13  1995 springeq.jpg
   -r--r--r--  1 1017  1017    1129 Oct 13  1995 springeq.txt
   -r--r--r--  1 1017  1017  239594 Sep 30  1994 studying.jpg
   -r--r--r--  1 1017  1017  244179 Oct 13  1995 subrace.jpg
   -r--r--r--  1 1017  1017    2681 Oct 13  1995 subrace.txt
   -r--r--r--  1 1017  1017  191332 Sep 30  1994 sundae.gif
   -r--r--r--  1 1017  1017  162140 Sep 30  1994 woild2.gif
   -r--r--r--  1 povray  vuser     80 Jul 20 01:47 .message
   drwxr-xr-x  2 povray  vuser    512 Dec 16 03:53 Amiga
   dr-xr-xr-x  2 povray  vuser    512 Aug 24 10:31 Docs
   lr-xr-xr-x  1 povray  vuser     11 Aug 24 11:14 HEADER -> ../.message
   dr-xr-xr-x  2 povray  vuser    512 Aug 24 10:31 Linux
   dr-xr-xr-x  2 povray  vuser    512 Aug 24 10:31 MS-Dos
   dr-xr-xr-x  2 povray  vuser    512 Aug 24 10:36 Macintosh
   -r--r--r--  1 povray  vuser     83 Jul 20 01:48 README
   -r--r--r--  1 povray  vuser    222 Feb  6  1997 README.HTML-DOCS
   dr-xr-xr-x  2 povray  vuser    512 Aug 24 10:31 SunOS
   dr-xr-xr-x  2 povray  vuser    512 Aug 24 10:32 Unix
   dr-xr-xr-x  3 povray  vuser    512 Aug 24 10:32 Windows
   -r--r--r--  1 povray  vuser  15055 Jul 19  1996 gamma.gif
   -r--r--r--  1 povray  vuser   1776 Jul 19  1996 gamma.gif.txt
   -r--r--r--  1 povray  vuser   3735 Feb  6  1997 news.3.01.txt
   -r--r--r--  1 povray  vuser  18452 Feb  5  1997 povlegal.doc
   -r--r--r--  1 povray  vuser  24060 Feb  1  1997 povwhere.get
   -r--r--r--  1 povray  vuser    110 Aug 24 11:01 www.html
   -r--r--r--  1 1017  1017      413 Feb  7  1997 README
   -r--r--r--  1 1017  1017   286517 Feb  7  1997 povdoc.zip
   -r--r--r--  1 1017  1017   764628 Feb  7  1997 povdocps.zip
   -r--r--r--  1 1017  1017  1601733 Feb  7  1997 povhtml.zip
   -r--r--r--  1 1017  1017    18452 Feb  7  1997 povlegal.doc
   -r--r--r--  1 1017  1017    24060 Feb  2  1997 povwhere.get
 pub/povray/Official-3.0/Linux * * * * *
   -r--r--r--  1 povray  vuser      786 Jul 20 01:41 00_index.txt
   -r--r--r--  1 povray  vuser      442 Jul 20 01:42 README
   -r--r--r--  1 povray  vuser  1506794 Feb  2  1997 povdoc.html.tgz
   -r--r--r--  1 povray  vuser   908752 Aug  1  1996 povdoc.ps.gz
   -r--r--r--  1 povray  vuser  1678592 Jul 18 13:02 povlinux.tgz

Linux users will be specially interested in two directories: 'pub/povray/Official-3.0/Linux' and 'pub/povray/Hall-Of-Fame'  In latter we will find what we can not find in the great Povray handbook: Examples.

The Povray handbook is really good but an image is better than thousand words. First the handbook is not illustrated in the proper way. And second in the other directory we can find several images that are an ideal complement for the handbook. I'm not saying that the handbook hasn't got enough examples, on the contrary it shows many. Every example explains a concept, and it is all right to acquire technical knowledge. Some handbook's examples are very beautiful, but 'Hall-Of-Fame' contains a selection of the best images ever created: a real Computer Science gallery of images. Every picture has attached a text explaining the tools and techniques used to obtain the incredible result.

We have to be aware that many of the tools mentioned (in the handbook) as modellers, filters, etc. as a general rule are not available for Linux yet.

We advise to download  ftp.povray.org/pub/povray/Official-3.0/Linux and also ftp.povray.org/pub/povray/Hall-Of-Fame  not only to enjoy the pictures, but as an important starting point for your design.

We will describe how to execute a typical installation (it should work in every Linux version, but it has been only completely tested with Debian).

Installing Povray

As usualy during installations, we have to log in as super user (root).
Let us assume that we have the distribution in the directory: "/incoming/pub/povray/Official-3.0/Linux"   
Then type in the following commands  
        # mkdir /usr/local/sbin 
        # mkdir /usr/local/apli 
        # mkdir /usr/local/apli/povray 
        # cp "/incoming/pub/povray/Official-3.0/Linux" /usr/local/povray 
        # cd /usr/local/povray 
        # tar -xzf povlinux.tgz 
        # tar -xzf povdoc.html.tgz 
        # cd /usr/local/sbin 
        # ln -s /usr/local/apli/povray/povray3/x-povray x-povray 
        # ln -s /usr/local/apli/povray/povray3/s-povray s-povray 
The last sequence of commands installed everything: there is nothing to be compiled.
You only have to check if the execution permissions are set for everybody in every directory in /usr/local/apli/povray/povray3 and for the x-povray and s-povray executables. 
In our case, we needed to change these permissions with 'chmod 755 (directory or file)'.   


The Povray setup process is useful to make the "include" files and library accessible, to configure the graphic card, to define input and output file formats and many other features.

Instead of explaining questions that are very well detailed in the handbook (Quick start), we will consider a generic configuration that will allow Linux users to use Povray in an easy, comfortable and immediate way.

Povray can display in SVGA mode but this is a card-dependent issue. We will consider that you have an installation with Xwindows and you are using 'xv' to display images.

The Linux configuration in the newer versions of povray can be simplified. It is possible to use environment variables, but it is more practical to create a config file *.ini with all you need.

There are several *.ini sample files for general purposes. This provides several possibilities to set up the configuration. It is possible to refer to our default configuration file in a environment file, or to use variables to locate the default include library, etc.. It also could be a good idea to pass as arguments a number of options, but we pass almost everything in a configuration file (*.ini) that at the same time we will specify as an argument on the command line. If you do not like this method, check out the handbook and you will see that there are several options to obtain the same result, however it is not a question for an introductory article to detail each option, but only the most useful.

There is also a shell script for generating the images corresponding to all the examples 'allscene.sh'. 

Maybe instead of generating all the scenes with a low resolution, you would like to choose one and render it with the highest resolution.

In this case, go to the example directory and execute povray using the following 'ini' file: 

The first two lines will determine the resolution of the final image.
The command to obtain the image is:

$ s-povray ini.ini +i source.pov 

The file 'source.pov' is the name of the file that we would like to process, obtaining an image 'out.tga' that we can display with, for example, 'xv out.tga'.  

POV: a utility to work with Povray

'pov' is a shell-script for using POV-ray easily. First we will show its listing (you can download all code at the end of the article):
#  Autor: Antonio Castro Snurmacher  (1.998)
#       pov (ver 1.0)
#       Esta versión esta dedicada a su inclusión en la
#       revista LinuxFocus   (freeware)
#  Este programa puede ser utilizado, distribuido, y modificado
#  libremente pero siempre se deberá respetar la propiedad
#  intelectual de su autor. Esta cabecera debe ser conservada 
#  tal cual en todas las modificaciones. 
#  En caso de traducción deberá conservarse el texto original de
#  esta cabecera y añadirse la traducción a continuación de ella.
#  El autor renuncia a todo tipo de beneficio económico y no se hace 
#  responsable de los posibles perjuicios derivados del uso del mismo. 
#  E-mail (acastro@ctv.es)
#  Author: Antonio Castro Snurmacher  (1.998)
#       pov (ver 1.0)
#       This version has been written to be included in
#       the LinuxFocus magazine   (freeware)
#  This program can be used, distributed, and modified
#  freely but always has to respect the intellectual
#  property of the author. This header should be kept
#  untouched in every modification.
#  In case of translation the text of this header should be kept
#  and the translation will be added after it.
#  The author renounces to any kind of economic benefit
#  and he is not responsible for any damage derived from
#  the use of this script.
#  E-mail (acastro@ctv.es)
   echo "Usage: pov (project) (size=0..6) (quality=1..11)"
   echo "0) 40x30     (STD/20) No backup"
   echo "1) 80x60     (STD/10) No backup"
   echo "2) 100x75    (STD/8)  No backup"
   echo "3) 200x150   (STD/4)"
   echo "4) 266x200   (STD/3)"
   echo "5) 320x200 *"
   echo "6) 400x300   (STD/2)"
   echo "7) 640x480 *"
   echo "8) 800x600 *   (STD)"
   echo "9) 1024x768 *"
   echo "The projects should be located in the directory pointed by"
   echo "${HOMEPOV} and will use the same name for it and for"
   echo "the main source file *.pov"
   echo "(STD) is the standard resolution chosen."
   exit 1

mv ${PREFIX}.pov.8.gz ${PREFIX}.pov.9.gz 2> /dev/null
mv ${PREFIX}.pov.7.gz ${PREFIX}.pov.8.gz 2> /dev/null
mv ${PREFIX}.pov.6.gz ${PREFIX}.pov.7.gz 2> /dev/null
mv ${PREFIX}.pov.5.gz ${PREFIX}.pov.6.gz 2> /dev/null
mv ${PREFIX}.pov.4.gz ${PREFIX}.pov.5.gz 2> /dev/null
mv ${PREFIX}.pov.3 ${PREFIX}.pov.4 2> /dev/null
mv ${PREFIX}.pov.2 ${PREFIX}.pov.3 2> /dev/null
mv ${PREFIX}.pov.1 ${PREFIX}.pov.2 2> /dev/null
cp ${PREFIX}.pov   ${PREFIX}.pov.1 
gzip ${PREFIX}.pov.4 2> /dev/null

   export SAVE="yes"
   case  $1 in
      0) Width=40 ; Height=30; SAVE="no" ;;
      1) Width=80 ; Height=60  SAVE="no" ;;
      2) Width=100; Height=75  SAVE="no" ;;
      3) Width=200; Height=150;;
      4) Width=266; Height=200;;
      5) Width=320; Height=200;;
      6) Width=400 ;Height=300;;
      7) Width=640 ;Height=480;;
      8) Width=800 ;Height=600;;
      9) Width=1024;Height=768;;
      *) usage

   case $1 in
        1) ;;
        2) ;;
        3) ;;
        4) ;;
        5) ;;
        6) ;;
        7) ;;
        8) ;;
        9) ;;
        10) ;;
        11) ;;
       *) usage
   export Quality=$1

####################### main ####################
export HOMEPOV=`pwd`
export PROYECT=$1
if [ $# != 3 ]
   then usage
# This should point to the installation directory 
# of povray. Change it if needed:
export POVRAY=/usr/local/apli/povray/povray3
size $2
quality $3
if [ $SAVE = "yes" ]
   then newversion
cat <<-FIN > ${PREFIX}.ini
   Post_Scene_Command=xv ${PREFIX}.tga
#   Output_File_Type=t
## Others height performace options ##
#   Antialias_Depth=3
#   Antialias=On
#   Antialias_Threshold=0.1
#   Jitter_Amount=0.5
#   Jitter=On

# Low priority, maybe I want to do other things.
nice -20 x-povray ${PREFIX}.ini 

if [ $SAVE != "yes" ]
    then echo "Warning !! There is no backup of this version."


When we are designing, we often have to test ideas many times, and we get closer to our ideal step by step.

To simplify the execution we are going to implement a shell-script that generates a *.ini file, executes Povray tracer and after that displays the result. We assume that we are working in the directory $HOMEPOV (set to pwd=current directory in the pov script) and that the name of the main file is (project name.pov)

This script generates *.ini-files that usually are enough for most situations. It is oriented to a specific way of working, but if you prefer another, it is easy to change.

This utility backups the last changes on the source files because very often we would like to revert to a previous version; after making many changes looking for different results, often we decide to go back to a previous design path. As we mentioned above, the creative process looks like brush painting, we decide step by step how to continue.

If we execute the script with the lowest resolutions, it generates no backup copy nor new version number: low resolution is an uniteresting test. With this kind of tests, you can just get an idea on the relative positions of the objects. This is a personal way of working, very easy. If your are not familiar with Povray it will be a good starting methodology. Maybe later you would like to adapt this tool to your particular necessities.

Some of the available resolutions are the same as the standards modes of some video resolutions. Others are fractions of the 800x600 resolution. Type in 'pov' without arguments to ge a short help menu.

Create an appropriate directory structure to work with it within your $HOME directory and you will see how easy is to work from the first day. We will base our exercises in the use of this tool. However it is not necessary to use it, it will more comfortable for you.

We will begin with a simple example to check that everything works:

#include "colors.inc"
#include "textures.inc"
#include "glass.inc"

// Author: Antonio Castro

// The camera will look towards the contact point
// of both spheres

camera {
  location <0, 15, 35>
  look_at <0, 10, 0>

// Source of white light
object {
  light_source {
  <20, 100, 50>
  color White

// Sky with white clouds
object {
 sphere { <0, 0, 0> 200000}  // Great vault of heaven
// We strecht the clouds
 texture { pigment {Blue_Sky} scale <50000, 6000, 50000>} 

// Golden ball
sphere { <-10, 10, 0> 10   
    texture { Gold_Metal }

// Mirror ball
sphere { <10, 10, 0> 10  
    texture { finish {Mirror }}

// Glass ball
sphere { <0, 5, 10> 5   
    texture { T_Glass1 }

// Floor 
// It is made with a great sphere that touches the center <0,0,0>
// but it could be implemented with a plane.
sphere {<0, -1000000, 0> 1000000
// Checker texture
 pigment {checker color Red color Yellow scale 2 } 
Copy it in $HOME/pov1/sample1.pov 
If it is necessary create first the correct directory structure. Then use the 'pov' utility provided in this article, executing it from a XWindows xterminal.

$ ./pov sample1 4 9 

You should launch 'xv' to display it. When you plan to implement your own scenes, we recommend to open another 'xterm' window with the text verion of the handbook in the 'vi' for example, in read only mode to search in a fast way the keywords of the language, consulting its syntax, and some example of its use.



Download source code