All About Lighting

by Ga'ash Soffer on December 26, 1998 7:57 PM EST

Gouraud Shading

Gouraud Shading is used in virtually all single pass rendering engines. Its simplicity, speed, and flexibility make it perhaps the only type of lighting directly appliable by hardware 3D accelerators. The only problem with Gouraud shading is that it's, well, very fake.

gouraud.jpg (9592 bytes)

As you can see from the shot above, Gouraud Shading (which can be used as lighting) isn't very pretty. Since the texture is supposed to be a shiny metal, you would expect the light to reflect off of the metal. Also, chances are you would expect a "highlight" (bright spot) in the middle of the scene above. [Textures used are from Planet Half-life's Texture Studio Pak]


Why is Gouraud Shading so fast, yet so ugly? Well, the algorithm for Gouraud Shading will explain. Gouraud Shading calculates an intensity at each vertex of a polygon, and then LINEARLY interpolates the intensities along polygon edges and across polygon rows. When it comes to lighting, chances are if you see the world linear, it is an approximation. While Gouraud Shading looks good for lit polygons viewed at an angle. Polygons straight in front of the light source are generally shaded w/the same color throughout, since the intensities are about the same at each vertex. (In reality, the center should be brighter, since the angle between the light source and the center of the polygon (assuming polygon is straight in front of the light) is much smaller (well, small depends on how you look at it). You can also used the intensity formula to see that in the middle of the polygon, the intensity is greater (intensity at a point = Light Intensity / (distance from light source)^2 ). The Math is below:

gouraud2.gif (1929 bytes)

Not only does Gouraud not shade correctly for most cases (actually all cases, but polygons viewed from the side are relatively accurate, or, at least look good), Gouraud shading produces an intensity warp, since the intensities are LINEARLY interpolated, they do NOT take into account the 3D properties of the polygon. This leads to "warping" as seen in linear (sometimes called affine) texture mapping, though not as noticeable. "Perspective correct" Gouraud shading detracts from Gouraud shading's main advantage over other lighting methods, speed, so it is generally not used (maybe hardware does this, not sure).

The Highlight
Comments Locked


View All Comments

Log in

Don't have an account? Sign up now