[Info] Fine tuning lights

Discussion in 'Mapping Questions & Discussion' started by YM, Jan 17, 2009.

  1. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,741
    Ever wondered what those three keyvalues you've never touched in your lights are??
    Constant linear and quadratic? what could those possibly mean?

    Well I aim to clear this up a bit.
    I'll start by explaining a little about light in the real world. If you have a point light source (like a lightbulb or candle flame) the intensity depends on your distance from it. If you get closer it gets stronger and if you're further away its weaker - just like gravity or electric fields.

    Lets put some numbers into this. If you're one meter away from a light and the intensity is say X, if you take a big step back so that your distance has doubled the intensity drops to 1/4 X. So double distance quarters the intensity. An inverse square law.

    All light behaves in this way. However when you apply the proper light equations to 3D models inside computers they don't really work so well, you end up with extreme light near the source and barely any further from it. When you place your lights in the source engine they default to using a quadratic equation to work out how they cast light. I don't know if this quadratic is exactly in line with the real world equation or if its been tweaked slightly but either way it produces bright spots if you put it near a wall and after a few meters it fades quite a lot.
    Here is what you might expect for a standard light_spot set to 1200
    [​IMG]

    Ok so that doesn't look so good, well lets see what the other two ones do. The middle keyvalue is 'linear' this means that if you're standing one meter away and intensity is X and you step another meter away inensity drops to 1/2 X. That is double one, half the other. This produces a much longer fade distance and less of a bright spot right next to the light.
    Like this:
    [​IMG]

    The final one is 'constant' and I bet you've worked out what I'll say about this one. This one means the light never decays, it's intensity is 1200 an inch from the source and 1200 a mile from the source. This doesn't make any bright spots but does look a little unnatural
    Something like this:
    [​IMG]

    Thanks Youme, that's cleared those few up a lot I hear you say....what? there’s more?

    Yup.
    These options aren’t an either/or type option, you can use all three in equal proportions or 50/50 of just two or 80/20 of another two. Its up to you to decide which ones and how much of them you use. Its just a matter of ratios.

    Here's one I'd use for that particular light, 70% quadratic and 30% linear:
    [​IMG]
    Its slightly brighter and the bright spot is slightly less intense, but not by much. Just the way I want my lights to look.

    So how do you implement these ratios? Well you simply set each's keyvalue to the proportion of each you want to use, so for my 70/30 ratio I use:
    Constant | 3
    Linear | 0
    Quadratic | 7
    (all add to make 10)

    But I could have done this:
    Constant | .3
    Linear | 0
    Quadratic | .7
    (all add to make 1)

    Or if you wanted 85% linear, 5% constant and 10% quadratic (you'd never want anything that complex but this is just an example)
    Constant | 5
    Linear | 85
    Quadratic | 10
    (all add to make 100)

    Actually you don't have to make them add up to any nice round number, you can make them add up to anything, its just the ratio that matters. I however keep them adding up to 10 for ease of use.

    Here’s how 50/50 constant/quadratic looks in hammer:
    [​IMG]

    So there you have it, three more keyvalues demystified, they're not too exciting but at least you now have the understanding to fiddle with them if you want to.
     
    • Thanks Thanks x 33
    Last edited: Jan 17, 2009
  2. Crimson

    Crimson L3: Member

    Messages:
    119
    Positive Ratings:
    1
    Wow, surprised no comments on this. Excellent job mate, never bothered with them before.
     
  3. Altaco

    Altaco L7: Fancy Member

    Messages:
    485
    Positive Ratings:
    121
    I remember when I discovered these - my lighting immediately looked nice. Before that I'd always used the falloff distances.
     
  4. Sgt Frag

    Sgt Frag L14: Epic Member

    Messages:
    1,443
    Positive Ratings:
    294
    Never saw this til now. Great guide though. Now I gotta tweak lights more :(
     
  5. zpqrei

    aa zpqrei Theme Changer Extraordinaire

    Messages:
    1,066
    Positive Ratings:
    1,122
    Wow, thanks. This really has helped me with my lighting!

    +Thanks