Skip to content

p5Shader - Is there a way to specify custom attributes? #5120

Closed
@JetStarBlues

Description

@JetStarBlues

How would this new feature help increase access to p5.js?

Potential to expand capability of p5's WebGL mode.

Most appropriate sub-area of p5.js?

  • WebGL

Feature enhancement details:

Is there a way to specify custom attributes when working with shaders?

From what I've gathered from this contributor_doc, these are the available attributes (let me know if this assumption is incorrect):

  • attribute vec3 aPosition
  • attribute vec3 aNormal
  • attribute vec2 aTexCoord
  • attribute vec4 aDirection
  • attribute vec4 aVertexColor

Suppose I want to pass some custom attributes to a shader. (For example, I want to specify a cube (or other custom geometry such as a 3D model or something generated dynamically) by passing in some vertices as one attribute, and some vertex colors as another attribute). How can I go about this? Is there a setAttribute equivalent to setUniform? If not, is there a way to do this using private p5 methods?


Sidenote:
It would be great if the shader documentation on p5js.org/reference was a bit more fleshed out. For example:

  • list all available attributes, and give a brief explanation of how they are generated
  • give an example of how to use each attribute. (For example the use of beginShape and endShape to specify custom geometry (aPostion), and vertex colors (aVertexColor) (as seen here Enabling lights() in WEBGL breaks vertex colors.  #4274))

Related issues:

Metadata

Metadata

Type

No type

Projects

Status

System Level Changes

Status

Completed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions