3 #define ADD_EXTRA_SKINNING_ATTRIBUTES
4 #define ADD_EXTRA_WEIGHTS
15 ADD_EXTRA_SKINNING_ATTRIBUTES;
21 uniform highp mat4 uViewMatrix;
22 uniform highp mat4 uModelMatrix;
23 uniform highp mat4 uProjection;
27 layout(std140) uniform Bones
29 mat4 uBone[MAX_BONES];
31 uniform mediump vec3 uYDirection;
35 #define MAX_BLEND_SHAPE_NUMBER 128
36 uniform int uNumberOfBlendShapes; ///< Total number of blend shapes loaded.
37 uniform highp float uBlendShapeWeight[MAX_BLEND_SHAPE_NUMBER]; ///< The weight of each blend shape.
38 #ifdef MORPH_VERSION_2_0
39 uniform highp float uBlendShapeUnnormalizeFactor; ///< Factor used to unnormalize the geometry of the blend shape.
41 uniform highp float uBlendShapeUnnormalizeFactor[MAX_BLEND_SHAPE_NUMBER]; ///< Factor used to unnormalize the geometry of the blend shape.
43 uniform highp int uBlendShapeComponentSize; ///< The size in the texture of either the vertices, normals or tangents. Used to calculate the offset to address them.
46 uniform highp mat4 uShadowLightViewProjectionMatrix;
50 highp vec4 position = vec4(aPosition, 1.0);
53 int width = textureSize( sBlendShapeGeometry, 0 ).x;
55 highp int blendShapeBufferOffset = 0;
57 for( int index = 0; index < uNumberOfBlendShapes; ++index )
59 highp vec3 diff = vec3(0.0);
60 highp int vertexId = 0;
65 // Calculate the index to retrieve the geometry from the texture.
66 vertexId = gl_VertexID + blendShapeBufferOffset;
70 // Retrieves the blend shape geometry from the texture, unnormalizes it and multiply by the weight.
71 if( 0.0 != uBlendShapeWeight[index] )
73 #ifdef MORPH_VERSION_2_0
74 highp float unnormalizeFactor = uBlendShapeUnnormalizeFactor;
76 highp float unnormalizeFactor = uBlendShapeUnnormalizeFactor[index];
79 diff = uBlendShapeWeight[index] * unnormalizeFactor * ( texelFetch( sBlendShapeGeometry, ivec2(x, y), 0 ).xyz - 0.5 );
84 blendShapeBufferOffset += uBlendShapeComponentSize;
88 blendShapeBufferOffset += uBlendShapeComponentSize;
92 blendShapeBufferOffset += uBlendShapeComponentSize;
99 highp mat4 bone = uBone[int(aJoints0.x)] * aWeights0.x +
100 uBone[int(aJoints0.y)] * aWeights0.y +
101 uBone[int(aJoints0.z)] * aWeights0.z +
102 uBone[int(aJoints0.w)] * aWeights0.w;
106 position = bone * position;
107 highp vec4 positionW = position;
109 highp vec4 positionW = uModelMatrix * position;
112 // To synchronize View-Projection matrix with pbr shader
113 gl_Position = uShadowLightViewProjectionMatrix * positionW;
116 vUV = vec2(aTexCoord.x, 1.0 - aTexCoord.y);
121 vColor = aVertexColor;