summaryrefslogtreecommitdiff
path: root/render/shaders/sprite.wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'render/shaders/sprite.wgsl')
-rw-r--r--render/shaders/sprite.wgsl16
1 files changed, 2 insertions, 14 deletions
diff --git a/render/shaders/sprite.wgsl b/render/shaders/sprite.wgsl
index 276a8ef..1e7f1a2 100644
--- a/render/shaders/sprite.wgsl
+++ b/render/shaders/sprite.wgsl
@@ -11,42 +11,30 @@ struct InstanceInput {
@location(2) size: vec2<f32>,
@location(3) texture_coordinates: vec2<f32>,
@location(4) texture_size: vec2<f32>,
- @location(5) texture_atlas_index: u32,
- @location(6) rotation: f32,
- @location(7) z_index: f32,
}
struct VertexOutput {
@builtin(position) clip_position: vec4<f32>,
@location(0) texture_coordinates: vec2<f32>,
- @location(1) texture_atlas_index: u32
}
@vertex
fn vs_main(model: VertexInput, instance: InstanceInput) -> VertexOutput {
var out: VertexOutput;
- // rotate the sprite
- let rotation = -instance.rotation;
- let a = vec2<f32>(cos(rotation), sin(rotation));
- let b = vec2<f32>(-a[1], a[0]);
- let rotation_mat = mat2x2<f32>(a, b);
- let rotated = rotation_mat * model.position;
-
// scale the sprite
- let scaled = rotated * instance.size;
+ let scaled = model.position * instance.size;
// move the sprite
let position2d = scaled + instance.position;
// camera stuff
- let position4d = vec4<f32>(position2d, instance.z_index, 1.0);
+ let position4d = vec4<f32>(position2d, 0.0, 1.0);
let position = camera * position4d;
let tex_coords = vec2<f32>(model.position[0] + 0.5, 1.0 - (model.position[1] + 0.5));
out.clip_position = position;
- out.texture_atlas_index = instance.texture_atlas_index;
out.texture_coordinates = tex_coords * instance.texture_size + instance.texture_coordinates;
return out;
}