Jump to content
  • Advertisement
Sign in to follow this  
Muncher

Bump mapping bump mapping

This topic is 5054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, why is it when moving around a bump-mapped poly/model with gluLookAt() it affects the lighting of the poly/model.... Cheers Paul

Share this post


Link to post
Share on other sites
Advertisement
How are you sending your light data? are you using shaders/programs or GL_DOT3_RGB? we need more info before we can help

Twixn

Share this post


Link to post
Share on other sites
do you render the light sources before camera movements? this may cause the problem. if not, please give more info..

Share this post


Link to post
Share on other sites
soz for the lack of info...

the deal is that im rendering a non moving world (which, for testing is just a cube) the light is fixed and is supplied to the cG shader that bump maps the world using normal maps. The thing is, that when i move around using gluLookAt, the shading on the object changes as i move... i have no idea why.
And yes, i am rendering the world before i move around

Paul

Share this post


Link to post
Share on other sites
are u using the 'glstate' to get ur light data? as that pre-transforms the light position into viewspace...making it behave as u described if used in a shader 'as-is'.

Twixn

Share this post


Link to post
Share on other sites
no, i'm actually not sure what glstate is. My light position (there is only 1) is just hardcoded as at position 0,20,0 this is then fed to the shader that transforms it into texture space to compute the lighting for each bump.

Should i be transforming the light position somehow??

Cheers for the help so far :)
Paul

Share this post


Link to post
Share on other sites
i see the same problem with classic opengl lighting(not shader) when i was beginning opengl. that was because of my render order. so, i was using the camera matrix with lights. i change position of the locate_lights() function to after camera.look(); function and the problem has been solved. can it be a problem like this? try to push and pop matrices when you locate the lights.
maybe your cube position is changing? render a model(eg. a sphere) to the light position and see what happens...

and it may be a problem with shader...??

Share this post


Link to post
Share on other sites
The problem is that you need to do your calculations(compute the light vector) in the same space. I assume you transform the vertices with modelview, so they are in eye space. Meanwwhile, the light position (0,20,0) is in worldspace. When you move the camera, the vertex position changes, but the light pos stays fixed, and that's why the lighting changes.

When you compute the vertex-to-light vector, you need both the vertex and light pos to be in the same space. Just don't transform the vertices, so they will both (vertex&light pos) be in worldspace. Then, transform the calculated lightvector with the TBN matrix to get it in tangent space. The T,B,N vectors also need to be in world space. Of course,after that, you will transform the vertices with the MVP matrix to give correct output in the vertex shader.

Share this post


Link to post
Share on other sites
Doh, i tried moving the lightPos into eye space, and although the results are a little better, the lighting still changes drastically when the camera moves.

Then i tried moving the positioning of the light to after the look() and marking its position with a point. The light does stay fixed in the same position when the camera moves, so thats not the problem... maybe i should post some code...

Paul

Share this post


Link to post
Share on other sites
Ahhhh, got it!

Thanks to all your replies, i the light position and the vertex were in two different coordinate systems, exactly as mikeman said :) I reverted to lighting in object space and the problem went away :)

Cheers all! you rocks!
Muncher

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!