diff options
author | 2023-09-24 15:24:08 +0200 | |
---|---|---|
committer | 2023-09-24 15:24:08 +0200 | |
commit | 5fb877ab5984dd1c4a3f3dcccf87103393da4e0c (patch) | |
tree | efb995792bf06a33ab3c7910824dab707e9e489c /wgpu/src/shader/image.wgsl | |
parent | e197abe0aae659742532ff2e2985afc97f041d2a (diff) | |
download | iced-5fb877ab5984dd1c4a3f3dcccf87103393da4e0c.tar.gz iced-5fb877ab5984dd1c4a3f3dcccf87103393da4e0c.tar.bz2 iced-5fb877ab5984dd1c4a3f3dcccf87103393da4e0c.zip |
Compute vertex position for image shader
Diffstat (limited to 'wgpu/src/shader/image.wgsl')
-rw-r--r-- | wgpu/src/shader/image.wgsl | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/wgpu/src/shader/image.wgsl b/wgpu/src/shader/image.wgsl index 5e22cdf4..0c8b3bdb 100644 --- a/wgpu/src/shader/image.wgsl +++ b/wgpu/src/shader/image.wgsl @@ -7,7 +7,7 @@ struct Globals { @group(1) @binding(0) var u_texture: texture_2d_array<f32>; struct VertexInput { - @location(0) v_pos: vec2<f32>, + @builtin(vertex_index) vertex_index: u32, @location(1) pos: vec2<f32>, @location(2) scale: vec2<f32>, @location(3) atlas_pos: vec2<f32>, @@ -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; } |