Message-ID: From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: Terrain Shading in Allegro Date: Tue, 14 Apr 1998 10:31:29 +0100 MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk Jason writes: > I was wondering if anyone knew how to shade a series of triangular > polygons across the whole set of polygons (as if the light source > was shining in one place onto the whole set of triangular polygons). The trick is to calculate a light intensity for each vertex, and then shade this across the polygon (that can be done using the Allegro gouraud shading or lit texture map modes). There are a million possible ways to generate your light values, depending on how you want the result to look. You could simply fade out with distance from the camera, to simulate atmospheric attenuation or "fog". Or you could have some fixed point lightsource, and fade out with distance from that. Or you could have a directional light, and calculate the intensity as the dot product of the vector from the light to the polygon and the normal of the polygon. Obviously you can combine several of these (and many other) methods, to give multiple lights with different characteristics. For a detailed discussion of various lighting models, see the book "Computer Graphics, Principles and Practice", by Foley & Van Damme. Shawn Hargreaves.