# 2 spot lights, same settings different effect - Help!

## Recommended Posts

I've had this problem a while and posted something a while back with little response but i have a different problem now. As the title suggests i've got two spot lights in my scene both exactly the same settings e.g. position,spot_cutoff,spot_exponent etc, shing down onto a highly tessalated surface but one is bigger than the other i.e light 1 is a small circular beam which is what i would expect with my settings (see code) yet light2 is probably 3 times bigger and oval shaped!?!? Heres the relevant code

int InitGL(GLvoid)
{
glClearColor (0.0, 0.0, 0.0, 0.0);

glEnable(GL_BLEND);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_DEPTH_TEST);

glDepthFunc(GL_LEQUAL);

//general light settings

GLfloat ambient[] = {0.5,0.5,0.5,1.0};
GLfloat diffuse[] = {1.0,1.0,1.0,1.0};
GLfloat specular[] = {0.0,0.0,0.0,0.0};

//light 0 settings
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);

glLightf(GL_LIGHT0, GL_SPOT_EXPONENT,128.0);
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 10.0);

//light 1 settings
glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, specular);

glLightf(GL_LIGHT1, GL_SPOT_EXPONENT,128.0);
glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 10.0);

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);

glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);

return TRUE;
}

void drawTable()
{
float z = 0.0;
float z1 = 0.1;
int c = 0;

for(z=1.0; z<=15.0; z+=0.5)
{
for(float x=-3.0; x<=3.0; x+=0.5)
{
g_vRect[1] = snooker_Vector(x,0.0,z);
g_vRect[2] = snooker_Vector(x+0.5,0.0,z);
g_vRect[3] = snooker_Vector(x+0.5,0.0,z+0.5);
g_vRect[4] = snooker_Vector(x,0.0,z+0.5);

}
}
}

void RenderScene()
{
GLfloat position[] = {0.0,2.0,1.1,1.0};
GLfloat spot_direction[] = {0.0,-1.0,1.1,1.0};

GLfloat position1[] = {0.0,2.0,2.9,1.0};
GLfloat spot_direction1[] = {0.0,-1.0,2.9,1.0};

glMatrixMode(GL_MODELVIEW);

glPushMatrix();

g_Camera.PositionCamera(0.0,6.5,5.0,
0.0,-2.0,5.6,
0.0,1.0,0.0);

g_Camera.Look();

glLightfv(GL_LIGHT0, GL_POSITION, position);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION,spot_direction);

glLightfv(GL_LIGHT1, GL_POSITION, position1);
glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION,spot_direction1);

glPushMatrix();

drawTable();

glPopMatrix();
glPopMatrix();

SwapBuffers(hDC);
}


I'd post an image to show u what it looks like but i don't know how, can i post one from my c: drive or does it have to be from the web? Anyway any help is appreciated.

##### Share on other sites
Yeah, your light state settings are the same, but position and look_at for the spotlights are different (position vs position1 and spot_direction vs spot_direction1). My guess is that your positioning is off. Play with those numbers a bit more. Everything else looks fine.

##### Share on other sites
Hmm i think your right actually, before.. i had one spotlight in front of the other, in that scenario they were different sizes. When i moved the lights so they were parallel/side by side to each other they were the same size so perhaps its something to do with the way my camera is lookin down on the scene?

##### Share on other sites
No. This lighting model has nothing to do with where the camera is pointed. Just like a spotlight in real life, it doesn't care how you look at it. Unless you're seeing distortions because of distance from the camera, I'd say you just have the spotlights in different positions.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627665
• Total Posts
2978529

• 10
• 10
• 12
• 22
• 13