Reference specularMaterial()

specularMaterial()

Sets the specular color of shapes’ surface material.

The specularMaterial() color sets the components of light color that glossy coats on shapes will reflect. For example, calling specularMaterial(255, 255, 0) would cause a shape to reflect red and green light, but not blue light.

Unlike ambientMaterial(), specularMaterial() will reflect the full color of light sources including directionalLight(), pointLight(), and spotLight(). This is what gives it shapes their "shiny" appearance. The material’s shininess can be controlled by the shininess() function.

specularMaterial() can be called three ways with different parameters to set the material’s color.

The first way to call specularMaterial() has one parameter, gray. Grayscale values between 0 and 255, as in specularMaterial(50), can be passed to set the material’s color. Higher grayscale values make shapes appear brighter.

The second way to call specularMaterial() has one parameter, color. A p5.Color> object, an array of color values, or a CSS color string, as in specularMaterial('magenta'), can be passed to set the material’s color.

The third way to call specularMaterial() has four parameters, v1, v2, v3, and alpha. alpha is optional. RGBA, HSBA, or HSLA values can be passed to set the material’s colors, as in specularMaterial(255, 0, 0) or specularMaterial(255, 0, 0, 30). Color values will be interpreted using the current colorMode().

Examples

Syntax

specularMaterial(gray, [alpha])
specularMaterial(v1, v2, v3, [alpha])
specularMaterial(color)

Parameters

gray
Number:

grayscale value between 0 (black) and 255 (white).

alpha
Number:

alpha value in the current current colorMode().

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().

color
p5.Color|Number[]|String:

color as a p5.Color object, an array of color values, or a CSS string.

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

Related References