The help files included with PovRay provide an excellent resource and can even be used for training if you spend time doing the examples. However, this tutorial is meant to provide you with a quick startup and an example of what is possible with this program.
Setting Up PovRay
Head to http://www.povray.org and click on the download button on the left. Find your operating system and download the appropriate binary. Install that file and you're ready to roll.
Your First Render
There are three important parts to any scene:
1) Include files
2) The camera
3) One or more light sources
4) The objects to render
We'll study each individually.
1. Include files
If you set up a big render file, you will most likely make use of a lot of the PovRay include files as well as a few of your own. The PovRay files are a great resource to look through. For our purposes we'll only use the one that defines some standard colors:
#include "colors.inc" |
2. The camera
The camera is capable of a lot of special features such as widescreen, fisheye, panoramic, etc. Once again, we'll stick to the basics. There are two main elements to a camera. They are the "location" point and the "look_at" point. A camera positioned at x=10, y=5, z=9 and pointed at x=0,y=0,z=0 would look like this:
camera {
location <10,5,9>
look_at <0,0,0>
}
|
3. One or more light sources
Light sources can be complicated. You can place them inside translucent objects, change the color of the light, make the light appear like a laser, etc. To light our object, we'll place one at the spot x=0, y=8, z=8.
light_source {
<0,8,8>
color White
}
|
4. The objects to render
This is where it gets really interesting. Here you are limited only by your imagination (or knowledge of PovRay!) We will create a box and a spehere on a reflective floor with a white background.
The background is easy so we'll start with that.
background { White }
|
To create the reflective floor, we simply define a plane and give it some properties.
plane {
y, 0 // the y vector is normal to the plane at a height of 0
pigment { Gray }
finish {
reflection .3 // 1 is high reflection, 0 is no reflection
metallic
}
}
|
Now we'll make a red box that sits one unit above the floor. This will give us a reflection in our floor and also a shadow from the light source.
box {
<0,1,0> // bottom left coordinate
<2,3,2> // top right coordinate
pigment { Red }
}
|
And now for the sphere...
sphere {
<4,2,0> // center of sphere
1 // radius
pigment { Yellow }
}
|
Rendering the Scene
I will include directions here for the Windows version, but the other versions should be similar. The first thing to do is choose the resolution to render at. There is a dropdown box in the upper left corner of the window. Each of the resolutions has two choices, one says "No AA" and the other says "AA 0.3". AA stands for anti-aliasing. It takes more time to render this way with the anti-aliasing turned on but you'll get better looking pictures.
Now that you've chosen your resolution, click the Run button on the toolbar. The code gets parsed by PovRay and then a new window appears as your scene is rendered. If you click on the Messages tab you can see some interesting output about your file.
Conclusion
That's a very brief overview. I encourage you to dig into the documentation and start trying things out. It can be intimidating at first but this tutorial should get you off your feet.
This code was accepted as a tutorial on Devhood!
Disclaimer:
By installing this software, you assume complete responsibility for any
damage that may occur to your system or your oldest child. I assume no
liability. Besides, if you tried to sue me you wouldn't get much.
May cause cancer in pregnant
lab rats on rainy days in Arkansas. Violators will be persecuted. Do not
pass Go, do not collect $200, go directly to jail. An apple a day keeps the
doctor away. Caffeine-free (although I am probably not). Look both ways
before crossing the road. Don't put that quarter in your mouth, you don't
know where it's been. Do not use in areas of high radiation. Do not use
while being chased by a rabid African tiger (a healthy one maybe, but not a
rabid one). I am not responsible for any lost or stolen brain cells. And
last, but not least, have fun!