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, as in in vec3 aProperty
, similar to .setUniform()
.
The second parameter, data
, is the value assigned to the shader variable. This value will be pushed directly onto the Geometry object. There should be the same number of custom property values as vertices, this method should be invoked once for each vertex.
The data
can be a Number or an array of numbers. Tn 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 global vertexProperty() function.
Examples
Syntax
vertexProperty(propertyName, data, [size])