WGSL shader code excerpt
Optionaltype: stringdefaults to "shapes"
Optionaldata: {} | Float32Array<ArrayBufferLike>only for use with fully custom shaders
a shader program
fn vertexMain(v: VertexParams) -> FragParams { var vert = transformVertex(v.pos, v.matrixIndex);
let i = f32(v.vertexIndex) % 4 * 100; vert.x += cos((q.time + i) * 0.01) * 0.1;
var f: FragParams;
f.position = vert;
f.color = vec4f(1, 0, 0, 1);
return f;
}`);
q5.draw = function () { clear(); shader(wobble); plane(0, 0, 100); };
⚡ Creates a shader that q5's WebGPU renderer can use.
If
typeis not specified, this function customizes a copy of the default shapes shader, which affects these functions:plane,line, andendShape.For more information on the vertex and fragment function input parameters, data, and helper functions made available for use in your custom shader code, read the "Custom Shaders in q5 WebGPU" wiki page.