Game Development Community

Scale related lighting problem

by Prairie Games · in Torque Game Engine · 02/17/2005 (10:58 am) · 2 replies

Has anyone else run into this and know what's happening:

Static scale at 1.0:

www.prairiegames.com/scaleone.jpg
Static scale at .1

www.prairiegames.com/scalesmall.jpg
When scaled the object no longer receives lighting, this can also cause black objects.

-Josh

Edit: problem with image links... one is a picture of a properly lit object the other is one that is fully lit, though shouldn't be... only difference is the scale.

#1
02/18/2005 (2:48 pm)
I've noticed this happening in OpenGL; a polygon's total illumination will go up as you scale it down.

I think it has to do with the fact that when you scale an object, you are also scaling the normals for each vertex, and those normals are not recalculated properly, which results in incorrect lighting.

I was trying to position the board in my 3D maze game by changing the scale, and I noticed that it immedialely got brighter as I scaled it down. If I simply moved the board further away from the camera, the "size" went down, but the lighting stayed the same.

The solution to your particular problem would be to scale down your object in whatever editor you were using, then re-export it.
#2
02/22/2005 (2:30 pm)
Yup, messed up normals is the problem.

If you are going to be scaling things in your world, you should use:

glEnable(GL_NORMALIZE)

Enabling this will tell opengl to resize all of your objects normals to unit length after they have been scaled.

Whatever object this is, you can add this call in the engine before it is rendered.