@absulit/points
Version:
A Generative Art library made in WebGPU
26 lines (23 loc) • 1.06 kB
JavaScript
/* @ts-self-types="./debug.d.ts" */
const showDebugCross=`
fn showDebugCross(position:vec2f, color:vec4f, uv:vec2f) -> vec4f{
let horizontal = sdfLine(vec2(0, position.y), vec2(10, position.y), 1., uv) * color;
let vertical = sdfLine(vec2(position.x, 0), vec2(position.x, 10), 1., uv) * color;
return vertical + horizontal;
}
`;const showDebugFrame=`
fn showDebugFrame(color:vec4f, uv:vec2f) -> vec4f {
let ratioX = params.screen.x / params.screen.y;
let ratioY = 1. / ratioX / (params.screen.y / params.screen.x);
let ratio = vec2(ratioX, ratioY);
let topRight = vec2(1., 1.) * ratio;
let topLeft = vec2(0., 1.);
let bottomLeft = vec2(0., 0.);
let bottomRight = vec2(1., 0.) * ratio;
let top = sdfLine(topLeft, topRight, 1., uv) * color;
let bottom = sdfLine(bottomLeft, bottomRight, 1., uv) * color;
let left = sdfLine(bottomLeft, topLeft, 1., uv) * color;
let right = sdfLine(bottomRight, topRight, 1., uv) * color;
return top + bottom + left + right;
}
`;export{showDebugCross,showDebugFrame};