Rouben Rostamian wrote:
>
> Transformation of normals under rescaling has been broken
> since Mesa3.1, at least.
>
> The problem is gotten particularly bad in Mesa3.4.
> I have written a simple demo to illustrate it.
> You can find the demo files in
>
> ftp://ftp.math.umbc.edu/pub/rostamian/mesabug/
>
> I spent some time going through Mesa3.4 source to track down
> the problem, but did not succeed :(
>
> I hope that seeing the demo will inspire some of the gurus
> here to look into the problem.
>
> PS: Homogeneous scaling, i.e., scaling with equal factors
> in the x, y, z directions, works just fine. The problem
> shows up only in inhomogeneous scaling.
The behaviour with Mesa 3.2, 3.2.1, 3.3, 3.4, and 3.5 appears
identical. With Mesa 3.1, however, the results are different
but I'm not sure it can be called better or worse. It may
actually be that Mesa 3.1 was broken.
The idea behind GL_RESCALE_NORMAL is that one can analyze the
inverse modelview matrix to compute a scale factor. This scale
factor is applied to all vertex normal vectors in order to scale
them to unit length. The scale factor is just computed once from
the inverse modelview instead of pervertex as GL_NORMALIZE does.
So it should be faster.
However, I don't think GL_RESCALE_NORMAL is going to be of much
use for nonuniform scale factors. I haven't gone through all
the math by hand but it looks like only the Zaxis scale factor
is relevant in the scale factor computation.
I think GL_RESCALE_NORMAL is only valid when you're providing
unitlength normals in your application AND the modelview matrix
only has uniform scales. I just checked the OpenGL 1.2 spec
and that's what is says.
Also note that the regular GL_NORMALIZE operation isn't always
going to help with nonuniform scales either. With shapes like
cylinders and cubes it just happens to do the job. But with other
objects a nonuniform scale is going to transform normal vectors in
a way which is not consistent with the underlying surface geometry.
So to summarize, I think GL_RESCALE_NORMAL was broken in Mesa 3.1
and it works correctly now. Also, don't try to use GL_RESCALE_NORMAL
if your modelview matrix has a nonuniform scale. GL_NORMALIZE
might work better, but not always.
Brian
