Snap clip_bounds in image shader
This commit is contained in:
parent
bed9657ec2
commit
e665afd9eb
1 changed files with 5 additions and 1 deletions
|
|
@ -76,6 +76,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
|
||||||
// Calculate the vertex position
|
// Calculate the vertex position
|
||||||
let v_pos = clipped_tile.xy + corner * clipped_tile.zw;
|
let v_pos = clipped_tile.xy + corner * clipped_tile.zw;
|
||||||
out.position = vec4(vec2(globals.scale_factor), 1.0, 1.0) * vec4<f32>(v_pos, 0.0, 1.0);
|
out.position = vec4(vec2(globals.scale_factor), 1.0, 1.0) * vec4<f32>(v_pos, 0.0, 1.0);
|
||||||
|
out.clip_bounds = globals.scale_factor * input.clip_bounds;
|
||||||
|
|
||||||
// Calculate rotated UV
|
// Calculate rotated UV
|
||||||
let uv = input.atlas_pos + (v_pos - tile.xy) / tile.zw * input.atlas_scale;
|
let uv = input.atlas_pos + (v_pos - tile.xy) / tile.zw * input.atlas_scale;
|
||||||
|
|
@ -87,10 +88,13 @@ fn vs_main(input: VertexInput) -> VertexOutput {
|
||||||
// Snap position to the pixel grid
|
// Snap position to the pixel grid
|
||||||
if bool(input.snap) {
|
if bool(input.snap) {
|
||||||
out.position = round(out.position);
|
out.position = round(out.position);
|
||||||
|
out.clip_bounds = vec4(
|
||||||
|
round(out.clip_bounds.xy),
|
||||||
|
round(out.clip_bounds.xy + out.clip_bounds.zw) - out.clip_bounds.xy,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
out.position = globals.transform * out.position;
|
out.position = globals.transform * out.position;
|
||||||
out.clip_bounds = globals.scale_factor * input.clip_bounds;
|
|
||||||
out.border_radius = globals.scale_factor * input.border_radius;
|
out.border_radius = globals.scale_factor * input.border_radius;
|
||||||
out.atlas = vec4(input.atlas_pos, input.atlas_pos + input.atlas_scale);
|
out.atlas = vec4(input.atlas_pos, input.atlas_pos + input.atlas_scale);
|
||||||
out.layer = input.layer;
|
out.layer = input.layer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue