Skip to content

Commit 029a7c0

Browse files
replace matrix swizzles in pbr shader with index accesses (#3122)
Matrix swizzles like `mat.x.xyz` are not supported in WGSL and accepted in naga by accident: <https://gpuweb.github.io/gpuweb/wgsl/#matrix-access-expr>
1 parent 9a4cc42 commit 029a7c0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pipelined/bevy_pbr2/src/render/pbr.wgsl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ fn vertex(vertex: Vertex) -> VertexOutput {
5050
out.world_position = world_position;
5151
out.clip_position = view.view_proj * world_position;
5252
out.world_normal = mat3x3<f32>(
53-
mesh.inverse_transpose_model.x.xyz,
54-
mesh.inverse_transpose_model.y.xyz,
55-
mesh.inverse_transpose_model.z.xyz
53+
mesh.inverse_transpose_model[0].xyz,
54+
mesh.inverse_transpose_model[1].xyz,
55+
mesh.inverse_transpose_model[2].xyz
5656
) * vertex.normal;
5757
#ifdef VERTEX_TANGENTS
5858
out.world_tangent = vec4<f32>(
5959
mat3x3<f32>(
60-
mesh.model.x.xyz,
61-
mesh.model.y.xyz,
62-
mesh.model.z.xyz
60+
mesh.model[0].xyz,
61+
mesh.model[1].xyz,
62+
mesh.model[2].xyz
6363
) * vertex.tangent.xyz,
6464
vertex.tangent.w
6565
);
@@ -560,12 +560,12 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4<f32> {
560560
#endif
561561

562562
var V: vec3<f32>;
563-
if (view.projection.w.w != 1.0) { // If the projection is not orthographic
563+
if (view.projection[3].w != 1.0) { // If the projection is not orthographic
564564
// Only valid for a perpective projection
565565
V = normalize(view.world_position.xyz - in.world_position.xyz);
566566
} else {
567567
// Ortho view vec
568-
V = normalize(vec3<f32>(view.view_proj.x.z, view.view_proj.y.z, view.view_proj.z.z));
568+
V = normalize(vec3<f32>(view.view_proj[0].z, view.view_proj[1].z, view.view_proj[2].z));
569569
}
570570

571571
// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"

0 commit comments

Comments
 (0)