@absulit/points
Version:
A Generative Art library made in WebGPU
34 lines (25 loc) • 881 B
JavaScript
import { texturePosition } from '../../image.js';
import { rand } from '../../random.js';
import { snoise } from './../../noise2d.js';
const frag = /*wgsl*/`
${texturePosition}
${rand}
${snoise}
fn main(
color: vec4f,
uv: vec2f,
ratio: vec2f, // relation between params.screen.x and params.screen.y
uvr: vec2f, // uv with aspect ratio corrected
mouse: vec2f,
position: vec4f
) -> vec4f {
let imageColor = texturePosition(renderpass_feedbackTexture, renderpass_feedbackSampler, vec2(0., 0), uvr, true);
rand_seed = uvr + params.time;
var noise = rand();
noise = noise * .5 + .5;
let finalColor = (imageColor + imageColor * noise) * .5;
return finalColor;
}
`;
export default frag;