markv@gauss.Princeton.EDU (Mark VandeWettering) (11/03/90)
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@acm.princeton.edu) Mark VandeWettering markv@acm.princeton.edu
kurt@cashew.asd.sgi.com (Kurt Akeley) (11/06/90)
In article <3801@idunno.Princeton.EDU>, markv@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
reuel@khaki.asd.sgi.com (Reuel Nash) (11/06/90)
In article <3801@idunno.Princeton.EDU>, markv@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@acm.princeton.edu) > Mark VandeWettering > markv@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@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