summaryrefslogtreecommitdiffstats
path: root/wgpu/src/shader/image.wgsl
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-01-19 20:54:09 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-19 20:54:09 +0100
commitb3e3f6e3c9fc6879e6681810f54d7eaa7c0f3d30 (patch)
treeef1a846a756fadce7df07732538192ee4f4ce6cf /wgpu/src/shader/image.wgsl
parent7ae7fcb89855002519bab752fd3686106ce448db (diff)
parent0c7f6e4b34391c709aa4c333c4a9cc10e607f6c4 (diff)
downloadiced-b3e3f6e3c9fc6879e6681810f54d7eaa7c0f3d30.tar.gz
iced-b3e3f6e3c9fc6879e6681810f54d7eaa7c0f3d30.tar.bz2
iced-b3e3f6e3c9fc6879e6681810f54d7eaa7c0f3d30.zip
Merge pull request #2099 from jim-ec/master
Compute vertex positions in the shader
Diffstat (limited to 'wgpu/src/shader/image.wgsl')
-rw-r--r--wgpu/src/shader/image.wgsl18
1 files changed, 10 insertions, 8 deletions
diff --git a/wgpu/src/shader/image.wgsl b/wgpu/src/shader/image.wgsl
index 5e22cdf4..7b2e5238 100644
--- a/wgpu/src/shader/image.wgsl
+++ b/wgpu/src/shader/image.wgsl
@@ -7,12 +7,12 @@ struct Globals {
@group(1) @binding(0) var u_texture: texture_2d_array<f32>;
struct VertexInput {
- @location(0) v_pos: vec2<f32>,
- @location(1) pos: vec2<f32>,
- @location(2) scale: vec2<f32>,
- @location(3) atlas_pos: vec2<f32>,
- @location(4) atlas_scale: vec2<f32>,
- @location(5) layer: i32,
+ @builtin(vertex_index) vertex_index: u32,
+ @location(0) pos: vec2<f32>,
+ @location(1) scale: vec2<f32>,
+ @location(2) atlas_pos: vec2<f32>,
+ @location(3) atlas_scale: vec2<f32>,
+ @location(4) layer: i32,
}
struct VertexOutput {
@@ -25,7 +25,9 @@ struct VertexOutput {
fn vs_main(input: VertexInput) -> VertexOutput {
var out: VertexOutput;
- out.uv = vec2<f32>(input.v_pos * input.atlas_scale + input.atlas_pos);
+ let v_pos = vertex_position(input.vertex_index);
+
+ out.uv = vec2<f32>(v_pos * input.atlas_scale + input.atlas_pos);
out.layer = f32(input.layer);
var transform: mat4x4<f32> = mat4x4<f32>(
@@ -35,7 +37,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
vec4<f32>(input.pos, 0.0, 1.0)
);
- out.position = globals.transform * transform * vec4<f32>(input.v_pos, 0.0, 1.0);
+ out.position = globals.transform * transform * vec4<f32>(v_pos, 0.0, 1.0);
return out;
}