Reference getWorldInputs()

getWorldInputs()

Registers a callback to modify the world-space properties of each vertex in a shader. This hook can be used inside baseColorShader().modify() and similar shader modify() calls to customize vertex positions, normals, texture coordinates, and colors before rendering. "World space" refers to the coordinate system of the 3D scene, before any camera or projection transformations are applied.

The callback receives a vertex object with the following properties:

  • position: a three-component vector representing the original position of the vertex.
  • normal: a three-component vector representing the direction the surface is facing.
  • texCoord: a two-component vector representing the texture coordinates.
  • color: a four-component vector representing the color of the vertex (red, green, blue, alpha).

This hook is available in:

Examples

Syntax

getWorldInputs(callback)

Parameters

callback
Function: A callback function which receives a vertex object containing position (vec3), normal (vec3), texCoord (vec2), and color (vec4) properties. The function should return the modified vertex object.
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