Archived

This topic is now archived and is closed to further replies.

Midhas

Lighting-Problems

Recommended Posts

Hi, i try to light my QUAD... glNormalf(0.0, 1.0, 0.0); glBegin(GL_QUAD); glVertex3f(-50.0, 0.0, -50.0); glVertex3f(-50.0, 0.0, 50.0); glVertex3f( 50.0, 0.0, 50.0); glVertex3f( 50.0, 0.0, -50.0); glEnd(); ... with a SPOT_LIGHT at Position... x=0.0, y=10.0, z=0.0, ... with SPOT_DIRECTION to ... x=0.0, y=-1.0, z=0.0 ... and a CUT_OFF-Angle of 50.0. The QUAD is only lighted when i increased the CUT_OFF-Value to a higher one, which light-cone of the angle includes at least one Vertex of the QUAD... What did i wrong ? How can i light the QUAD without make sure that one vertex is in the view of the spotlight ? Hope anybody can help me !!! thanks Midhas

Share this post


Link to post
Share on other sites
OpenGL''s default lighting is per-vertex. This means that colour is calculated at each vertex of each primitive and interpolated across the primitive. If none of your vertices are lit by the spotlight then your quad will not be lit. You''ll need to either:

a) tesselate your quad
b) use a lightmap
c) use a projective texture
d) use per-pixel lighting using a fragment program

Enigma

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think you need to add ambient lightning to your scene. Something like:

GLfloat ambient_light[] = {0.2f, 0.2f, 0.2f, 1.0f};

glLightfv( GL_LIGHT0, GL_AMBIENT, ambient_light);

Share this post


Link to post
Share on other sites