Reference combineColors()

combineColors()

Registers a callback to customize how color components are combined in the fragment shader. This hook can be used inside baseMaterialShader().modify() and similar shader modify() calls to control the final color output of a material. The callback receives an object with the following properties:

  • baseColor: a three-component vector representing the base color (red, green, blue).
  • diffuse: a single number representing the diffuse reflection.
  • ambientColor: a three-component vector representing the ambient color.
  • ambient: a single number representing the ambient reflection.
  • specularColor: a three-component vector representing the specular color.
  • specular: a single number representing the specular reflection.
  • emissive: a three-component vector representing the emissive color.
  • opacity: a single number representing the opacity.

The callback should return a vector with four components (red, green, blue, alpha) for the final color.

This hook is available in:

Examples

Syntax

combineColors(callback)

Parameters

callback
Function: A callback function which receives the object described above and returns a vector with four components for the final color.
Notice any errors or typos? Please let us know. Please feel free to edit src/strands/p5.strands.js and open a pull request!

Related References