UNPKG

@absulit/points

Version:

A Generative Art library made in WebGPU

48 lines (44 loc) 1.56 kB
/** * The defaultFunctions are functions already incorporated onto the shaders you create, * so you can call them without import. * <br> * <br> * These are wgsl functions, not js functions. * The function is enclosed in a js string constant, * to be appended into the code to reference it in the string shader. * * Use the base example as reference: examples/base/vert.js * @module defaultFunctions */ /** * The defaultVertexBody is used as a drop-in replacement of the vertex shader content. * <br> * This is not required, but useful if you plan to use the default parameters of the library. * <br> * All the examples in the examples directory use this function in their vert.js file. * <br> * <br> * Default function for the Vertex shader that takes charge of automating the * creation of a few variables that are commonly used. * @example * // Inside the main vertex function add this * return defaultVertexBody(in.position, in.color, in.uv, in.normal); * @type {string} * @param {vec4f} position * @param {vec4f} color * @param {vec2f} uv * @return {FragmentIn} */ export const defaultVertexBody = /*wgsl*/` fn defaultVertexBody(position: vec4f, color: vec4f, uv: vec2f, normal: vec3f) -> FragmentIn { var result: FragmentIn; result.ratio = params.ratio; result.position = position; result.color = color; result.uv = uv; result.uvr = uv * params.ratio; result.mouse = params._mouse_normalized; result.normal = normal; return result; } `;