PDA

View Full Version : light vectors, how to make lights work?



04-22-2000, 11:28 AM
how do i make a light point in the right direction?i defined a light 0,0,-1
and i figured that the light product of that and any other object after 0,0,0 would get light on him, but nope, that didn't work, so i did 100,-100,-100 and puff what do u know the object got lit but only a little, any usggestions?

04-24-2000, 06:43 AM
Could be a whole whack of things:
1) translation and/or rotation
2) be sure to define lights before objects
3) material properties of objects
4) light settings: brightness, etc.

For a test, put an object where your light is to represent it. Note that unless the light is explicity defined as spot, it shines in all directions.



Originally posted by sadman:
how do i make a light point in the right direction?i defined a light 0,0,-1
and i figured that the light product of that and any other object after 0,0,0 would get light on him, but nope, that didn't work, so i did 100,-100,-100 and puff what do u know the object got lit but only a little, any usggestions?

dmy
04-24-2000, 01:37 PM
for directional lights you can use this rule:

-take a sphere of unit radius
-take a point on its surface
-build a ray from it to the sphere's center

this way you have defined a direction, wich is the where the light is pointing.

...or you can consider you scene to be infinitely small, and positioned at the center of the sphere.

of course, the point on the sphere's surface is what you pass to glLight(GL_POSITION...)

and remember that opengl is right-handed, so a light wich shine at your right+top+back has a GL_POSITION of 1,1,1 (that's not on a unit sphere, but gl normalizes it afaik)

Dolo/\/\ighty

04-28-2000, 06:34 AM
I am actually doing it software-wise, but was hoping to get an answer which would help in both methods, i am quite the newbie and didnt undertsand much about the second explanation with the sphere(mainly cause i dont use spheres yet+i dont know how to calc it yet), i am pretty sure it was positioned correctly, and i made the light (0,0,1), 1 is into screen in my method, and my object is set infront and behind the 0,0,0 but since it rotates about all axis is assumed that at least at some point it will be completely behind and then get hit by light, by now that i think of it i don't think it actually will...will it?

FATBUDDHA
04-28-2000, 07:17 AM
Is it possible that you've not used glNormal() before you draw your plane?

04-28-2000, 08:34 AM
No i was doing it software-wise, as i said above