Page 9 of 9

Re: Quad rendering bug

PostPosted: Fri Sep 08, 2017 10:11 am
by Bart
Super cool! I forget how Gouraud shading works but if I remember correctly, you interpolate between 2 adjacent vertices along the edge using linear interpolation, and then when each scanline is filled, it is interpolated from edge to edge linearly? This would work the same way for quads, though. So I must be misunderstanding how the interpolation is performed.

Re: Quad rendering bug

PostPosted: Wed Sep 13, 2017 4:18 am
by Ian
Unfortunately the code I tested can't handle crazy shape quads :(
So maybe back to the drawing board or write myself something from scratch

I did find this which looked quite promising
https://stackoverflow.com/questions/149 ... -in-opengl
but doesn't handle perspective so would essentially be an affine transform

Re: Quad rendering bug

PostPosted: Fri Sep 15, 2017 7:35 am
by Bart
Ian wrote:Unfortunately the code I tested can't handle crazy shape quads :(
So maybe back to the drawing board or write myself something from scratch

I did find this which looked quite promising
https://stackoverflow.com/questions/149 ... -in-opengl
but doesn't handle perspective so would essentially be an affine transform


Ah I see now. I think I was correct about how Gouraud shading works but indeed, if it's not rasterized natively as a quad, it will be different because the interpolation from side to side will occur between one edge and the hypotenuse (assuming an ordinary quad), rather than across the entire span of the quad. This sounds really tricky but it will be fascinating to see if you can implement an elegant solution! If I recall correctly, it was the norm for software 3D engines in the 90's (e.g., Quake) to support either both triangles and quads, or convex polygons of an arbitrary number of sides. I remember writing a software rasterizer way back when (it's still on my web site here!) and this was the natural way to do it (not triangulating). Never really did anything fancy like shading so I never gave much thought to this.