Hi,
(Note there was a previous post re epth Problem but now we find it’s something else … so a new thread !)
Is 4 lights too much ? … I’ve been working on a major problem with an application that we’re developing. We launched a beta version of our application to find that it failed on many systems. The problem looked like a face culling problem and indeed we found that by disabling culling did correct the problem but that in itself isn’t a viable solution. The appearance of the erroneous culling is dependent on view angle with respect to the face normal and effects only quad surfaces !
Eventually we isolated the problem to the fact that we were using 4 lights … switch one off and the problem goes away … problem is that we need 4 lights !
Now, the main development machine uses a GeForce 2 card and I guess the NVidia drivers were a little old … but they worked and didn’t exhibit this problem. However we upgraded the drivers and voila - 4 lights is too much !
We attempted to produce a minimal subset of our code and that’s attached below … note that our world is offset by -20 on the Z-Axis … little to be gained to explain why that came about - is what it is !
Can anyone tell us what we’re doing wrong, whether you’ve got the same problem or have heard of this before … we’re tearing our hair out at the moment !
Many thanks,
Andrew - SoftSpot Software
Note that it’s in Delphi …
…
// OpenGL Initialized parameters …
const
Ambient : TGLArrayf4 = (0.70, 0.70, 0.70, 1.0);
Diffuse : TGLArrayf4 = (0.75, 0.75, 0.75, 1.0);
Specular : TGLArrayf4 = (0.50, 0.50, 0.50, 1.0);
begin
glLightfv(GL_LIGHT0, GL_AMBIENT, @Ambient ); // Light 0
glLightfv(GL_LIGHT0, GL_DIFFUSE, @Diffuse );
glLightfv(GL_LIGHT0, GL_SPECULAR, @Specular);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT1, GL_AMBIENT, @Ambient ); // Light 1
glLightfv(GL_LIGHT1, GL_DIFFUSE, @Diffuse );
glLightfv(GL_LIGHT1, GL_SPECULAR, @Specular);
glEnable(GL_LIGHT1);
glLightfv(GL_LIGHT2, GL_AMBIENT, @Ambient ); // Light 2
glLightfv(GL_LIGHT2, GL_DIFFUSE, @Diffuse );
glLightfv(GL_LIGHT2, GL_SPECULAR, @Specular);
glEnable(GL_LIGHT2);
glLightfv(GL_LIGHT3, GL_AMBIENT, @Ambient ); // Light 3
glLightfv(GL_LIGHT3, GL_DIFFUSE, @Diffuse );
glLightfv(GL_LIGHT3, GL_SPECULAR, @Specular);
glEnable(GL_LIGHT3);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
…
Lights coordinates …
const
LightPos0 : TGLArrayf4 = (-20.0, 20.0, 0.0, 1.0);
LightPos1 : TGLArrayf4 = (-20.0, 20.0, -40.0, 1.0);
LightPos2 : TGLArrayf4 = ( 20.0, 20.0, -40.0, 1.0);
LightPos3 : TGLArrayf4 = ( 20.0, 20.0, 0.0, 1.0);
…
Lights within main draw routine …
glLightfv(GL_LIGHT0, GL_POSITION, @LightPos0);
glLightfv(GL_LIGHT1, GL_POSITION, @LightPos1);
glLightfv(GL_LIGHT2, GL_POSITION, @LightPos2);
glLightfv(GL_LIGHT3, GL_POSITION, @LightPos3);
…
// Floor List
glNewList(fGenList, GL_COMPILE);
glColor3ub(80, 80, 80);
glBegin(GL_QUADS);
glNormal3f( 0.0, 1.0, 0.0);
glTexCoord2f( 0.0, 0.0); glVertex3f(-100.0, -17.0, -100.0);
glTexCoord2f( 0.0, 20.0); glVertex3f(-100.0, -17.0, 100.0);
glTexCoord2f(20.0, 20.0); glVertex3f( 100.0, -17.0, 100.0);
glTexCoord2f(20.0, 0.0); glVertex3f( 100.0, -17.0, -100.0);
glEnd;
glEndList;