Results 1 to 5 of 5

Thread: faraway lights

  1. #1
    Member Contributor
    Join Date
    Jan 2001
    Posts
    55

    faraway lights

    hi, i have a question about spotlights...my spotlights work well when they are positioned close to the objects that are being illuminated. but if i move the light to a realistic position in relation to the objects, they are barely illuminated. the lights are turned up to maxium strength. so if i am drawing a scene that is "to scale", is there a mulitplier or material setting that will brighten up these lights?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: faraway lights

    You can set the damp-coefficients.

    d = 1/ (kc + kl*r + kq*r^2)

    r is the distance
    kc is the constant weight
    kl is the linear weight
    kq is the quadratic weight

    If d gets one, you've got full brightness, if its 0, you've serious darkness, since:

    Illum(lit surface) ~ d*Illum(light)

    The coefficients get defined like this:

    kc -> glLightf( GL_LIGHTx GL_CONSTANT_ATTENUATION, kc );

    kl and kq respecitvely with GL_LINEAR_ATTENUATION and GL_QUADRATIC_ATTENUTATION

  3. #3
    Member Contributor
    Join Date
    Jan 2001
    Posts
    55

    Re: faraway lights

    michael,
    thank you for your important reply. but i'm not an optics engineer... ummm, could you please explain what the quadratic weight, the linear weight, and the constant weight are (or at least how they affect a light). thanks a lot!

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: faraway lights

    The constants is used to calculate how the light is fading when you get far away from the lightsource.

    The default in OpenGL is kc=1, kl=0 and kq=0
    r is the distance from the lightsource.

    Stuffing these values into the forula Michael mentioned, you will see that only kl and kq is multiplied with r, and since these two constants is zero, the distance has no affect to the light.

    The constant weight is a constant damping factor, which affects the whole scene. If kc=2, then d=1/2=0.5, which means that the light will be half as bright over the entire scene. As kc grows bigger, d grows smaller.

    kl is a linear damping factor. It is multiplied by the distance to the vertex being lit. As the distance grows, the total dampingfactor will grow, and d will be less and less the further away you get from the light. And the lower d is, the less light will reach the vertex.

    kq is the same as kl, but is affected by the squared distance. The further away you get from the light, the damping factor will grow even more.

  5. #5
    Member Contributor
    Join Date
    Jan 2001
    Posts
    55

    Re: faraway lights

    thanks for explaining this, bob, your explanation is helpful

Similar Threads

  1. Speed of built in lights v.s. custom lights
    By STTrife in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-23-2013, 05:11 PM
  2. Lights anyone?!
    By TBoNe in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-14-2003, 08:04 AM
  3. Is 4 lights too many ?
    By Andrew Jameson in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-10-2002, 05:37 AM
  4. Lights
    By goater in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-11-2001, 07:22 AM
  5. Replies: 13
    Last Post: 11-29-2000, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean