Difference between revisions of "Point Light Attenuation"

From Bakery GPU Lightmapper: Wiki
Jump to navigation Jump to search
(Created page with "In real world, lighting attenuation is governed by [https://en.wikipedia.org/wiki/Inverse-square_law inverse-square law]: File:Falloff ph.png However, in computer graphic...")
 
Line 6: Line 6:
 
There are multiple ways to solve it.
 
There are multiple ways to solve it.
  
* Standard Unity rendering pipeline uses a completely fake falloff curve that looks similar to this:
+
'''Standard Unity rendering pipeline''' uses a completely fake falloff curve that looks similar to this:
 
[[File:Falloff unity.png]]
 
[[File:Falloff unity.png]]
  
 
(r being Light's Range)
 
(r being Light's Range)
 
This is an arbitrary hand-tweaked function. It has a nice property of being exactly 1 in the center, but its falloff is basically always locked and distance-independent. It simply scales the same gradient based on Range parameter. That allowed Unity to even store it inside a texture. A 8-bit texture unfortunately, that also lacks precision and produces visible banding when rendering with gamma correction.
 
This is an arbitrary hand-tweaked function. It has a nice property of being exactly 1 in the center, but its falloff is basically always locked and distance-independent. It simply scales the same gradient based on Range parameter. That allowed Unity to even store it inside a texture. A 8-bit texture unfortunately, that also lacks precision and produces visible banding when rendering with gamma correction.

Revision as of 22:18, 29 May 2019

In real world, lighting attenuation is governed by inverse-square law: Falloff ph.png

However, in computer graphics things are a little trickier. Inverse-square law works for real lights because they have area, hence the projection of this area on receiver geometry gets exponentially smaller with distance. Point lights are an approximation and using the law on them produces one obvious problem: as distance approaches zero, lighting intensity approaches infinity.

There are multiple ways to solve it.

Standard Unity rendering pipeline uses a completely fake falloff curve that looks similar to this: Falloff unity.png

(r being Light's Range) This is an arbitrary hand-tweaked function. It has a nice property of being exactly 1 in the center, but its falloff is basically always locked and distance-independent. It simply scales the same gradient based on Range parameter. That allowed Unity to even store it inside a texture. A 8-bit texture unfortunately, that also lacks precision and produces visible banding when rendering with gamma correction.