## The Codesmith's Library

### 3D Computer Graphics

Written by Carsten Whimster

## 3D Computer Graphics

At one point, I needed a book on 3D computer graphics, but found the Foley/van Dam book too expensive and too raw, so I looked around, and ended up finding this book. Here are the chapters:

```
1.  Three-dimensional Geometry in Computer Graphics
2.  Representation of Objects
3.  Viewing Systems
4.  Reflection and Illumination Models
5.  Rendering Algorithms
6.  Parametric Representation and Practice
8.  Raytracing
9.  Volume Rendering
11. Anti-Aliasing
12. Functionally Based Modelling Methods
13. Three-dimensional Computer Animation
14. Colour Spaces and Monitor Considerations
A.  Viewing Transformations for a Simple Four-parameter Viewing System
B.  A Wireframe System
C.  An Implementation of a Renderer
D.  The Utah Teapot
References
Index
```

The book jumps right into things in chapter one. Transformations are among the most basic of topics in the 3D world, yet this hurdle must be crossed before a good understanding of rendering from 3D models can be reached. Affine transformations don't seem to make too much sense until you start seeing how they work, and as importantly, why the matrices are 4x4 instead of 3x3. Coordinate systems, rotations, translations, scaling, structure-deforming tranformations, and a brief intro to vectors make up this first chapter.

One of the more valuable aspects of this book is also one of the more frustrating aspects. The exercises are anything but trivial. The very first question is as follows: "Implement a program (see Appendix B) that enables a user to set up a scene that consists of a number of objects which are viewed (using viewing system I, Chapter 3) in wireframe mode."

This pace is both good and bad. It is good because it presumes a certain level of motivation and maturity, and it is bad because to do the first exercise in chapter 1, you have to read chapter 3 and appendix A, and even then there will be some loose ends. If you are planning to do the exercises, set aside some time. Nonetheless, there is some good pseudocode in the book, both in the text, and in the appendices. One of the source code examples is a renderer!

From this auspicious start, we move along at a rapid pace. Why so fast? Well, if you consider that Foley/van Dam (Computer Graphics, Principles and Practice, 2nd Edition, Foley, van Dam, Hughes, Feiner) is twice as thick, and teaches things less clearly (it is really more of a reference,) you start to get the sense of how much material there is to cover. This book does not have the depth of that other book, the bible for graphics programmers, but I pity anyone who has to learn graphics from scratch using only Foley/van Dam. If you visit Foley/van Dam at Amazon, you will see that it got 4 1/2 of 5 stars. Then you notice that people who bought that book sometimes bought this one (enough to place it at the top of the "other books bought" list), and visiting this book you will find that it got 5/5 stars.

Anyway, in spite of the rapid pace, the material is very clearly presented, formulas are kept to a necessary minumum, and there are mostly lots of examples and diagrams to explain key concepts. Object representation (polygons, patches, csg representation, octrees, a quick intro to bsp trees) and a brief introduction to rendering the various shapes is the second chapter. The first project in this chapter asks you to implement some object by volume sweeping :)

The confusing topic of viewing systems, and why we so often have model coordinates, global coordinates, viewing coordinates, and screen coordinates (and sometimes device coordinates,) is next on the agenda. The conepts are taught brilliantly in stages. The first viewing system is so limited as to be of use only to severely restricted instances, but has enough functionality to explain a few key concepts, such as perspective projection and the view plane. The last viewing system is like PHIGS, ie. highly complex (too much so?) yet very functional, but because the concepts were introduced gradually, by the time you reach the final viewing system, you should be able to grasp it, if not completely understand it.

Reflection and illumination are taught in depth, both with the normal simplifications (the Phong model, a-la OpenGL,) and also with less constraints (BRDFs and the Cook and Torrance model, among others.) The sample code in this chapter is excellent, if possibly somewhat unoptimized. The clarity it imparts is worth the price in performance though, as optimized code can be very hard to understand.

But rendering is not all there is to rendering... clipping, culling, incremental shading, Gouraud shading, Phong interpolation, rasterization, Z-buffer, CSG again, and the scanline algorithms are all part of the equation too. This chapter is followed by Bezier patches and splines of various types. I must say that with some work I was able to grasp most of the material in this chapter, but I found that some more examples around non-uniform B-splines would have been welcome. There are lots of diagrams and a few formulas, but I couldn't quite piece it together from the presented material. No matter, I am on my way out to pick up a copy of the killer B-s today, so that should soon be rectified. I noticed that the bookstore had two or three copies of this hard-to-find book the other day. I hope they are still there. NURBS and ß-splines wrap up the presentation of parametric surfaces.

From there we move back into more rendering-oriented tasks, with shadows and textures, including both texture-mapping, and procedural (3D) textures. Bump mapping, anti-aliasing and other related topics are covered, before we move on to ray tracing. This chapter is the original reason I bought the book, and it is nice and clear. A (relatively) full description of the history of raytracing and the limitations of raytracing is included, topics which are often missed by zealots. Some efficiency and quality issues are also touched on, but for more depth, Watt's next book, Advanced Animation and Rendering Techniques, Theory and Practice is probably needed. A review of this second book will follow at some point.

Volume rendering, a topic about which I know next to nothing, save the most cursory of knowledge about the marching cubes algorithm, is next. This subtopic is covered, as well as voxels, but overall this chapter seems more of an introduction than a tutorial. A touch more depth here might be in order.

Radiosity, that CMU invention, is now presented. The first (and second and third...) time I read this chapter, I thought: "Where is the pesudocode? This chapter is incomplete." Eventually, I re-read it with a clear mind, and lo and behold, the pseudocode is not actually strictly necessary. I think it might clarify some things a touch, but there is enough information in here to go off and design a radiosity engine, albeit a simple one. Aliasing theory follows this chapter, and is in turn followed by what the author terms "functionally based modelling." What is this, you might ask. Well, it is a large-ish but ill-defined field that deals with the generation of such features as waves, plants, and random non-uniformity in other places. Fractals are one approach, statistical noise is another. the chapter is short, but interesting. More detail?

Animation. A topic which could easily take up another book of the same size is now presented. By necessity it must be somewhat curt, but it does manage to cover key-framing and parametric approaches, as well as touch on the crucial topic of anti-aliasing. A brief intro to colour theory wraps things up.

One thing that this book does not cover, which is not strictly speaking a graphics topic, but which is crucial to the whole field of the implementation of graphics, is the topic of data structures and the algorithms needed to access them. Some kind of combination hash table/tree is what we used as an object/scene database in the course I took, and I personally added some twists to this, but I would have enjoyed a more in-depth discussion of the underlying structure to support a rendering engine. When a raytracer looks at a sphere in some scene hierarchy 100,000 times during the render of a picture, it pays off to have it stored in an efficient data structure. When the sphere is changed to a parametric patch, it becomes absolutely crucial. This is a must-have addition to the 3rd edition of this book, ideally in a separate chapter, perhaps a new chapter 3 or 4.

## Summary

This is a really good book. Focusing on teaching 3D computer graphics to neophytes, it nonetheless expects a reasonable level of math sophistication. I find that it keeps a good balance, but then I am taking math in university. If you expect to learn from a book like this, you will need to be sharp and reasonably well versed with linear algebra, and a little bit of general math and statistics. If you meet these requirements, this book is a great way to get into 3D graphics programming, certainly easier to learn from than the ubiquitous Foley/van Dam book, although obviously with less depth (but greater clarity.) I would have liked to see a touch more detail in places (splines and radiosity in particular), with more hands-on examples, but I recognize that this is a hard balance to strike. I want to give this book a perfect score, but based on the few hard-to-follow areas in the book, and they are indeed few, I leave room for improvement in the next edition.

I give it a well-deserved 9/10.

3D Computer Graphics, Watt

• Addison-Wesley, ISBN 0-201-63186-5, (price unmarked)
• Intended audience: Beginning/Intermediate 3D Graphics Programmers
• Mark: 9/10

## Reviewed Books

Our Bookstore has reviews and links to Amazon for all books we have reviewed in the past, as well as several books waiting to be reviewed, and others which we recommend.