Rendering: What is it? Part One

I remember being told in my advanced mathematics classes two things: 1) I will never need to know any algebra for any reason in th efuture, and 2) you had better learn your algrebra because you don't know if you will need it.

I still haven't figured out which one is right.

But to learn the basics of 3D modeling and how all this raytracing and 3D to 2D mapping works, you need a little math. Trigonometry, mostly, but I won't bore you with to much math.

We start with a simple box in space. (All pictures you can click to enlarge)

«a href="http://deskmerc.com/pixors/tue0615-01.php" onclick="window.open('http://deskmerc.com/pixors/tue0615-01.php','popup','width=320,height=240,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"»«img src="http://deskmerc.com/pixors/tue0615-01-thumb.jpg" width="100" height="75" border="0" /»«/a»

This is a simple image, one "camera", a uniform light source, and a simple geometrical object, known as a "primitive". Other primitives would be things like cones, spheres, planes, circles, and what not. More complex objects can be made from primitives added to other primitives, or from triangluar patches, structures known as meshes, NURBS, and other objects. In this case, the cube is 2 x 2 x 2 arbitrary units, solid.

Now, 3D Studio Max just makes you a box, you define a camera and a light, and click "render". That's a long way from the renderers I started playing with, namely Vivid and POV. With those two, you had to write a text file that described the the environment you were working with, from light sources, camera position, where each object is located, the surface qualities of each object (such as color) even going so far as to defining whihc way is up. And all so that is done with vectors and Cartesian coordinates, like these:

«a href="http://deskmerc.com/pixors/tue0615-02.php" onclick="window.open('http://deskmerc.com/pixors/tue0615-02.php','popup','width=320,height=240,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"»«img src="http://deskmerc.com/pixors/tue0615-02-thumb.jpg" width="100" height="75" border="0" /»«/a»

You start with an arbitrary zero, (0,0,0) in an XYZ format. That's where everything in this "space" will be referenced from. You can call the "distance" between points whatever you wish, meters, inches, furlongs, whatever, it doesn't matter. You would define a camera by, say, the XYZ position (5,5,5), which places it 5 units along each axis away from the origin, and "point" it back to the origin. Using our imagination, it would look something like this:

«a href="http://deskmerc.com/pixors/tue0615-03.php" onclick="window.open('http://deskmerc.com/pixors/tue0615-03.php','popup','width=320,height=240,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"»«img src="http://deskmerc.com/pixors/tue0615-03-thumb.jpg" width="100" height="75" border="0" /»«/a»

You can see the camera location and where it points back. So far, so good. Now we need an object, in this case, our box. A basic box is actually siz square planes, and a plane would be defined like this:

polygon { points 4
vertex 0 0 0
vertex 2 0 0
vertex 0 2 0
vertex 2 2 0 }

This draws a square with the four points at those XYZ coordinates, relative to the origin. To finish the box, we would do five more just like that, all with the points at the proper places, and it would look like this in our mind's eye:

«a href="http://deskmerc.com/pixors/tue0615-04.php" onclick="window.open('http://deskmerc.com/pixors/tue0615-04.php','popup','width=320,height=240,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"»«img src="http://deskmerc.com/pixors/tue0615-04-thumb.jpg" width="100" height="75" border="0" /»«/a»

From the camera's perspective, the cube looks like this:

«a href="http://deskmerc.com/pixors/tue0615-05.php" onclick="window.open('http://deskmerc.com/pixors/tue0615-05.php','popup','width=320,height=240,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"»«img src="http://deskmerc.com/pixors/tue0615-05-thumb.jpg" width="100" height="75" border="0" /»«/a»

Later, I'll explain how the image is actually created. So far, we don't have anything but a description of an object, where it is in rleation to an absolute zero, and a point of reference we are using to "look" at the object.

(For extra credit, define the vector if we are pointing from XYZ 5,5,5 to 0,0,0)