Hello and welcome to a "classical" POV-Ray tutorial!

The reflective sphere over a checkered floor is mostly one of the first scenes a raytracer creates. This tutorial will show you how to do something similar with some more objects.

If you have never worked with POV-Ray before, I highly recommend that you have a look at Slime's "The Basics of POV-Ray" since otherwise you'll have problems with understanding this one.

1 Let's start right off. Open your POV-Ray with a new document. First we are adding the basic 2 lines which are necessary in nearly every pov-file:

	camera { location <10, 5, 10> look_at 0 }

	light_source{ <1000, 1000, 0> 1 }

Then we need a ground of course, so let's go with a nice plane:

	plane { y, 0
		pigment { rgb 0.5 }
	}

Note, what this does:
The y signifies the normal-vector of the plane itself. y stands for <0,1,0>. In 3D there are several ways to specify a plane. One is through 3 points, one is through a normal-vector. The next parameter specifies the distance where the plane cuts the y-axis. In our case it's 0, which means exactly in the center of our coordinate-system. You know already that pigment {rgb 0.5} gives the plane a mid-gray color. If you render it out, you should get something like this:

Our first image

2 Actually kinda boring, so we wanna add something more spectacular.
Replace the pigment of the plane with this:

	plane { y, 0
		pigment { checker rgb <0.9, 0.5, 0.4> rgb <0.9, 0.9, 1.0> scale 5 }
	}

Then render and look what happened:

With checkers

The checker gives the object a pattern which looks like a chessboard. It is followed by two color values which set the two colors of the squares. The scale 5 is just added to make the squares a 5 times bigger. By default they have a size of 1x1.
Go, try playing around with the two colors and the scale a bit!

3 Now that we have our nice ground plane with our preferred colors and size we should finish this thing up a bit to let it look more realistic. Therefore we can use the finish modifier of the object. Let's look at the code first:

	plane { y, 0
		pigment { checker rgb <0.9, 0.5, 0.4> rgb <0.9, 0.9, 1.0> scale 5 }
		finish { reflection 0.5 ambient 0.4 }
	}

Render it out and you will see it is getting a bit brighter. That's because the ambient keyword makes the object to "take" more light. Also its reflection is increased but we dont recognize this now, since there is nothing to be reflected yet.

With reflection and ambient

4 For the sky we can use the sky_sphere object which simulates a giant hollow sphere around us. Let's look at the code:

	sky_sphere {
		pigment { rgb <0.4, 0.4, 0.9> }
	}

Blue sky

Render it out and we will see a nice afternoon-blue sky. Nice but boring. Realistic sky isn't always the same color. Due to absorption in the atmosphere, the color gets lighter to the horizon:

	sky_sphere {
		pigment { gradient y
			color_map {
				[0 rgb <0.5, 0.6, 1.0> ]
				[1 rgb <0.0, 0.0, 1.0> ]
			}
		}
	}

(You may position the camera a bit upwards if you wanna see more of the sky. I choose look_at <0, 7, 0>.)

Blue gradient sky

Here we used a color_map which is aligned along the y-axis. We determine that by using the gradient y. A color_map always runs from 0 to 1. In our case we give the point at zero a light blue and the point at 1 a dark, full blue.
You can of course add other points in this gradient. For example if you want to go the gradient from light blue over green to dark blue, you would have to add [0.5 rgb <0,1,0> ] between the 0 and the 1.

5 What we wanna do next, is to add clouds. This is kinda complicated. Let's add another pigment modifier to the sphere so that it looks like this:

	sky_sphere {
		pigment { gradient y
			color_map {
				[0 rgb <0.5, 0.6, 1> ]
				[1 rgb <0, 0, 1> ]
			}
		}
		pigment { wrinkles turbulence 0.7
			color_map {
				[0 rgbt <1,1,1,1>]
				[0.5 rgbt <0.98, 0.99, 0.99, .6>]
				[1 rgbt <1, 1, 1, 1>]
			}
			scale <.8, .1, .8>
		}
	}

Clouds

The wrinkles give the whole pigment a noise and the turbulence attribute sets the value of how intense that noise is. Then again we have a color_map over the whole pigment but this time we use the rgbt (rgbTransparent) colors. If the t value is 0 we have 0% of transparency, at 1 we have 100%. So in our case the only interesting part is the color at 0.5 where we give it a gray that is very close to white and a 60% transparency. If you render this out, you'll see that the clouds absolutely don't fit on the sky, that's why we have to add the scale modifier.

6 You'll notice that the scene still looks unnatural since we can see the infinite distance where the clouds actually touches the horizon. The best attempt to avoid this in POV-Ray is the fog:

	fog {
		distance 500
		color rgb 0.9
		fog_offset 10
		fog_alt 5
		fog_type 2
	}

When we add this to our scene we get a nice fog or dust on the horizon. As you may already guess distance specifies the distance where our fog starts and color sets its colors. The most natural fog would be a bright gray, so i took 0.9 (rgb <0.9,0.9,0.9>) but you can play around with other colors too to get a surrealistic scene. fog_offset specifies how high the fog is. In our case it is 10 units heigh and then the fog_alt specifies how fast the fog density goes to zero. Two would mean, that at an altitude at 10+2=12 the density is 25%. Finally make sure, you have fog_type set two 2 which is the horizon-like fog we use. Check the POV-Ray helpfile for more information on fog.

Fog

7 Ok, from here on it depends on what you want in your scene. In this tute, i won't add much, just enough that you understand the concepts of the objects. We'll try to make some kind of table and an abstract object on it. Let's start with the feet of the table:

	#declare myTorus = torus { 1.0, 0.5 finish { phong 0.5  phong_size 1.0 } }

	object { myTorus translate < 4.0, 0.5, -4.0> }
	object { myTorus translate <-4.0, 0.5, -4.0> }
	object { myTorus translate < 4.0, 0.5,  4.0> }
	object { myTorus translate <-4.0, 0.5,  4.0> }

Render this out and you see 4 tori which are placed in quadratical edges. (Check if you have the camera set back to look_at 0.) How did this happen? The #declare lets us make our own object like some kind of variable. In this case our object's name is myTorus and it is defined with a major radius of 1 and a minor of 0.5. Notice that we gave it a phong finish to make it look like some rubber. Feel free to play around with the values to get different results.
With this code alone we won't see anything, because we have to call our mytorus object first. This is be done with the object keyword. We call it four times and apply a different translate every time so that we place our object in four different places. (With translate an object can be set somewhere in our system by using relative coordinates.) The torus object is in <0,0,0> by default. Check the POV-Ray helpfile for more information about it.

Rubber

8 Next we are going to lay something on our tori-feet:

	#include "textures.inc"

	box { <5.0, 1.1, 5.0> <-5.0, 1.2, -5.0> texture { New_Penny } }

You'll already guess what this does. A box is defined by two points only which are the very opposite. Then we apply a texture called New_Penny to it. To access this we have to include the file where it is defined. This is done by the #include "textures.inc".

nice, a box!

Looks cool already. So finally we wanna add an abstract object on our table. Again we use #declare to combine several objects.

	#declare myObject = union {
		sphere { <0, 0, 0>, 2
			texture { Bright_Bronze
				pigment { rgb <1, 0, 0> }
			}
		}

		cylinder { <0,0,4>, <0,0,-4>, 0.5
			texture { Soft_Silver }
		}
		cylinder { <0,0,4>, <0,0,-4>, 0.5
			texture { Soft_Silver }
			rotate y*90
		}
	}

	object { myObject  rotate <10,0,5> translate y*3 }

9 Ok, here we make an object called myObject that are three combined basic objects. We can combine them using the union { }. Inside we have a sphere with radius 2 and a Chrome texture which we load from the textures.inc again. Then we give the sphere a color (red) to make it look a bit extraordinary.
Then we add two cylinders which go through the sphere. A cylinder is defined by a starting point, an ending point and a radius. Finally we give it a texture like the sphere, let's say Soft_Silver. You can check out the textures.inc or other include files for more cool textures.

Finished!

Cool! Ey? Ya can download the sourcecode here: abstract.pov
Now play around a little bit. Change camera position, colors, textures. Some examples:

variant     variant     variant

Have a lot of fun!
© 2003 Matthias Grumet | embege.com