p5.js | lightFalloff() Function
The lightFalloff() function in p5.js is used to set the falloff for point lights in the scene. Light falloff means the reduction of illumination with the distance of the object from the point light. It only affects elements that are created after it. The following equation is used to calculate the falloff:
falloff = 1 / (CONSTANT + d * LINEAR + ( d * d ) * QUADRATIC)
Where d is the distance from the light position to the vertex position. The default value of the function is lightFalloff(1.0, 0.0, 0.0).
lightFalloff( constant, linear, quadratic )
Parameters: This function accept three parameters as mentioned above and described below:
- constant: It is a number which denotes the constant value in the falloff equation.
- linear: It is a number which denotes the linear value in the falloff equation.
- quadratic: It is a number which denotes the quadratic value in the falloff equation.
Below example illustrates the lightFalloff() function in p5.js:
Online editor: https://editor.p5js.org/