Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: position vector for light source

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2010
    Posts
    20

    position vector for light source

    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

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882

    Re: position vector for light source

    Quote Originally Posted by badass
    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)

    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)
    * Avoiding 16 Common OpenGL Pitfalls

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •