ambient-light

directional-light

light-falloff

light-specularclj

lights

no-lightsclj

point-light

spot-lightclj

ambient-light

Arguments
[red green blue][red green blue x y z]
Docstring

Adds an ambient light. Ambient light doesn't come from a specific direction, the rays of light have bounced around so much that objects are evenly lit from all sides. Ambient lights are almost always used in combination with other types of lights. Lights need to be included in the draw to remain persistent in a looping program. Placing them in the setup of a looping program will cause them to only have an effect the first time through the loop. The effect of the parameters is determined by the current color-mode.

Works only inside sketch functions?
Yes
Original Processing method
ambientLight()
Original p5js method
ambientLight()
Example
(q/background 0)
(q/camera 100 100 100 0 0 0 0 0 1)
(q/ambient-light 200 190 230)
(q/sphere 50)
try example

directional-light

Arguments
[r g b nx ny nz]
Docstring

Adds a directional light. Directional light comes from one direction and is stronger when hitting a surface squarely and weaker if it hits at a gentle angle. After hitting a surface, a directional lights scatters in all directions. Lights need to be included in the draw function to remain persistent in a looping program. Placing them in the setup function of a looping program will cause them to only have an effect the first time through the loop. The affect of the r, g, and b parameters is determined by the current color mode. The nx, ny, and nz parameters specify the direction the light is facing. For example, setting ny to -1 will cause the geometry to be lit from below (the light is facing directly upward).

Works only inside sketch functions?
Yes
Original Processing method
directionalLight()
Original p5js method
directionalLight()
Example
(q/background 0)
(q/camera 100 100 100 0 0 0 0 0 -1)
; use red-ish color with direction [-1, -0.76, -0.5]
(q/directional-light 255 150 150 -1 -0.76 -0.5)
(q/box 50)
try example

light-falloff

Arguments
[constant linear quadratic]
Docstring

Sets the falloff rates for point lights, spot lights, and ambient lights. The parameters are used to determine the falloff with the following equation:

d = distance from light position to vertex position falloff = 1 / (CONSTANT + d * LINEAR + (d*d) * QUADRATIC)

Like fill, it affects only the elements which are created after it in the code. The default value is (light-falloff 1.0 0.0 0.0). Thinking about an ambient light with a falloff can be tricky. It is used, for example, if you wanted a region of your scene to be lit ambiently by one color and another region to be lit ambiently by another color, you would use an ambient light with location and falloff. You can think of it as a point light that doesn't care which direction a surface it is facing.

Works only inside sketch functions?
Yes
Original Processing method
lightFalloff()
Original p5js method
None.
Example
(q/background 0)
(q/camera 100 100 100 0 0 0 0 0 -1)
(q/light-falloff 1 0.008 0)
(q/point-light 255 150 150 100 100 100)
(q/box 50)
try example

light-specularclj

Arguments
[r g b]
Docstring

Sets the specular color for lights. Like fill, it affects only the elements which are created after it in the code. Specular refers to light which bounces off a surface in a preferred direction (rather than bouncing in all directions like a diffuse light) and is used for creating highlights. The specular quality of a light interacts with the specular material qualities set through the specular and shininess functions.

Works only inside sketch functions?
Yes
Original Processing method
lightSpecular()
Original p5js method
None.
Example
clojure specific
  • (q/background 0)
    (q/camera 100 100 100 0 0 0 0 0 -1)
    (q/light-specular 100 100 255)
    (q/directional-light 255 150 150 -1 -0.76 -0.5)
    (q/box 50)

lights

Arguments
[]
Docstring

Sets the default ambient light, directional light, falloff, and specular values. The defaults are:

(ambient-light 128 128 128) (directional-light 128 128 128 0 0 -1) (light-falloff 1 0 0) (light-specular 0 0 0).

Lights need to be included in the draw to remain persistent in a looping program. Placing them in the setup of a looping program will cause them to only have an effect the first time through the loop.

Works only inside sketch functions?
Yes
Original Processing method
lights()
Original p5js method
None.
Example
(q/background 0)
(q/camera 100 100 100 0 0 0 0 0 -1)
(q/lights)
(q/box 50)
try example

no-lightsclj

Arguments
[]
Docstring

Disable all lighting. Lighting is turned off by default and enabled with the lights function. This function can be used to disable lighting so that 2D geometry (which does not require lighting) can be drawn after a set of lighted 3D geometry.

Works only inside sketch functions?
Yes
Original Processing method
noLights()
Original p5js method
None.
Example
clojure specific
  • (q/background 0)
    (q/camera 100 100 100 0 0 0 0 0 -1)
    ; draw box with lights
    (q/directional-light 255 150 150 -1 -0.76 -0.5)
    (q/box 50)
    ; draw sphere without lights
    (q/no-lights)
    (q/translate 0 50 0)
    (q/sphere 20)

point-light

Arguments
[r g b x y z]
Docstring

Adds a point light. Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. The affect of the r, g, and b parameters is determined by the current color-mode. The x, y, and z parameters set the position of the light

Works only inside sketch functions?
Yes
Original Processing method
pointLight()
Original p5js method
pointLight()
Example
(q/background 0)
(q/camera 100 100 100 0 0 0 0 0 -1)
; set light from the same point as camera [100, 100, 100]
(q/point-light 255 150 150 100 100 100)
(q/box 50)
try example

spot-lightclj

Arguments
[r g b x y z nx ny nz angle concentration][[r g b] [x y z] [nx ny nz] angle concentration]
Docstring

Adds a spot light. Lights need to be included in the draw to remain persistent in a looping program. Placing them in the setup of a looping program will cause them to only have an effect the first time through the loop. The affect of the r, g, and b parameters is determined by the current color-mode. The x, y, and z parameters specify the position of the light and nx, ny, nz specify the direction or light. The angle parameter affects the angle of the spotlight cone.

Works only inside sketch functions?
Yes
Original Processing method
spotLight()
Original p5js method
None.
Example
clojure specific
  • (q/background 0)
    (q/camera 100 100 100 0 0 0 0 0 -1)
    ; use two different ways to call spot-light
    ; one light is red and another is blue
    (q/spot-light 255 0 0 50 0 50 -1 0 -1 q/PI 1)
    (q/spot-light [0 0 255] [0 100 100] [0 -1 -1] q/PI 1)
    (q/box 50)