# Difference between revisions of "Constant-Linear-Quadratic Falloff"

m |
MossyBucket (talk | contribs) m (Anchient typo.) |
||

Line 16: | Line 16: | ||

The 100% constant attenuation will result in a light that has no attenuation at all. The intensity, represented by the brigtness setting of the light entity, will be totally unaffected by distance, continuing until it hits a surface, theoretically capable of illuminating an infinite area. | The 100% constant attenuation will result in a light that has no attenuation at all. The intensity, represented by the brigtness setting of the light entity, will be totally unaffected by distance, continuing until it hits a surface, theoretically capable of illuminating an infinite area. | ||

− | This type of light can be seen from the sky (sunlight, | + | This type of light can be seen from the sky (sunlight, moonlight and starlight), and other large and distant light sources. It can also be used for setting local ambient lighting (by letting it illuminate the shadows of the room) or mood lighting. |

As a 100% constant lightsource is an extreme type of light, constant light is mostly used in combination with the other two types of attenuations, to "soften" or limit them. | As a 100% constant lightsource is an extreme type of light, constant light is mostly used in combination with the other two types of attenuations, to "soften" or limit them. |

## Revision as of 06:50, 9 February 2011

## Contents

### Introduction

While light travels from its source, it usually diminishes in intensity, limiting the area that its source can illuminate. This diminishing is called "light attenuation" or "fall-off".

The attenuation of a normal, unmodified light entity is preset to be 100% quadratic. While this is typical real world attenuation (accordng to inverse-square law), this rate is often too fast for virtual environments, creating unnatural glares on nearby textures (like the ceiling).

The Constant-Linear-Quadratic system is an old system for adjusting how a light attenuates (or "falls off"). It has since been superseded by the two "percent falloff distance" keyvalues, which some may find easier to understand and handle.

The ratio between the three keyvalues *Constant* (*_constant_attn*), *Linear* (*_linear_attn*) and *Quadratic* (*_quadratic_attn*) will determine the way in which the light attenuates. (The three values has gotten their names from the mathematical function used to describe the decline of its intensity.)

### Constant Attenuation

The picture on the right shows a lightsource displaying the simplest of attenuations: Constant attenuation. The keyvalues *Constant*, *Linear* and *Quadratic* have here been set to "1", "0" and "0" respectively, creating a Constant-Linear-Quadratic ratio of 1:0:0, meaning that the attenuation is 100% Constant, 0% Linear, and 0% Quadratic.

The 100% constant attenuation will result in a light that has no attenuation at all. The intensity, represented by the brigtness setting of the light entity, will be totally unaffected by distance, continuing until it hits a surface, theoretically capable of illuminating an infinite area. This type of light can be seen from the sky (sunlight, moonlight and starlight), and other large and distant light sources. It can also be used for setting local ambient lighting (by letting it illuminate the shadows of the room) or mood lighting.

As a 100% constant lightsource is an extreme type of light, constant light is mostly used in combination with the other two types of attenuations, to "soften" or limit them.

### Linear Attenuation

This is the same light entity, but at a 0:1:0 ratio, making its lighting 100% linear instead.

Mathematically, the decline of this type of light is linear, inversely proportial to the distance from the light source (I = 1/d where I is intensity and d is distance). This means that the light intensity (set by its brightness) will diminish (at a fixed rate) as it travels from its source. To compensate for this decline, Valve has boosted the intensity of the lightsource to 100 times its brightness.

In the *real* world a 100% linear lightsource would be practically impossible, as it would represent a real world soft light of *infinite* size, but in the *virtual* world, a 0:1:0 lightsource is believable for most entity based lightsources.

### Quadratic Attenuation

This is a normal, unmodified light source, preset to 0:0:1, making it 100% Quadratic.

Mathematically, the attenuation of a 100% quadratic light is exponential (quadratic), expressed as "I = 1/d^2", meaning that the further the light travels from its source, the *more* it will be diminished. This creates a very sharp drop in light. To compensate for the fast decline of quadratic lights, Valve has boosted the intensity of them to be 100^2 (10 000) times more intense than the actual intensity.

An unmodified (100% quadratic) lightsource represents a pure "point light source" in the real world. In the virtual world, this effect looks like a lightsource shining through murky water, looking far from typical real world lightsource behavior.

When used in moderation, quadratic attenuation can be used not only for small lightsources, but also to reflect light travelling through something more dispersing than air, like air humidity (like fog) or water.

### Mixing Attenuation

When blending between these three types of attenuation, you set the proportions of each attenuation type against the other two types. To avoid confusion, keep in mind that you can set the scale of these proportions as you wish: A proportion of 3:6:1 gives the exact same result as 6:12:2, or 30:60:10, which can easily be translated to 30%, 60% and 10%.

### Constant-Linear-Quadratic vs. 50%-0% falloff

As mentioned above, when lights are attenuated using Constant-Linear-Quadratic settings, the light's intensity can be scaled up as much by as 10,000. While such high values cannot be displayed using LDR, [HDR] lighting with bloom will make a light of moderate intensity appear blindingly white. This scaling does not occur when 50 percent falloff distance and 0 percent falloff distance are defined.

A real-world point light will fall off following the inverse-square law(plus some linear attenuation due to atmospheric scattering). To find a suitable 50% falloff distance, one could use the following equation:

I/2 = I/d^2 d = sqrt(2)

In other words, The intensity of the light reaches 50% when the distance from the light reaches the square root of 2, or 1.14.

0% falloff is actually the point at which the light reaches 1/256 brightness, which vrad.exe considers negligible. So that point can be found as so:

1/256 = I/d^2 d = sqrt(I)*16

Again in English, the light "runs out" at 16 times the square root of the light's original intensity.

What is missing here are units to go with these numbers. Clearly 1.14 Source units is much too soon for a light to drop by 50%, and a light of 100 brightness should reach much farther than 160 units. Some experimentation in a test map indicates that a 50% falloff distance of 10 looks good, which corresponds to sqrt(I)*113. That could easily be rounded to sqrt(I)*100 for simplicity's sake (and to account for that atmospheric scattering mentioned above). With this equation a light with a brightness of 100 would reach 1000 units before ceasing to exist.

If more accurate or better-looking values are found for this, they should be posted here!