Ideas and suggestions needed for Improving p5.js WebGL mode in GSOC 2019

spotLight(v1, v2, v3, x, y, z, nx, ny, nz, angle, concentration)-
We can understand this by taking the example of the torch. It is essentially an extension of pointlight() while also considering the opening of the torch, the direction of the torch, and torch’s strength.

Arguments -

  1. The torch’s light has a color, depicted by the three RGB values v1,v2,v3 or we can pass p5.color object.
  2. The position of the torch, whereas x,y,z being the coordinates of the position, a p5.vector can also be used.
  3. The direction of the light emitted by the torch, with nx, ny, nz being the coefficient for a normalized vector describing the direction of the light, and p5.vector can also be used here.
  4. The width of the opening of the torch, which basically resembles a cone, here is measured by the solid angle angle. It will be a number.
  5. The strength of the torch, used here as concentration. The higher value of concentration will let you concentrate the light in the middle more.

Also, I am thinking of making the angle and concentration arguments as optional, and setting them to some default value when not supplied by the user.

Advantages and Motivation-

  • The spotlight is very useful in creating a lot of lighting effects, and can be heavily used by the community when introduced.
  • Although, it is not a fundamental lighting method used in WebGL, It is still very different from the other existing lighting methods present in p5.

Implementation-
Currently, I don’t think any previous methods defined in p5.src needs to be changed, but the light shader and phong shader will have to be changed to incorporate the solid angle and concentration.