Rodolphe Ortalo wrote:
> My usual test program draws a few thousand random Gouraud shaded triangles
> on a 1024x768 16bpp framebuffer (5:6:5), using a 16bpp Z-buffer. Each
> triangle is defined by 3 vertices which are defined using the
> (Matrox-related) structs shown at the end of this mail. The WARP program
> (aka pipe) I use is a TGZ one, so specular, fog, and alpha color
> parameters theoretically have no effect on the drawing.
Are corresponding units in the pixel shading pipeline disabled (e.g.
it might not be enough to disable units setting up triangle parameters,
but also those using (possible uninitialized) parameters...)
> Triangles get drawn correctly wrt x,y positions on the screen. However,
> The actual shading of the triangles is very "strange". I usually get a
> *striped* rainbow color-gradient on all triangles. Changing the color of
> the vertices influences the "shading", setting textures also affects the
> colors (but textures do not really show up yet). However, overall, it
> seems to me that the triangle drawing is wrong. (I expected to have a
> smooth transition on the triangle surface, not a striped result - but I'm
> not sure of what the drawing should be.)
Do the frame buffer read out unit's and the shader's understanding of
what the frame buffer layout should be match? (e.g. shader set to
555 weights and readout to 565 could give the above result).
> I am not very familiar with Gouraud shading, nor with the potential
> artifacts of this algorithm. (My test program more or less generates the
> vertices parameters randomly - so I guess it may really use the Gouraud
> algo. the ill way.) Initially, I thought it was a problem due to hardware
> setup (this is still a possibility and I'm pursuing efforts to check the
> driver) but well, maybe it is something else.
Gouraud shading just means that color values are interpolated linearly
over the triangle. Flat shading just dives it some constant color (either
from the last vertex or from the average of all vertex colors).
Phong shading interpolates the normals over the triangle and performs
lighting calculation for each pixel.
> Does someone with experience debugging (hw-accelerated) 3D rendering can
> give me advice here? Are there situations where Gouraud shaded triangles
> renders to rainbow stripes? Or is it just the driver which is buggy (<me>
> very stupid sometimes :-).
It looks as if there is an overflow in the color interpolation. Just try
to set the triangles vertex colors to one basic color only but different
intensity. This should result in a smooth gradient with only that color.
May be this gives a hint where overflow takes place...
> <teapot wanted>
> I'd also really like to (re)use some "classical" 3D test programs and the
> associated tesselated 3D models in order to check the actual rendering of
> the G400. (If possible with reference output for various rendering
> parameters: with/without specular, with/without alpha, with/without
> textures, etc. And minimal "porting" work to reuse the code - ideally only
> the draw_triangle() function should need porting. :-) Do you know were I
> can find some?
> </teapot wanted>
I think the teapot thingy comes with the SGI sample implementation in the
KGI repository.
Steffen Seeger