PDA

View Full Version : Light over a quad



overloadnn
11-12-2000, 01:46 PM
I have a little problem when moving a light over a quad: It only gets lighted when the light is very close to the one of the vertexs. I do want smooth shades over the quad then light is on the top of it!!

I draw the quad with a texture (with just a color does the same) like this:

glPushMatrix;
Texture2.Enable;
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(0,0);
glTexCoord2f(1, 0); glVertex2f(0,100);
glTexCoord2f(1, 1); glVertex2f(100,100);
glTexCoord2f(0, 1); glVertex2f(100,100);
glEnd;
glPopMatrix;

I tried applying glMaterial settings but nothing happens.
Any solution? Is this always like this?

Thanks a lot.

RandyU
11-12-2000, 02:18 PM
Try also changing specular and diffuse component of your light(more ambient and diffuse and less specular-> more smooth light),material's Specular(diffuse (and ambient)is smoother) and shininess(lesser->smoother,but i'm not sure).
Maybe you also need directional instead of positional light, use no attenuation and cuttoff.

Won
11-12-2000, 08:04 PM
OpenGL normally uses vertex lighting, which is to say that lighting computations are done only at the vertices and the lighting contribution everywhere else in the quad is
interpolated between these values.

There are at least three solutions:

1) Add more vertices (tesselation) by using a grid of little quads instead of one large quad. This is probably the easiest way to do it.

2) Use a light map, which is just another texture (usually an environment map) that generates the lighting contribution per texel. The downside is that is that you have to regenerate the lightmaps for dynamic lights whenever they change, and deal with rendering with two textures instead of one. Of course, with most multitexturing video cards, you really don't suffer that a big a performance penalty besides the lightmap generation.

3) If you have a newer video card (e.g. GeForce) then use per-pixel lighting. There are a ton of demos on this, but it's a bit more complicated than the other two options.

Good luck -- Won

overloadnn
11-13-2000, 11:42 AM
My first aproch will the be a quad strip, but what about the texture?
How do I apply a unique texture shared with several quads ?

Thanks

RandyU
11-13-2000, 02:25 PM
It does it automatically.