View Full Version : Light over a quad
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:
glTexCoord2f(0, 0); glVertex2f(0,0);
glTexCoord2f(1, 0); glVertex2f(0,100);
glTexCoord2f(1, 1); glVertex2f(100,100);
glTexCoord2f(0, 1); glVertex2f(100,100);
I tried applying glMaterial settings but nothing happens.
Any solution? Is this always like this?
Thanks a lot.
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.
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
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 ?
11-13-2000, 02:25 PM
It does it automatically.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.