PDA

View Full Version : position vector for light source



badass
05-23-2010, 01:19 AM
im a bit confused on the parameters for positioning the light source...most of the stuff ive read says light position is defined by a vector...

so i have a terrian from z=-1600 to 800 and y=0 to 700 and x=-400 to 400

if i want to give a sun like lighting effect i position my light at x=0,y=1000,z=-1700 .. but it doesn't seem to work

also any general tips on lighting for terrian would be helpful

thanks
Raza

Dark Photon
05-23-2010, 11:41 AM
im a bit confused on the parameters for positioning the light source...most of the stuff ive read says light position is defined by a vector...
It's a 4D vector. If w=1, then it's a positional light source. If w=0, it's a directional light source. Read this: OpenGL Programming Guide: Chapter 5 (Lighting) (http://glprogramming.com/red/chapter05.html)

If you're new to lighting, start with a directional light source. Fewer parameters to set up and thus fewer ways to get confused.


if i want to give a sun like lighting effect i position my light at x=0,y=1000,z=-1700 .. but it doesn't seem to work
Let's see your code, and possibly a screen shot.

One thing that often trips folks ups is they don't know (or forget) that with the fixed-function pipeline, the light source position is transformed by the MODELVIEW when you set the light source position to determine where it is in eye space.

For more lighting help/tips, see:

* Lights and Shadows (OpenGL.org) (http://www.opengl.org/resources/faq/technical/lights.htm)
* Avoiding 16 Common OpenGL Pitfalls (http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/)