Skip to content

Commit b3ab4fc

Browse files
superdumpcart
authored andcommitted
Sync up bevy_sprite and bevy_ui shader View struct (#5531)
# Objective - Similar to #5512 , the `View` struct definition in the shaders in `bevy_sprite` and `bevy_ui` were out of sync with the rust-side `ViewUniform`. Only `view_proj` was being used and is the first member and as those shaders are not customisable it makes little difference in practice, unlike for `Mesh2d`. ## Solution - Sync shader `View` struct definition in `bevy_sprite` and `bevy_ui` with the correct definition that matches `ViewUniform`
1 parent 12daeeb commit b3ab4fc

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

crates/bevy_sprite/src/render/sprite.wgsl

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
struct View {
22
view_proj: mat4x4<f32>,
3+
inverse_view_proj: mat4x4<f32>,
4+
view: mat4x4<f32>,
5+
inverse_view: mat4x4<f32>,
6+
projection: mat4x4<f32>,
7+
inverse_projection: mat4x4<f32>,
38
world_position: vec3<f32>,
9+
width: f32,
10+
height: f32,
411
};
512
@group(0) @binding(0)
613
var<uniform> view: View;

crates/bevy_ui/src/render/ui.wgsl

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
struct View {
22
view_proj: mat4x4<f32>,
3+
inverse_view_proj: mat4x4<f32>,
4+
view: mat4x4<f32>,
5+
inverse_view: mat4x4<f32>,
6+
projection: mat4x4<f32>,
7+
inverse_projection: mat4x4<f32>,
38
world_position: vec3<f32>,
9+
width: f32,
10+
height: f32,
411
};
512
@group(0) @binding(0)
613
var<uniform> view: View;
@@ -22,7 +29,7 @@ fn vertex(
2229
out.position = view.view_proj * vec4<f32>(vertex_position, 1.0);
2330
out.color = vertex_color;
2431
return out;
25-
}
32+
}
2633

2734
@group(1) @binding(0)
2835
var sprite_texture: texture_2d<f32>;
@@ -31,7 +38,7 @@ var sprite_sampler: sampler;
3138

3239
@fragment
3340
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
34-
var color = textureSample(sprite_texture, sprite_sampler, in.uv);
41+
var color = textureSample(sprite_texture, sprite_sampler, in.uv);
3542
color = in.color * color;
3643
return color;
37-
}
44+
}

0 commit comments

Comments
 (0)