[][src]Static p5_sys::global::lightFalloff

pub static lightFalloff: LightFalloffInternalType

Sets the falloff rates for point lights. It affects only the elements which are created after it in the code. The default value is lightFalloff(1.0, 0.0, 0.0), and the parameters are used to calculate the falloff with the following equation:

d = distance from light position to vertex position

falloff = 1 / (CONSTANT + d * LINEAR + ( d * d ) * QUADRATIC)

Examples

function setup() {
  createCanvas(100, 100, WEBGL);
  noStroke();
}
function draw() {
  background(0);
  let locX = mouseX - width / 2;
  let locY = mouseY - height / 2;
  translate(-25, 0, 0);
  lightFalloff(1, 0, 0);
  pointLight(250, 250, 250, locX, locY, 50);
  sphere(20);
  translate(50, 0, 0);
  lightFalloff(0.9, 0.01, 0);
  pointLight(250, 250, 250, locX, locY, 50);
  sphere(20);
}

Parameters

constant constant value for determining falloff

linear linear value for determining falloff

quadratic quadratic value for determining falloff