Skip to content

Commit

Permalink
WGSL: use correct syntax for matrix access (#5039)
Browse files Browse the repository at this point in the history
# Objective

- `.x` is not the correct syntax to access a column in a matrix in WGSL: https://www.w3.org/TR/WGSL/#matrix-access-expr
- naga accepts it and translates it correctly, but it's not valid when shaders are kept as is and used directly in WGSL

## Solution

- Use the correct syntax
  • Loading branch information
mockersf committed Jun 18, 2022
1 parent a62ff65 commit 8b27124
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/bevy_pbr/src/render/skinning.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ fn add_matrix(
b: mat4x4<f32>,
) -> mat4x4<f32> {
return mat4x4<f32>(
a.x + b.x,
a.y + b.y,
a.z + b.z,
a.w + b.w,
a[0] + b[0],
a[1] + b[1],
a[2] + b[2],
a[3] + b[3],
);
}

Expand All @@ -29,10 +29,10 @@ fn skin_model(
}

fn inverse_transpose_3x3(in: mat3x3<f32>) -> mat3x3<f32> {
let x = cross(in.y, in.z);
let y = cross(in.z, in.x);
let z = cross(in.x, in.y);
let det = dot(in.z, z);
let x = cross(in[1], in[2]);
let y = cross(in[2], in[0]);
let z = cross(in[0], in[1]);
let det = dot(in[2], z);
return mat3x3<f32>(
x / det,
y / det,
Expand Down

0 comments on commit 8b27124

Please sign in to comment.