Interpolating Colors in Lighting Mode?

Reuel Nash reuel at khaki.asd.sgi.com
Tue Nov 6 04:47:10 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?
> 
> mark (markv at acm.princeton.edu)
> Mark VandeWettering
> markv at acm.princeton.edu


The command that triggers lighting calculations depends a lot on
what lighting modes you're in. The above code will do what you want in 
a local lighting or local viewer mode, since lighting calculations 
are done by the v3f() call. You must not be using any local lights or viewer,
however. In the infinite model, lighting calculations are done by 
the n3f() command, using the current "state" including the current color
as set by the most recent c3f(). This code should work for you:
 
 	lmcolor(LMC_DIFFUSE) ;
 
 	....
 
 	bgnpolygon() ;
 		c3f(c1) ;		/* a color + vertex */
 		n3f(normal) ;		/* some normal for the poly	*/
 		v3f(v1) ;
 		c3f(c2) ;		/* a color + vertex */
 		n3f(normal) ;		/* some normal for the poly	*/
 		v3f(v2) ;
 		c3f(c3) ;		/* a color + vertex */
 		n3f(normal) ;		/* some normal for the poly	*/
 		v3f(v3) ;
 	endpolygon() ;
 

Reuel Nash				Email:		reuel at sgi.sgi.com  
"Rendering? You mean like hogs?"	Voicemail:	(415)962-3254  
Mail stop:SR-254 Work Phone:(713)266-1333 Home Phone:(713)589-6258
USMail:	 Silicon Graphics, 5858 Westheimer Suite 100, Houston, TX  77057



More information about the Comp.sys.sgi mailing list