Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#define_import_path bevy_pbr::skinning
3#ifdef SKINNED
5@group(2) @binding(1)
6var<uniform> joint_matrices: SkinnedMesh;
8fn skin_model(
9 indexes: vec4<u32>,
10 weights: vec4<f32>,
11) -> mat4x4<f32> {
12 return weights.x * joint_matrices.data[indexes.x]
13 + weights.y * joint_matrices.data[indexes.y]
14 + weights.z * joint_matrices.data[indexes.z]
15 + weights.w * joint_matrices.data[indexes.w];
18fn inverse_transpose_3x3(in: mat3x3<f32>) -> mat3x3<f32> {
19 let x = cross(in[1], in[2]);
20 let y = cross(in[2], in[0]);
21 let z = cross(in[0], in[1]);
22 let det = dot(in[2], z);
23 return mat3x3<f32>(
24 x / det,
25 y / det,
26 z / det
27 );
30fn skin_normals(
31 model: mat4x4<f32>,
32 normal: vec3<f32>,
33) -> vec3<f32> {
34 return inverse_transpose_3x3(mat3x3<f32>(
35 model[0].xyz,
36 model[1].xyz,
37 model[2].xyz
38 )) * normal;
41#endif
Contents