pub const SKIN_WGSL: &str = r#"
const MAX_BONES: u32 = 52u;
struct Skin {
bones: array<mat4x4<f32>, MAX_BONES>,
};
@group(2) @binding(0) var<uniform> skin: Skin;
fn skin_matrix(weights: vec4<f32>, bones: vec4<u32>) -> mat4x4<f32> {
return skin.bones[bones.x] * weights.x + skin.bones[bones.y] * weights.y
+ skin.bones[bones.z] * weights.z + skin.bones[bones.w] * weights.w;
}
// A skinned point with w = 1. The shipped weights sum to 253..255/255, so the blended matrix's w
// is not 1; the original blends `R·p + t` per bone and projects the result as a point.
fn skin_point(skin_m: mat4x4<f32>, p: vec3<f32>) -> vec4<f32> {
return vec4<f32>((skin_m * vec4<f32>(p, 1.0)).xyz, 1.0);
}
"#;Expand description
WGSL for the palette at @group(2) @binding(0) and the four-bone blend.