subscribe

Shading

flat shading

Objects in 3D scenes are most commonly created by fitting together a large number of polygons (usually triangles), edge to edge, creating a “wire-frame” which approximates the object’s surface. By drawing only those triangles which lie on surfaces visible to the viewer (known as “hidden line removal”), recognisable, though unrealistic, objects can be portrayed. There are a number of ways to make objects more realistic. One being texture mapping and another: shading. As the name suggests, shading means simulating light falling on a scene and the effect this has on the brightness and colour of different areas of objects in the scene. There are many different ways to shade a scene but we will look at the three most commonly used:

The simplest and fastest form of shading is “flat” (sometimes called “polygon”, “constant” or “faceted”) shading, in which a single colour is assigned to each polygon in an object. Objects take on a more solid appearance than when represented as wire-frame models but, unless the individual polygons which make up the object are extremely small and the graphic card’s colour depth is sufficiently high, are still evidently polyhedral (made up of a number of flat planes) and still appear “blocky”, as the junctions between polygons are still visible. In fact, even if the polygons making up the object are extremely small, colour banding (also called the Mach band effect, after the person who first observed it) can still appear, detracting from a smooth appearance.

 

 

gouraud shadingThe next most effective way to add realism is by using Gouraud (also “intensity interpolation” or “colour interpolation”) shading, which is a technique implemented in the OpenGL API. Its effect can be seen in some of the 3D screen-savers supplied with 32-bit versions of Windows. It involves calculating the colour at each polygon’s vertices (the corners) and blending these colours into each other across the surface of the polygon. This hides the junctions between polygons and produces a smoother appearance in curved object surfaces. Unfortunately, unless extra calculations are done, this can mean that smoothing also happens at junctions which should remain sharply visible, such as those at the edges of a cube. Though able to represent diffuse highlights, Gouraud shading doesn’t handle specular highlights (the kind seen on shiny surfaces) at all well, so all object surfaces appear to have a matt texture. It also takes more processing power than flat shading but is the minimum required to produce anything like a realistic 3D object. Adding texture mapping to Gouraud shading can improve its effectiveness a lot and is often used as a compromise when complex scenes have to be built-up in real time on low-power systems.

 

phong shadingThe most realistic looking of the commonly used shading techniques is Phong (or “normal-vector interpolation”) shading. It too bases its calculations on polygon vertices but also takes into account the way that light will be reflected from each point within a polygon, not just its intensity or colour. The resultant image produces much more realistic objects, especially if the object is one in which we are used to seeing sharply defined reflections from light sources. Phong shading requires much more processing power than Gouraud shading, so is more likely to be confined to visualisation systems running on more powerful equipment. It has only recently started to become available on higher-end gaming hardware but is almost certain to become a must-have for future tick-lists. By the way, don’t confuse “Phong lighting” with “Phong shading”. Phong lighting calculates lighting values for polygon vertices but then uses Gouraud-type blending calculations to apply values to the rest of the polygon. The result is not as realistic as if Phong shading were used.

 

Ray tracing and radiosity are techniques for scene rendering which are based on modelling the way light reacts with objects in the real world. These require vast amounts of processing power, or very long rendering times, to achieve but are necessary to produce images that can even begin to be considered photo-realistic.