Skip to content

q5-webgpu: User defined uniform data #105

Open
@quinton-ashley

Description

@quinton-ashley

Support user defined uniform data in custom shaders.

https://p5js.org/reference/p5.Shader/setUniform/

In p5, setting uniform data is typically a necessity, as p5 doesn't provide any instance data such as width, height, mouseX, etc.

q5 does provide uniform data about the q5 instance by default though. So in q5, shader.setUniform would just be for custom data that users want to feed into the shader each frame. Pretty advanced stuff.

If q5 were to support this, I think the assumption would be the user's data is just f32 floats. q5 would make a struct for the data behind the scenes. It'd be put in a buffer each frame just like q5's default uniform data.

In q5, it'd be nice for users to be able to set uniform data in a JS object when they apply a shader, instead of having to use setUniform multiple times.

shader(myCustomShader, {
  myUniform0: 1000,
  myUniform1: 2000
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Maybe

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions