to your scene file to get your first complete POV-Ray scene file as shown below.
The vector in the light_source statement specifies the location of the light as 2 units to our right, 4 units above the origin and 3 units back from the origin. The light source is invisible, it only casts light, so no texture is needed.
That's it! Close the file and render a small picture of it using the command
If your computer does not use the command line, see your platform specific docs for the correct command to render a scene.
You may also set any other command line options you like. The scene is written to the image file demo.tga (or some suffix other than .tga if your computer uses a different default file format).
The scene you just traced isn't quite state of the art but we'll have to start with the basics before we soon get to much more fascinating features and scenes.
In this example you can see that a box is defined by specifying the 3D coordinates of its opposite corners. The first vector must be the minimum x, y, z coordinates and the 2nd vector must be the maximum x, y, z values. Box objects can only be defined parallel to the axes of the world coordinate system. You can later rotate them to any angle. Note that you can perform simple math on values and vectors. In the rotate parameter we multiplied the vector identifier y by 20. This is the same as <0,1,0>*20 or <0,20,0>.
The cone shape is defined by the center and radius of each end. In this example one end is at location <0,1,0> and has radius of 0.3 while the other end is centered at <1,2,3> with radius=1. If you want the cone to come to a sharp point then use radius=0. The solid end caps are parallel to each other and perpendicular to the cone axis. If you want an open cone with no end caps then add the keyword open after the 2nd radius like this:
The object defined here is an infinite plane. The vector <0,1,0> is the surface normal of the plane (i.e. if you were standing on the surface, the normal points straight up). The number afterward is the distance that the plane is displaced along the normal from the origin - in this case, the floor is placed at y=-1 so that the sphere at y=1, radius=2, is resting on it.
Notice that there is no texture {... } statement. There really is an implied texture there. You might find that continually typing statements that are nested like texture {pigment {... }} can get to be a tiresome so POV-Ray lets you leave out the texture {... } under many circumstances. In general you only need the texture block surrounding a texture identifier (like the T_Stone25 example above), or when creating layered textures (which are covered later).
This pigment uses the checker color pattern and specifies that the two colors red and blue should be used.
Because the vectors <1,0,0>, <0,1,0> and <0,0,1> are used frequently, POV-Ray has three built-in vector identifiers x , y , and z respectively that can be used as a shorthand. Thus the plane could be defined as:
Note that you do not use angle brackets around vector identifiers.
Looking at the floor, you'll notice that the ball casts a shadow on the floor. Shadows are calculated very accurately by the ray-tracer, which creates precise, sharp shadows. In the real world, penumbral or "soft" shadows are often seen. Later you'll learn how to use extended light sources to soften the shadows.
You should be aware that the shapes described below are not trivial to understand. Don't worry if you do not know how to use them or how they work. Just try the examples and play with the features described in the reference chapter. There is nothing better than learning by doing.
Bezier patches are actually very useful and, with a little practice, some pretty amazing things can be created with them. For our first tutorial, let's make a sort of a teepee/tent shape using a single sheet patch.
First, start moray and, from the main edit screen, click on "CREATE". Name your object Teepee . The "CREATE BEZIER PATCH" dialogue box will appear. Make sure that "SHEET" is depressed. Click on "OK, CREATE". At the bottom of the main edit screen, click on "EXTENDED EDIT".
Hold the cursor over the "TOP" view and right click to make the pop-up menu appear. Click on "MAXIMIZE". [ALT]-drag to zoom in a little. Click on "MARK ALL", and under the transformation mode box, "UFRM SCL". Drag the mouse to scale the patch until it is approximately four units wide. Click on "TRANSLATE", and move the patch so that its center is over the origin. Right click - "MINIMIZE", "UNMARK ALL".
[SHIFT]-drag a box around the lower right control point to mark it. [ALT]-zoom into the "FRONT" view so that you can see the patch better. In the "FRONT" view, "TRANSLATE" that point 10 units along the negative z-axis (note that in MORAY z is up). "UNMARK ALL". Repeat this procedure for each of the other three corner points. Make sure you remember to "UNMARK ALL" once each point has been translated. You should have a shape that looks as though it is standing on four pointed legs. "UNMARK ALL".
Working once again in the "TOP" view, [SHIFT]-drag a box around the four center control points to mark them. Right-click over the "TOP" view, "MAXIMIZE". Click on "UFRM SCL" and drag the mouse to scale the four points close together. [ALT]-drag to zoom closer and get them as close together as you can. [ALT]-drag to zoom out, right click, "MINIMIZE".
In the "FRONT" view, "TRANSLATE" the marked points 10 units along the positive z-axis. "UNMARK ALL". The resulting shape is quite interesting, was simple to model, and could not be produced using CSG primitives. Now let's use it in a scene.
Click on "DONE" to return to the main edit screen. Notice that U_STEPS and V_STEPS are both set to 3 and flatness is set to 0.01. Leave them alone for now. Click on "FILES", and then "SAVE SEL" (save selection). Name your new file teepee1.mdl . Press [F3] and open teepee1.mdl . There is no need to save the original file. When teepee1 is open, create a quick "dummy" texture ( moray will not allow you to export data without a texture), say, white with default finish, name it TeePeeTex , and apply it to the object. Save the file and press [CTRL-F9]. moray will create two files: teepee1.inc and teepee1.pov .
Exit moray and copy teepee1.inc and teepee1.pov into your working directory where you are doing these tutorials. Create a new file called bezdemo.pov and edit it as follows:
Using a text editor, create and declare a simple texture for your teepee object:
Now, paste in the bezier patch data from teepee1.pov (the additional object keywords added by moray were removed):
Add the above rotations so that the patch is oriented to POV's left-handed coordinate system (remember the patch was made in moray in a right handed coordinate system) and so we can see all four legs. Rendering this at 200x150 -a we see pretty much what we expect, a white teepee over a green and yellow checkered plane. Let's take a little closer look. Render it again, this time at 320x200.
Now we see that something is amiss. There appears to be sharp angling, almost like faceting, especially near the top. This is indeed a kind of faceting and is due to the U_STEPS and V_STEPS parameters. Let's change these from 3 to 4 and see what happens.
That's much better, but it took a little longer to render. This is an unavoidable tradeoff. If you want even finer detail, use a U_STEPS and V_STEPS value of 5 and set flatness to 0. But expect to use lots of memory and an even longer tracing time.
Well, we can't just leave this scene without adding a few items just for interest. Declare the patch object and scatter a few of them around the scene:
That looks good. Let's do something about that boring gray background. Delete the background declaration and replace it with:
This adds a pleasing cirrus-cloud filled sky. Now, let's change the checkered plane to rippled sand dunes:
Render this at 320x240 -a. Not bad! Let's just add one more element. Let's place a golden egg under each of the teepees. And since this is a bezier patch tutorial, let's make the eggs out of bezier patches.
Return to moray and create another bezier patch. Name it Egg1 and select "CYLINDRICAL 2 - PATCH" from the "CREATE BEZIER PATCH" dialogue box. Click on "EXTENDED EDIT". "MARK ALL", and rotate the patch so that the cylinder lays on its side. "UNMARK ALL". In the "FRONT" view, [SHIFT]-drag a box around the four points on the right end to mark them. In the "SIDE" view, right click, "MAXIMIZE". [ALT]-drag to zoom in a little closer. "UFRM SCL" the points together as close as possible. Zoom in closer to get them nice and tight. Zoom out, right click, "MINIMIZE".
Click on "TRANSLATE" and drag the points to the left so that they are aligned on the z-axis with the next group of four points. This should create a blunt end to the patch. Repeat this procedure for the other end. "UNMARK ALL".
In the "FRONT" view, the control grid should be a rectangle now and the patch should be an ellipsoid. [SHIFT]-drag a box around the upper right corner of the control grid to mark those points. Then [SHIFT]-drag a box around the lower right corner to mark those points as well. In the "SIDE" view, "UFRM SCL" the points apart a little to make that end of the egg a little wider than the other. "UNMARK ALL".
The egg may need a little proportional adjustment. You should be able to "MARK ALL" and "LOCAL SCL" in the three views until you get it to look like an egg. When you are satisfied that it does, "UNMARK ALL" and click on done. Learning from our teepee object, we now go ahead and change U_STEPS and V_STEPS to 4.
Create a dummy texture, white with default finish, name it EggTex , and apply it to the egg. From the FILES menu, "SAVE SEL" to filename egg1.mdl . Load this file and export ([CTRL F9]). Exit moray and copy the files egg1.inc and egg1.pov into your working directory.
Back in bezdemo.pov , create a nice, shiny gold texture:
And while we're at it, let's dandy up our TeePeeTex :
Now paste in your egg patch data and declare your egg:
Now place a copy of the egg under each teepee. This should require only the x and z coordinates of each teepee:
Render this at 320x240 -A . Everything looks good so run it again at 640x480 +A . Now we see that there is still some faceting near the top of the teepees and on the eggs as well. The only solution is to raise U_STEPS and V_STEPS from 4 to 5 and set flatness to 0 for all our bezier objects. Make the changes and render it again at 640x480 +A .
povray +w160 +h120 +p +x +d0 -v -idemo.pov
Section 4.2
Using the Camera
Section 4.2.1
Camera Types
Section 4.2.2
Using Focal Blur
Section 4.2.3
Using Camera Ray Perturbation
Section 4.3
Simple Shapes
Section 4.3.1
Box Object
Section 4.3.2
Cone Object
Section 4.3.3
Cylinder Object
Section 4.3.4
Plane Object
Section 4.3.5
Standard Include Objects
Section 4.4
Advanced Shapes
Section 4.4.1
Bicubic Patch Object
Scene build with different Bezier patches.
Table Of Contents