www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/15/10:39:19

Message-ID: <D1FB30BBA491D1118E6D006097BCAE39261C46@Probe-nt-2a.Probe.co.uk>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
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

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019