From fc940721e68f7b8a39f63afd008954b253b3f133 Mon Sep 17 00:00:00 2001 From: Squareys Date: Sun, 3 May 2020 10:23:05 +0200 Subject: [PATCH] Shaders: Add Weights and JointIndices attribute types Signed-off-by: Squareys --- src/Magnum/Shaders/Generic.h | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/Magnum/Shaders/Generic.h b/src/Magnum/Shaders/Generic.h index 43858c0cd..4544dcfda 100644 --- a/src/Magnum/Shaders/Generic.h +++ b/src/Magnum/Shaders/Generic.h @@ -126,13 +126,13 @@ both bitangents and object ID for instancing, \n 6 -* *Reserved* --- vertex weights +@ref Weights 7 -* *Reserved* --- bone indices +@ref JointIndices @@ -150,13 +150,13 @@ both bitangents and object ID for instancing, \n 10 -* *Reserved* --- 2nd vertex weights +@ref Weights 11 -* *Reserved* --- 2nd bone indices +@ref JointIndices @@ -358,7 +358,26 @@ template struct Generic { */ typedef GL::Attribute<5, Vector3> Normal; - /* 6, 7 reserved for vertex weights / bone IDs */ + /** + * @brief Skin weights + * + * @ref Magnum::Vector4 "Vector4", four weights of influence per @ref JointIndices. + * Corresponds to @ref Trade::MeshAttribute::Weights. + */ + // TODO: E.g. gltf supports importing multiple sets of 4 weights (WEIGHTS_0 [0;3], WEIGHTS_1 [4;7]) + // I suppose these would require special shaders and it's fine to only support 4 for the GenericShaders + typedef GL::Attribute<6, Vector4> Weights; + + /** + * @brief Joint indices + * + * @ref Magnum::Vector4 "Vector4", four weights of influence per @ref JointIndices. + * Corresponds to @ref Trade::MeshAttribute::Weights. + */ + // TODO: E.g. gltf supports importing multiple sets of 4 indices (JOINTS_0 [0;3], JOINTS_1 [4;7]) + // I suppose these would require special shaders and it's fine to only support 4 for the GenericShaders + // TODO: This is called "Joints" in gltf. + typedef GL::Attribute<7, Vector4> JointIndices; /** * @brief (Instanced) transformation matrix