// ShaderToy conversion template for 64k demo project // TODO: Paste ShaderToy mainImage() function below and adapt #include "sequence_uniforms" #include "render/fullscreen_uv_vs" // <- VertexOutput + vs_main // Scene effect: only uniforms (bindings 0,1 unused) // For post-process (input texture needed), add: // @group(0) @binding(0) var smplr: sampler; // @group(0) @binding(1) var txt: texture_2d; @group(0) @binding(2) var uniforms: UniformsSequenceParams; // ============================================================================ // PASTE SHADERTOY CODE HERE // ============================================================================ // ShaderToy → WGSL conversion notes: // // 1. Replace ShaderToy uniforms: // iResolution.xy → uniforms.resolution // iTime → uniforms.time // fragCoord → in.position.xy (pixel coords) or in.uv * uniforms.resolution // fragColor → return value // // 2. Coordinate conversion: // vec2 uv = fragCoord / iResolution.xy; // becomes: // let uv = in.uv; // [0..1], origin top-left // // OR for ShaderToy convention (origin bottom-left): // let uv = vec2f(in.uv.x, 1.0 - in.uv.y); // // 3. Type syntax changes: // float → f32 // vec2/vec3/vec4 → vec2f, vec3f, vec4f // mat2/mat3/mat4 → mat2x2f, mat3x3f, mat4x4f // // 4. Function syntax: // float foo(vec2 p) → fn foo(p: vec2f) -> f32 // // 5. Common functions (mostly same): // mix, sin, cos, length, normalize, dot, cross, fract(), etc. // mod(x, y) → x % y // // 6. Texture sampling (requires bindings 0,1 in C++ and shader): // texture(iChannel0, uv) → textureSample(txt, smplr, uv) // // 7. Variable declarations: // float x = 1.0; → var x: f32 = 1.0; OR let x = 1.0; // const float x = 1.0; → const x: f32 = 1.0; // // 8. Beat / audio: // uniforms.beat_time → absolute musical beats // uniforms.beat_phase → fractional beat [0..1] // uniforms.audio_intensity → audio reactivity // // ============================================================================ @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4f { // TODO: Paste and adapt ShaderToy mainImage() body here // Standard UV (origin top-left, [0..1]) let uv = in.uv; // For ShaderToy convention (origin bottom-left, [-1..1] centered): // let q = vec2f(in.uv.x, 1.0 - in.uv.y); // var coord = q * 2.0 - 1.0; // coord.x *= uniforms.aspect_ratio; // TODO: Your effect code here var col = vec3f(uv.x, uv.y, 0.5); // Optional: Sample previous frame (requires bindings 0,1) // var prev_col = textureSample(txt, smplr, uv); // Optional: Audio reactivity // col *= 1.0 + uniforms.audio_intensity * 0.2; // Optional: Beat sync // col *= 1.0 + uniforms.beat_phase * 0.1; return vec4f(col, 1.0); }