Jump to content
  • Advertisement
Sign in to follow this  

2 spot lights, same settings different effect - Help!

This topic is 4994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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);


//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);



   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};



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);




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 this post

Link to post
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 this post

Link to post
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 this post

Link to post
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!