From 5dd6a4a4fe43edd8793219a7756c3a34ac38bcfc Mon Sep 17 00:00:00 2001 From: Hepp Maccoy Date: Tue, 7 Feb 2023 12:22:26 -0700 Subject: [PATCH 1/2] Compute Boids: Sprite shader uses color --- src/sample/computeBoids/sprite.wgsl | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/sample/computeBoids/sprite.wgsl b/src/sample/computeBoids/sprite.wgsl index 70e51893..566f18a2 100644 --- a/src/sample/computeBoids/sprite.wgsl +++ b/src/sample/computeBoids/sprite.wgsl @@ -1,18 +1,35 @@ +struct VertexOutput { + @builtin(position) position : vec4, + @location(4) color : vec4, +} + @vertex fn vert_main( @location(0) a_particlePos : vec2, @location(1) a_particleVel : vec2, @location(2) a_pos : vec2 -) -> @builtin(position) vec4 { +) -> VertexOutput { let angle = -atan2(a_particleVel.x, a_particleVel.y); let pos = vec2( (a_pos.x * cos(angle)) - (a_pos.y * sin(angle)), (a_pos.x * sin(angle)) + (a_pos.y * cos(angle)) ); - return vec4(pos + a_particlePos, 0.0, 1.0); + + var output : VertexOutput; + output.position = vec4(pos + a_particlePos, 0.0, 1.0); + output.color = vec4( + 1.0 - sin(angle + 1.0) - a_particleVel.y, + pos.x * 100.0 - a_particleVel.y + 0.1, + a_particleVel.x + cos(angle + 0.5), + 1.0); + return output; } -@fragment -fn frag_main() -> @location(0) vec4 { - return vec4(1.0, 1.0, 1.0, 1.0); +struct FragmentInput { + @location(4) color : vec3, } + +@fragment +fn frag_main(@location(4) color : vec4) -> @location(0) vec4 { + return color; +} \ No newline at end of file From 5689801a2e9798e00b9bf5842457c7435a399bb6 Mon Sep 17 00:00:00 2001 From: Hepp Maccoy Date: Tue, 7 Feb 2023 15:38:44 -0700 Subject: [PATCH 2/2] Remove unused struct --- src/sample/computeBoids/sprite.wgsl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/sample/computeBoids/sprite.wgsl b/src/sample/computeBoids/sprite.wgsl index 566f18a2..c72e9a8f 100644 --- a/src/sample/computeBoids/sprite.wgsl +++ b/src/sample/computeBoids/sprite.wgsl @@ -25,10 +25,6 @@ fn vert_main( return output; } -struct FragmentInput { - @location(4) color : vec3, -} - @fragment fn frag_main(@location(4) color : vec4) -> @location(0) vec4 { return color;