RENDERMAN VS. REAL TIME

RENDERMAN VS. REAL TIME

RenderMan is a continually evolving product, but it's never been one that could be considered real time. A good reason for this is the flexibility needed by the artists. In 1989, there was no hardware that could render a complex ray-traced scene in real time. You can think of ray tracing as tracing each pixel through a scene—through transparent and translucent objects—back to the location where the pixel is saturated. This works nicely for scenes that have lots of complex behavior, such as scenes with reflecting surfaces, water, shadows, glass, smoke, etc. And while that is the direction 3D consumer graphics is heading, we're not quite there yet.

In the consumer 3D graphics arena, we're dealing with objects that reflect light, and we can deal with objects that are some degree of transparent. But there's no support for the effect of other objects in a scene. There's support for the concept of "lights," but a "light" in OpenGL or Direct3D is just a source of light, not an object itself. An object only "knows" about the lights in a scene, but not if it's occluded from these lights by anything else in a scene.

WHAT YOU'LL LEARN FROM THIS BOOK

This book is intended for someone familiar with 3D graphics who wants a better understanding about just how some math can turn a bunch of data into a photorealistic scene. This book not only covers the basics of setting up and using vertex and pixel shaders, it also discusses in depth the very equations (and simplifications) that were used in the default graphics pipeline. You'll learn what the basic equations are for lighting and shading, what the standards are, and most important, how to toss them out and program your own.

The emphasis is on giving you the knowledge to understand the equations that are used in lighting and shading, what the alternatives are, and how you can write your own. The equations are discussed in detail, and a shader editing tool from ATI called RenderMonkey is included. RenderMonkey is a powerful tool with an easy to use interface with which you can dynamically edit vertex and pixel shaders and their parameters in real time and see the changes upon a variety of objects. Not only will you understand the differences between the standard Blinn-Phong lighting equations and others like Torrance-Sparrow and Oren-Nayar, but you'll learn how to make real-time shaders that implement these models. Anisotropic lighting, cartoon shading, Fresnel effects; it's all covered in this book.

Chapter 2: Preliminary Math

OVERVIEW

I'm very well acquainted too with matters mathematical, I understand equations, both the simple and quadratical. About binomial theorem I'm teeming with a lot of news—With many cheerful facts about the square of the hypotenuse.

--Gilbert and Sullivan, The Pirates of Penzance

Well, there's no getting around it. If you want to really understand shader programming and be able to program some wicked shaders, you have to have a firm understanding of the basic math required for 3D graphics and how it ties together. Understanding the math is a prerequisite for setting up shaders. If you're a programmer, you really should have a good grasp on the mathematics involved in taking a vertex from a file and getting it rendered as pixels on the screen. If you're an artist, you might be able to slide on some of the math, but to fully use a shading language requires knowing what data is coming through in a particular coordinate system and knowing how to change it as needed. Expertise lies in knowing how to shift data from one range to another, how to maintain as much precision as possible, and how to spoof the system to do what you want it to do.

If you've already programmed your own 3D rendering engine, have written a tri-stripping routine, know what a projection matrix is, and understand the usefulness of negative color values, then you can probably skip this section. However, if you feel that a quick and painless refresher on the basics of useful 3D math, terminology, and the mathematics of color would be useful, read on!