Sign in to follow this  
Foobar of Integers

Weird specular lighting on floor

Recommended Posts

I'm having a bit of trouble getting my floor to light up at all. Here's a screen: The light is built using the code:

float light_position[4] = {0.0f, 1.1f, 0.0f, 1.0f};
float light_ambient[4] = {0.0f, 0.0f, 0.0f, 1.0f};
float light_specular[4] = {0.0f, 1.0f, 0.0f, 1.0f};
float light_diffuse[4] = {0.0f, 1.0f, 0.0f, 1.0f}; 

float spot_cutoff = 45.0f 
float spot_direction[] = {0.0f, -1.0f, 0.0f} // down at the floor

As you can see, the model is lighting up fine under the spotlight. (The cube is just there to make the light's position more obvious) However, the floor isn't lighting up at all. I set up the floor's material properites using this code, and pass the normal of (0, 1, 0) for each vertex on the floor Edit: I am also specifying the floor vertices in counter-clockwise order.

float light_properties[] = {0.6f, 0.6f, 0.6f, 1.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, light_properties);					
glBindTexture(GL_TEXTURE_2D, *m_pTextureManager->GetTexture(floor));
// etc

How do I get it to light up in the spotlight like the model does? I thought that giving it the mateiral properties that I do should work. [Edited by - Foobar of Integers on April 22, 2006 3:28:58 PM]

Share this post

Link to post
Share on other sites
This kind of lighting is per vertex. So if you're only using 4 (or perhaps 6) vertices for the floor, all positioned in the corners, they will all be outside the range of the spotlight. I don't know how many triangles your using for the floor, but my guess is that there are no vertices below the spotlight that can be illuminated by it, and that's why there is no lighting on the floor.

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