Rouben Rostamian wrote:
> Brian, re your message regarding non-uniform scaling, you wrote:
>>GL_NORMALIZE computes the magnitude of the normal vector,
>>then divides the components of the normal by the magnitude.
>>The result is a unit-lengh normal vector, regardless of scale
>>factors. However, the _direction_ of the normal may not be
>>correct for non-uniform scales. Mesa/OpenGL can't do anything
> So we agree that the _direction_ of the recomputed normal vector is
> incorrect in general. Well, if that is not a bug, then what is it?
An unfortunate side-effect of linear algebra.
> What is the use of computing a vector which does not point in the
> right direction?
> I don't agree that "Mesa/OpenGL can't do anything about that".
> Consider a point P on a surface S and let N be the normal to S
> at P. Suppose that the tangent plane at P looks like this:
> ax + by + cz = d,
> therefore the normal vector is N = (a, b, c). OpenGL/Mesa
> receives the normal vector N from the user.
> Now suppose that the space is scaled by factors u, v, w in the
> x, y, z directions. Then the tangent plane transforms to:
> aux + bvy + cwz = d,
When we're transforming normals, we don't have individual u, v, w scale
factors; we have the modelview matrix. We use the upper-left 3x3 part of the
inverse of the modelview matrix to transform the normal. The 3x3 part has
rotation factors (and possibly shearing) in addition to the scale factors.
Perhaps you can extract the correct u, v, w values out of there but I'm too
lazy to go through the arithmetic right now.
> which says that the new normal vector is N' = (au, bv, cw)
> which is easily computable. Compute N' then reduce it to
> unit length.
If it's that easy, why didn't OpenGL define that behaviour from day one? I
can't remember the details, but I think it's a little harder than that.
>>I don't see an open bug related to GL_NORMALIZE and I'm not
>>aware of any known issues with it.
> My recollection is that you looked into the issue and concluded
> that Mesa was doing the right thing. The bug report then was
> marked as closed/resolved.