Reference specularColor()

specularColor()

Sets the specular color for lights.

specularColor() affects lights that bounce off a surface in a preferred direction. These lights include directionalLight(), pointLight(), and spotLight(). The function helps to create highlights on p5.Geometry objects that are styled with specularMaterial(). If a geometry does not use specularMaterial(), then specularColor() will have no effect.

Note: specularColor() doesn’t affect lights that bounce in all directions, including ambientLight() and imageLight().

There are three ways to call specularColor() with optional parameters to set the specular highlight color.

The first way to call specularColor() has two optional parameters, gray and alpha. Grayscale and alpha values between 0 and 255, as in specularColor(50) or specularColor(50, 80), can be passed to set the specular highlight color.

The second way to call specularColor() has one optional parameter, color. A p5.Color object, an array of color values, or a CSS color string can be passed to set the specular highlight color.

The third way to call specularColor() has four optional parameters, v1, v2, v3, and alpha. RGBA, HSBA, or HSLA values, as in specularColor(255, 0, 0, 80), can be passed to set the specular highlight color. Color values will be interpreted using the current colorMode().

Examples

Syntax

specularColor(v1, v2, v3)
specularColor(gray)
specularColor(value)
specularColor(values)
specularColor(color)

Parameters

v1
Number:

red or hue value in the current colorMode().

v2
Number:

green or saturation value in the current colorMode().

v3
Number:

blue, brightness, or lightness value in the current colorMode().

gray
Number:

grayscale value between 0 and 255.

value
String:

color as a CSS string.

values
Number[]:

color as an array of RGBA, HSBA, or HSLA values.

color
p5.Color:

color as a p5.Color object.

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/light.js and open a pull request!

Related References