glScale and Normals

What effect does glScale have on Normals?
Because if it affects them, then they aren’t going to be unit length any longer.

Normals are transformed by, if I remember correct, the transpose of the inverse of the modelview matrix. Meaning, if you scale your object by 2, your normals are scaled by 0.5. You can enable GL_NORMALIZE to tell OpenGL to renormalize your normals after transformation.

Hi !

Yes GL_NORMALIZE fixes some problems, but if I remeber correct it does not work with non uniform scaling, not much you can do about it though.

On most modern hardware GL_NORMALIZE does not cost anything in performance so there is no reason to have it disabled.

Mikael

Originally posted by mikael_aronsson:
[b]Hi !

On most modern hardware GL_NORMALIZE does not cost anything in performance so there is no reason to have it disabled.

Mikael[/b]

Hi! Why does it cost nothing to have it?

Originally posted by Bob:
Normals are transformed by, if I remember correct, the transpose of the inverse of the modelview matrix. Meaning, if you scale your object by 2, your normals are scaled by 0.5. You can enable GL_NORMALIZE to tell OpenGL to renormalize your normals after transformation.

OK! So this is really useful then. Correct me if I’m wrong, but this says that gl does the intelligent thing with the normals so that you never need to recalculate their direction, or size.

I have not used scaling much (OpenGL’s scaling that is) so I’m not very experienced with it. But I think you are correct that the normal, after scaling, will still be a vector perpendicular to the surface, although scaled. So it should work correct with non-uniform scaling.

Hi !

It does not cost anything because the hardware can do it in a way that it does not impact speed.

You still have to calculate the normals, GL_NORMALIZE just keeps them correct when you start to scale.

I could be wrong on the non uniform issue, I am not sure.

Mikael

Originally posted by mikael_aronsson:
[b]
You still have to calculate the normals, GL_NORMALIZE just keeps them correct when you start to scale.

I could be wrong on the non uniform issue, I am not sure.
[/b]

There are two normal “rescaling” operations in opengl. GL_NORMALIZE which does a full recalculation of the vector length and then there is GL_RESCALE_NORMAL. If you only use uniform scaling you can get away with only using GL_RESCALE_NORMAL.

Originally posted by roffe:
There are two normal “rescaling” operations in opengl. GL_NORMALIZE which does a full recalculation of the vector length and then there is GL_RESCALE_NORMAL. If you only use uniform scaling you can get away with only using GL_RESCALE_NORMAL.

I can’t find GL_RESCALE_NORMAL in the headers nor in the msdn library.

Originally posted by mr_coolio:
I can’t find GL_RESCALE_NORMAL in the headers nor in the msdn library.

Microsofts header files are OpenGL 1.1,
GL_RESCALE_NORMAL is OpenGL 1.2.

Locate some updated header files from your gfx card vendor, unless you’re software rendering.

To get you started…
#define GL_RESCALE_NORMAL 0x803A

[This message has been edited by roffe (edited 02-27-2003).]

well, thanks that was very helpful, folks.

[This message has been edited by mr_coolio (edited 02-27-2003).]