[Info] Fine tuning lights

  • If you're asking a question make sure to set the thread type to be a question!

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
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
3204603691_a8cc537099_o.jpg


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:
3204603759_13d1a073f6_o.jpg


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:
3204603815_8efeaf4d7f_o.jpg


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:
3205450834_cb2dbc222f_o.jpg

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:
3205451122_4e4f86ff4c_o.jpg


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.
 
Last edited:

Crimson

L3: Member
Nov 25, 2007
119
1
Wow, surprised no comments on this. Excellent job mate, never bothered with them before.
 

Altaco

L420: High Member
Jul 3, 2008
484
120
I remember when I discovered these - my lighting immediately looked nice. Before that I'd always used the falloff distances.