Minor edits
parent
64f930b391
commit
d09158a324
|
@ -33,13 +33,13 @@ var sampler_array: binding_array<sampler>;
|
||||||
|
|
||||||
// INCLUDE: anchor.wgsl
|
// INCLUDE: anchor.wgsl
|
||||||
|
|
||||||
@vertex
|
|
||||||
fn vertex_main(
|
fn transform_vertex(
|
||||||
vertex: VertexInput,
|
|
||||||
instance: InstanceInput,
|
instance: InstanceInput,
|
||||||
) -> VertexOutput {
|
vertex_position: vec3<f32>,
|
||||||
|
texture_index: u32,
|
||||||
|
) -> vec4<f32> {
|
||||||
|
|
||||||
let window_dim = global_data.window_size / global_data.window_scale.x;
|
let window_dim = global_data.window_size / global_data.window_scale.x;
|
||||||
let scale = instance.size / window_dim.y;
|
let scale = instance.size / window_dim.y;
|
||||||
let aspect = (
|
let aspect = (
|
||||||
|
@ -50,8 +50,8 @@ fn vertex_main(
|
||||||
// Apply scale and sprite aspect
|
// Apply scale and sprite aspect
|
||||||
// Note that our mesh starts centered at (0, 0). This is important!
|
// Note that our mesh starts centered at (0, 0). This is important!
|
||||||
var pos: vec2<f32> = vec2(
|
var pos: vec2<f32> = vec2(
|
||||||
vertex.position.x * scale * aspect,
|
vertex_position.x * scale * aspect,
|
||||||
vertex.position.y * scale
|
vertex_position.y * scale
|
||||||
);
|
);
|
||||||
|
|
||||||
// Apply rotation (and adjust sprite angle, since sprites point north)
|
// Apply rotation (and adjust sprite angle, since sprites point north)
|
||||||
|
@ -72,10 +72,27 @@ fn vertex_main(
|
||||||
vec2(instance.size * aspect, instance.size)
|
vec2(instance.size * aspect, instance.size)
|
||||||
);
|
);
|
||||||
|
|
||||||
var out: VertexOutput;
|
return vec4<f32>(pos, 0.0, 1.0);
|
||||||
out.position = vec4<f32>(pos, 1.0, 1.0);
|
}
|
||||||
out.color_transform = instance.color_transform;
|
|
||||||
|
|
||||||
|
@vertex
|
||||||
|
fn vertex_main(
|
||||||
|
vertex: VertexInput,
|
||||||
|
instance: InstanceInput,
|
||||||
|
) -> VertexOutput {
|
||||||
|
|
||||||
|
// TODO: this will break if we try to use texture 0.
|
||||||
|
// implement animations for ui sprites & fix that here.
|
||||||
|
|
||||||
|
let pos = transform_vertex(
|
||||||
|
instance,
|
||||||
|
vertex.position,
|
||||||
|
instance.texture_index.x,
|
||||||
|
);
|
||||||
|
|
||||||
|
var out: VertexOutput;
|
||||||
|
out.position = pos;
|
||||||
|
out.color_transform = instance.color_transform;
|
||||||
|
|
||||||
|
|
||||||
// TODO: function to get texture from sprite
|
// TODO: function to get texture from sprite
|
||||||
|
@ -108,7 +125,6 @@ fn vertex_main(
|
||||||
out.mask_index = vec2(0u, 0u);
|
out.mask_index = vec2(0u, 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue