• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Use the macro/function applySkinning(x) to apply skinning
2// If skinning is not available, it will be a no-op,
3// otherwise it will multiply x by the skinning matrix
4
5#include ":skinning"
6
7[bones]
8// Declare the bones that are available
9#if defined(numBones)
10#if numBones > 0
11 	uniform mat4 u_bones[numBones];
12#endif //numBones
13#endif
14
15[skinning]
16#include "a_attributes.glsl:a_boneWeights"
17#include ":bones"
18
19// If there are bones and there are bone weights, than we can apply skinning
20#if defined(numBones) && defined(boneWeightsFlag)
21#if (numBones > 0)
22	#define skinningFlag
23#endif
24#endif
25
26#ifdef skinningFlag
27	mat4 skinningTransform = mat4(0.0)
28	#ifdef boneWeight0Flag
29		+ (a_boneWeight0.y) * u_bones[int(a_boneWeight0.x)]
30	#endif //boneWeight0Flag
31	#ifdef boneWeight1Flag
32		+ (a_boneWeight1.y) * u_bones[int(a_boneWeight1.x)]
33	#endif //boneWeight1Flag
34	#ifdef boneWeight2Flag
35		+ (a_boneWeight2.y) * u_bones[int(a_boneWeight2.x)]
36	#endif //boneWeight2Flag
37	#ifdef boneWeight3Flag
38		+ (a_boneWeight3.y) * u_bones[int(a_boneWeight3.x)]
39	#endif //boneWeight3Flag
40	#ifdef boneWeight4Flag
41		+ (a_boneWeight4.y) * u_bones[int(a_boneWeight4.x)]
42	#endif //boneWeight4Flag
43	#ifdef boneWeight5Flag
44		+ (a_boneWeight5.y) * u_bones[int(a_boneWeight5.x)]
45	#endif //boneWeight5Flag
46	#ifdef boneWeight6Flag
47		+ (a_boneWeight6.y) * u_bones[int(a_boneWeight6.x)]
48	#endif //boneWeight6Flag
49	#ifdef boneWeight7Flag
50		+ (a_boneWeight7.y) * u_bones[int(a_boneWeight7.x)]
51	#endif //boneWeight7Flag
52	;
53#endif //skinningFlag
54
55#ifdef skinningFlag
56	vec3 applySkinning(const in vec3 x) { return (skinningTransform * vec4(x, 0.0)).xyz; }
57	vec4 applySkinning(const in vec4 x) { return (skinningTransform * x); }
58#else
59	#define applySkinning(x) (x)
60#endif //skinningFlag
61