Skip to main content
gamedev.net
🔒 Locked

Strange lighting problem

Started by stuh505 6 replies 1.5k views
Original Post
stuh505
stuh505
For some reason my objects are displaying almost-flat shaded. It doesn't matter where I put the light. It's not the normals (which were exported from max) -- the problem happens even when using a primitive like glutSolidSphere and I know that generates normals. What could be causing this? lightingprobdz3.jpg
Brother Bob
Brother Bob
Have you even enabled all the required lighting states? You need to enable both GL_LIGHTING to turn on lighting in general, and the individual GL_LIGHTn aswell.
stuh505
stuh505
The jpg encoding made it difficult to understand what was happening, this should be a better image (why doesnt this forum display images?)

One of these might display...

light2jw3.png

Image Hosted by ImageShack.us

http://img98.imageshack.us/img98/3360/light2jw3.png
Herr_O
Herr_O
GLfloat light_position[] = { -2.991, -25.599, 52.613 };GLfloat light_pos_follow[] = { 0,0,0 };


looks a little bit odd to me. The light array should have a size of 4. One component for each axis and a value for describing what type of light opengl is dealing with. If the last parameter is omitted you can't tell if it is a directional light or a point/spot-light. Directional lights are defined by 0, spot and point lights are 1.

Further reading...

Jouvieje OpenGL lighting tutorials

NeHe light tutorial
RichardoX
RichardoX
Are your normal vectors set up properly? It looks like you are either using wrong normal vectors or they are pointing the wrong way. This may be caused by scaling, because the scene gets scaled, but the normal vectors don't. So, if you scale your scenes, you need to scale your normals too. The easiest way to do this is to enable GL_NORMALIZE.

-Riku
stuh505
stuh505
Quote:
The light array should have a size of 4.


Ok. I added another 1 to the end. It didn't change anything.

Quote:
Are your normal vectors set up properly?


GL_NORMALIZE is already enabled, and I have the same problem if I try to use glutSolidSphere that comes with normals

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.