Jump to content
  • Advertisement
Sign in to follow this  
Isolier

3D Lighting Problem

This topic is 4826 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

Hello, I am using OpenGL, but thought to post this in the general game programming forum as I am sure a similar problem could happen in D3D. I seem to be having trouble with lighting in my current project which creates terrain from a heightmap. The problem seems to be with directional lights. When I set up a directional light, the entire world is lit as if I was only using ambient light, so I am getting a 2d looking landscape basically, because there is no shading done along the hills or anything. However, when I use a positional light, things seem to work correctly as the 3d terrain appears to be correctly lit along the hills and valleys and such. I am simply using:
float[] diffuseLight = {0.5f, 0.5f, 0.5f, 1.0f};
float[] lightPos    = {0.0f, 1.0f, 0.0f, 0.0f};
nomalizeVector(lightPos);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);



I am fairly sure my normals are calculated correctly else the positional light wouldn't work I am assuming. Does anyone know what is wrong? Am I setting up the directional light incorrectly? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
did you enable lighting via glEnable(GL_LIGHTING) ??

I think you have to enable every light seperatley too, so you'd have to enable GL_LIGHT0 or something. I'm gonna get some old code, and report back.


Tim

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!