summaryrefslogtreecommitdiff
path: root/src/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader')
-rw-r--r--src/shader/particle.wgsl9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/shader/particle.wgsl b/src/shader/particle.wgsl
index 704cfbe..3dd61a9 100644
--- a/src/shader/particle.wgsl
+++ b/src/shader/particle.wgsl
@@ -6,6 +6,7 @@ struct Camera {
struct Particle {
position: vec2f,
data: u32,
+ life: f32,
};
@group(0) @binding(0) var<uniform> camera: Camera;
@@ -16,6 +17,8 @@ struct VertexOutput {
@builtin(position) clip_position: vec4<f32>,
@location(0) world: vec2<f32>,
@location(1) @interpolate(flat) instance: u32,
+ @location(2) @interpolate(flat) material: u32,
+ @location(3) @interpolate(flat) life: f32,
};
@vertex
@@ -33,6 +36,8 @@ fn vs_main(
out.clip_position = vec4f((world - camera.centre) * camera.scale, 0.0, 1.0);
out.world = world;
out.instance = n;
+ out.material = particle.data & 0xFF;
+ out.life = particle.life;
return out;
}
@@ -41,6 +46,6 @@ fn vs_main(
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
let particle = particles[in.instance];
// TODO can pack more in here and shift
- let c = palette[particle.data];
- return c;
+ let c = palette[in.material];
+ return vec4<f32>(c.r, c.g, c.b, c.a * smoothstep(0.0, 1, in.life));
}