Sets the shader's vertex property or attribute variables.
An vertex property or vertex attribute is a variable belonging to a vertex in a shader. p5.js provides some default properties, such as aPosition
, aNormal
, aVertexColor
, etc. These are set using vertex(), normal() and fill() respectively. Custom properties can also be defined within beginShape() and endShape().
The first parameter, propertyName
, is a string with the property's name. This is the same variable name which should be declared in the shader, such as in vec3 aProperty
, similar to .setUniform()
.
The second parameter, data
, is the value assigned to the shader variable. This value will be applied to subsequent vertices created with vertex(). It can be a Number or an array of numbers, and in the shader program the type can be declared according to the WebGL specification. Common types include float
, vec2
, vec3
, vec4
or matrices.
See also the vertexProperty() method on Geometry objects.
Examples
Syntax
vertexProperty(attributeName, data)