Sign in to follow this  
Aghis

Reflected model lighting

Recommended Posts

Aghis    144
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?

Share this post


Link to post
Share on other sites
Kalidor    1087
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.

Share this post


Link to post
Share on other sites
Aghis    144
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?

Share this post


Link to post
Share on other sites
moagstar    263
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.

Share this post


Link to post
Share on other sites
moagstar    263
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.

Share this post


Link to post
Share on other sites
Aghis    144
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?

Share this post


Link to post
Share on other sites
moagstar    263
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.

Share this post


Link to post
Share on other sites
Aghis    144
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?

Share this post


Link to post
Share on other sites
moagstar    263
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);

Share this post


Link to post
Share on other sites
Aghis    144
Quote:
Original post by moagstarDid you try the glEnable(GL_NORMALIZE)? I have a feeling it will fix you problem.


Yes I did. Unfortunately nothing changed. It is still the wrong surfaces that are receiving the light :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this