Reference getPixelInputs()

getPixelInputs()

Registers a callback to modify the properties of each fragment (pixel) before the final color is calculated in the fragment shader. This hook can be used inside baseMaterialShader().modify() and similar shader modify() calls to adjust per-pixel data before lighting/mixing.

The callback receives an Inputs object. Available fields depend on the shader:

  • In baseMaterialShader():

    • normal: a three-component vector representing the surface normal.
    • texCoord: a two-component vector representing the texture coordinates (u, v).
    • ambientLight: a three-component vector representing the ambient light color.
    • ambientMaterial: a three-component vector representing the material's ambient color.
    • specularMaterial: a three-component vector representing the material's specular color.
    • emissiveMaterial: a three-component vector representing the material's emissive color.
    • color: a four-component vector representing the base color (red, green, blue, alpha).
    • shininess: a number controlling specular highlights.
    • metalness: a number controlling the metalness factor.
  • In baseStrokeShader():

    • color: a four-component vector representing the stroke color (red, green, blue, alpha).
    • tangent: a two-component vector representing the stroke tangent.
    • center: a two-component vector representing the cap/join center.
    • position: a two-component vector representing the current fragment position.
    • strokeWeight: a number representing the stroke weight in pixels.

Return the modified object to update the fragment.

This hook is available in:

Examples

Syntax

getPixelInputs(callback)

Parameters

callback
Function: A callback function which receives the fragment inputs object and should return it after making any changes.
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