Weird specular lighting on floor

Started by
3 comments, last by Foobar of Integers 17 years, 12 months ago
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));
glBegin(GL_QUADS);
// 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]
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface
Advertisement
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.
see point 2 here
http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/
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.
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface
Update: Per-pixel lighting shader goodness!

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.
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface

This topic is closed to new replies.

Advertisement