Jump to content
  • Advertisement
Sign in to follow this  
genesys

strange lighting

This topic is 4234 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! I've got a problem with lighting/shading... I have objects with the following material setup: gl_push_attrib(gl_enable_bit | gl_polygon_bit | gl_texture_bit) gl_shade_model(gl_smooth) gl_enable(gl_lighting) gl_materialfv(gl_front_and_back, gl_ambient, ambient_color.pointer) gl_materialfv(gl_front_and_back, gl_diffuse, diffuse_color.pointer) gl_materialfv(gl_front_and_back, gl_specular, specular_color.pointer) gl_materialfv(gl_front_and_back, gl_emission, emission_color.pointer) gl_materialfv(gl_front_and_back, gl_shininess, shininess.pointer) gl_enable(Em_gl_texture_2d) gl_bind_texture(gl_texture_2d, texture_id) and there is a lightsource flying arround the objects. But instead of smooth shading change, the faces which are lit are completely blue, while the faces pointing away from the lightsource are completely black. and while the lightsource moves, the faces change from black to blue within one moment... http://neo.cycovery.com/lighting_problem.gif what could be wrong here?

Share this post


Link to post
Share on other sites
Advertisement
No ideas?

I must say: I am working on a library which is written by many different students. My target is to replace the current 3D stuff since it is veeeery messy. I didn't yet replace all classes so it can be that before my material call any gl commands are called which are responsible for the effect i get. But i have to know what gl calls this could be, so that i can find it!


Thanks!

Share this post


Link to post
Share on other sites
I see you are lighting front and back, but did you take into account polygon winding? (link)
I'm unsure if this would cause the exact problem you have, but it is the only thing that readily comes to my mind.

Share this post


Link to post
Share on other sites
yes. The polygon winding isn't the problem, since i load the objects from .obj file in which the winding is already defined right.

And the lighting of the polygons itself is actually right (the ones that should be lit are lit and the ones which shouldn't be lit (because they don't face the lightsource) are black) . . . but there is no gradually degreasement of the lighting - only a sudden 'swap' from lit to not lit and vice versa . . .

Share this post


Link to post
Share on other sites
I can think of only one thing: flat shading. Even tbough you explicitely enable smooth shading, it seems to have no effect. Check for errors using glGetError. Also - but this couldn't be it I think - are you sure the device you're working on is using a colour output of more than 8 bits per pixel?

EDIT: the image doesn't look quite right. Are you absolutely sure both the model is correct and you load it in correctly?

[Edited by - Todo on November 19, 2006 8:01:31 AM]

Share this post


Link to post
Share on other sites
face normals and models are ok!

I'm still experiancing the same problem.

Here is the rendering of a glu_sphere (here the normals must be correct!)

http://neo.cycovery.com/lighting_problem2.gif

one can see, that the normals facing the lightsource are completely green, while the normals backfacing the lightsource are completely black. between them there is a smooth gradient.

There is only one lightsource with the following properties
diffuse_clor := (1.0,1.0,0.8,1.0)
specular_color := (1.0,1.0,1.0,1.0)
ambient_color := (0.0,0.0,0.0,1.0)


is this not correct?

Share this post


Link to post
Share on other sites
Argh!! i found the problem:

the elements of the vectors i passed to openGL were DOUBLE and not FLOAT... that's why i got such strange behaviour...

Now everything works fine!

Thanks to all anyway!

[Edited by - genesys on November 20, 2006 11:26:32 AM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!