Game Development Reference
In-Depth Information
Gouraud Shading
A slightly more complex form of shading is known as Gouraud shading . In this
type of shading, the reflection model is calculated once per each vertex. This res-
ults in a different color potentially being computed for each vertex. The rest of the
triangle is then filled by blending between the vertex colors. So, for example, if
one vertex were red and one vertex were blue, the color between the two would
slowly blend from red to blue.
Although Gouraud shading is a decent approximation, there are some issues. First
of all, the quality of the shading directly correlates to the number of polygons in
the model. With a low number of polygons, the shading may have quite a few
hard edges, as shown in Figure 4.13(a) . A high-polygon model can look good with
Gouraud shading, but it's at the additional memory cost of having more polygons.
Another issue is that smaller specular highlights often look fairly bad on low-poly-
gonmodels, resulting inthe banding seen in Figure 4.13(a) .Andthe highlight may
even be missed entirely if it's so small that it's contained only in the interior of a
polygon, because we are only calculating the reflection model at each vertex. Al-
though Gouraud shading was popular for many years, as GPUs have improved, it
no longer sees much use.
Phong Shading
With Phong shading , the reflection model is calculated at every single pixel in the
triangle. In order to accomplish this, the vertex normals are interpolated across the
surface of the triangle. At every pixel, the result of the interpolation is then used
as the normal for the lighting calculations.
As one might imagine, Phong shading is computationally much more expensive
than Gouraud shading, especially in a scene with a large number of lights.
However, most modern hardware can easily handle the increase in calculations.
Phong shading can be considered a type of per-pixel lighting , because the light
values are being calculated for every single pixel.
Figure 4.15 compares the results of shading an object with Gouraud shading and
with Phong shading. As you can see, the Phong shading results in a much smooth-
er and even shading.
Search WWH ::




Custom Search