Interpolating Colors in Lighting Mode?

Kurt Akeley kurt at cashew.asd.sgi.com
Tue Nov 6 03:54:52 AEST 1990


In article <3801 at idunno.Princeton.EDU>, markv at gauss.Princeton.EDU (Mark
VandeWettering) writes:
|> Is there any way to make the SGI interpolate colors AND perform shading
|> calculations at the same time?  For instance, if I am drawing triangles
|> and wish to interpolate the colors, I do something like:
|> 
|> 	lmcolor(LMC_DIFFUSE) ;
|> 
|> 	....
|> 
|> 	bgnpolygon() ;
|> 		n3f(normal) ;		/* some normal for the poly	*/
|> 		c3f(c1) ;		/* a color + vertex */
|> 		v3f(v1) ;
|> 		c3f(c2) ;		/* a color + vertex */
|> 		v3f(v2) ;
|> 		c3f(c3) ;		/* a color + vertex */
|> 		v3f(v3) ;
|> 	endpolygon() ;
|> 
|> But the resulting triangle, while shaded, only has a single flat color.
|> 
|> Any ideas?

You've run into a bug/feature of non-VGX systems.  Prior to the VGX, IRIS
systems did infinite lighting computations only when a new normal was passed,
rather than for each vertex.  When lmcolor() was introduced some of the
problems with this "short cut" were corrected, some were documented, and
others, such as yours, were missed altogether.  I tried your code on a GTX
and it failed just as you described, because the GTX does only a single
lighting calculation.  On my VGX things worked just fine.  To solve the
problem on all machines, simply call v3f() prior to drawing each vertex:

	bgnpolygon();
	c3f(c1);
	n3f(normal);
	v3f(v1);
	c3f(c2);
	n3f(normal);
	v3f(v2);
	c3f(c3);
	n3f(normal);
	v3f(v3);
	endpolygon();

I will file a bug against machines that exhibit this behavior.  Thanks.

-- kurt



More information about the Comp.sys.sgi mailing list