Point Light Source
Ok, I''m trying to create a small point light source, kinda like a fireball or a torch. I can figure out spotlights and ambient world lights, but I can''t do this for some reason.
My idea was to create a light source, give it a position with a w coordinate of 1.0 making it a positional instead of directional source, right? I would give it a cutoff of 180 and a constant attenuation of maybe 3 or 4 so the light would only affect stuff in its immediate vicinity, maybe only 20 units away or something. I''m using a red colored light (setting the ambient, diffuse & specular properties of the light to be {1.0, 0.0, 0.0}). I end up with a light that appears to originating from the camera.
I know, this got answered in that other thread, but over there that guy was trying to create a spotlight, I''m not, and I''m definitely putting my light positioning code after I set up the perspective stuff (which is only called once). Is what I''m describing possible? If so, any idea what I''m doing wrong?
--
Peace,
Capt. Jean-Luc Pikachu
If you were talking about my thread, I wasn''t trying to create a spotlight, but rather a general directional light to light a terrain ( I know, lightmaps are better - but I''m pacing myself ).
My problem came from only setting the light position once, in the initcode, like yourself. It needs to be set after you translate to the current scene position ( via gluLookAt or manually using glLoadMatrix or the rotates/translates ). You will also probably need to push/pop the modelview matrix, as answered in the other thread also.
Thats what solved my problem, and it may solve yours too!
My problem came from only setting the light position once, in the initcode, like yourself. It needs to be set after you translate to the current scene position ( via gluLookAt or manually using glLoadMatrix or the rotates/translates ). You will also probably need to push/pop the modelview matrix, as answered in the other thread also.
Thats what solved my problem, and it may solve yours too!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement