# Weird specular lighting on floor

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

## Recommended Posts

I'm having a bit of trouble getting my floor to light up at all. Here's a screen: http://img194.imageshack.us/my.php?image=picture41fq.png 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 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 on other sites
see point 2 here
http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/

##### Share on other sites
I see.

I guess that would break it, the floor is actually only 4 vertices with the texture stretched across and repeated.

So either I fix the floor or I implement a per-pixel lighting shader, which I've wanted to do for a while now.

thanks.

##### Share on other sites

http://rav.efbnet.com/imagebin/images/1145745015.png

I used the shader from lighthouse3d.com and modified it to use textures, later on I'll add in mutiple-light support.

• 11
• 20
• 12
• 10
• 34
• ### Forum Statistics

• Total Topics
631399
• Total Posts
2999853
×