Skip to content

Commit

Permalink
ping pong
Browse files Browse the repository at this point in the history
  • Loading branch information
arcadeperfect committed Dec 4, 2024
1 parent 5fd4d73 commit d0dedab
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 71 deletions.
7 changes: 5 additions & 2 deletions assets/shaders/generate_circle.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ struct Params {
noise_scale: f32,
noise_amplitude: f32,
}
// @group(0) @binding(0) var<uniform> params: Params;
// @group(0) @binding(1) var texture: texture_storage_2d<rgba32float, write>;
@group(0) @binding(0) var<uniform> params: Params;
@group(0) @binding(1) var texture: texture_storage_2d<rgba32float, write>;
@group(0) @binding(2) var output_texture: texture_storage_2d<rgba32float, write>;


// Changed to 8x8 workgroup size - better for most GPUs
@compute @workgroup_size(8, 8)
Expand Down Expand Up @@ -100,7 +103,7 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
pos = vec2f(mag, 0.0);
let edge = vec2f(r, 0.0);

textureStore(texture, upos, vec4<f32>(v , dist, distance(pos, edge), 1.));
textureStore(output_texture, upos, vec4<f32>(v , dist, distance(pos, edge), 1.));

}

19 changes: 19 additions & 0 deletions assets/shaders/second_pass.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
struct Params {
dimensions: u32,
radius: f32,
noise_seed: u32,
noise_scale: f32,
noise_amplitude: f32,
}

@group(0) @binding(0) var<uniform> params: Params;
@group(0) @binding(1) var input_texture: texture_storage_2d<rgba32float, read>;
@group(0) @binding(2) var output_texture: texture_storage_2d<rgba32float, write>;

@compute @workgroup_size(8, 8)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>){
let upos = vec2<i32>(i32(global_id.x), i32(global_id.y));
let value = textureLoad(input_texture, upos);
textureStore(output_texture, upos, vec4<f32>(1.0 - value.x, 1.0 - value.y, 1.0 - value.z, value.w));
}

Loading

0 comments on commit d0dedab

Please sign in to comment.