Lighting-Problems

Started by
3 comments, last by Midhas 20 years, 3 months ago
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
Advertisement
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
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);
Don''t you have any tutorials or links ? I searched the
full google-world, but i found nothing really helpful stuff.

:-(

thanx, midhas

<a href = http://www.gamedev.net/download/redbook.pdf> look at chapter 5 </a>

This topic is closed to new replies.

Advertisement