Reflected model lighting

Started by
9 comments, last by Aghis 18 years, 9 months ago
Hi everyone. When rendering a model whose vertices are reflected on the world origin (0, 0, 0) via a glScale3f(-1.0f, -1.0f, -1.0f) call, I only see the ambient light on its surfaces. The light's position in the scene is correct and normals have been calculated and submitted so this situation has developed into a mystery for me. Is there something about lighting and flipped vertices that I don't know?
Advertisement
Quote:Original post by Aghis
Hi everyone.

When rendering a model whose vertices are reflected on the world origin (0, 0, 0) via a glScale3f(-1.0f, -1.0f, -1.0f) call, I only see the ambient light on its surfaces. The light's position in the scene is correct and normals have been calculated and submitted so this situation has developed into a mystery for me.

Is there something about lighting and flipped vertices that I don't know?
Do you send the light's position again after the glScalef call? If that's not the problem, post your rendering code.
All lights are set after the geometry is submitted. Is that wrong? And if so, why does the lighting work if glScale3f is not called?
Try putting automatic normal normalisation on, I think i remember having this problem when I tried reflections by scaling by -1, The command you need is glEnable(GL_NORMALIZE); hope that helps.
Just read your second post, what is probably happening is that the lights are being enabled ready for the next frame, you don't need to do this every frame, you can do it once at the start and then those will be the active lights. If you are using multiple light sources, or you want to turn lighting on and off you can do it by putting appropiate glEnable glDisable calls in your rendering code. I think that the problem is to do with you normals then if it is only the presence of the glScale3f which affects the lighting.
Quote:Original post by moagstar
Just read your second post, what is probably happening is that the lights are being enabled ready for the next frame, you don't need to do this every frame, you can do it once at the start and then those will be the active lights. If you are using multiple light sources, or you want to turn lighting on and off you can do it by putting appropiate glEnable glDisable calls in your rendering code. I think that the problem is to do with you normals then if it is only the presence of the glScale3f which affects the lighting.


Actually, light positions may change from frame to frame. A glLight* function is called on every frame to update this. Are you suggesting that I disable the lights after the buffers are swapped and enable them again after the glLight(..., GL_POSITION, ...) call?
You might try glEnable(GL_RESCALE_NORMAL), but I'm not sure if it'll fix your problem.
Quote:Original post by Aghis
Actually, light positions may change from frame to frame. A glLight* function is called on every frame to update this.


Yes your right if the position, colour etc changes then you need to call glLight, but only call it when something changes, don't call it every frame.

Quote:Original post by Aghis
Are you suggesting that I disable the lights after the buffers are swapped and enable them again after the glLight(..., GL_POSITION, ...) call?


No you don't need to do that, only if you need to render stuff without lighting, you don't need to keep disabling and enabling the lights for the changes to take effect.

Did you try the glEnable(GL_NORMALIZE)? I have a feeling it will fix you problem.
Quote:Original post by Aeluned
You might try glEnable(GL_RESCALE_NORMAL), but I'm not sure if it'll fix your problem.


My OpenGL library doesn't seem to support this feature... Can I enable it through some extension?
Quote:Original post by Aghis
Quote:Original post by Aeluned
You might try glEnable(GL_RESCALE_NORMAL), but I'm not sure if it'll fix your problem.


My OpenGL library doesn't seem to support this feature... Can I enable it through some extension?


Use glEnable(GL_NORMALIZE);

This topic is closed to new replies.

Advertisement