From 0f71c96d21cdb3f9b1c112982db483bb64ffefce Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Fri, 5 Aug 2022 02:28:06 +0000 Subject: [PATCH] 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` --- crates/bevy_sprite/src/render/sprite.wgsl | 7 +++++++ crates/bevy_ui/src/render/ui.wgsl | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/bevy_sprite/src/render/sprite.wgsl b/crates/bevy_sprite/src/render/sprite.wgsl index 78494b5a72ee5..2f1e4f8e45f89 100644 --- a/crates/bevy_sprite/src/render/sprite.wgsl +++ b/crates/bevy_sprite/src/render/sprite.wgsl @@ -1,6 +1,13 @@ struct View { view_proj: mat4x4, + inverse_view_proj: mat4x4, + view: mat4x4, + inverse_view: mat4x4, + projection: mat4x4, + inverse_projection: mat4x4, world_position: vec3, + width: f32, + height: f32, }; @group(0) @binding(0) var view: View; diff --git a/crates/bevy_ui/src/render/ui.wgsl b/crates/bevy_ui/src/render/ui.wgsl index 70edf23f24c14..4993e52d3908f 100644 --- a/crates/bevy_ui/src/render/ui.wgsl +++ b/crates/bevy_ui/src/render/ui.wgsl @@ -1,6 +1,13 @@ struct View { view_proj: mat4x4, + inverse_view_proj: mat4x4, + view: mat4x4, + inverse_view: mat4x4, + projection: mat4x4, + inverse_projection: mat4x4, world_position: vec3, + width: f32, + height: f32, }; @group(0) @binding(0) var view: View; @@ -22,7 +29,7 @@ fn vertex( out.position = view.view_proj * vec4(vertex_position, 1.0); out.color = vertex_color; return out; -} +} @group(1) @binding(0) var sprite_texture: texture_2d; @@ -31,7 +38,7 @@ var sprite_sampler: sampler; @fragment fn fragment(in: VertexOutput) -> @location(0) vec4 { - var color = textureSample(sprite_texture, sprite_sampler, in.uv); + var color = textureSample(sprite_texture, sprite_sampler, in.uv); color = in.color * color; return color; -} \ No newline at end of file +}