12 uniform highp mat4 uViewMatrix;
13 uniform highp mat4 uModelMatrix;
14 uniform highp mat4 uProjection;
20 uniform mat4 uBone[MAX_BONES];
21 uniform mediump vec3 uYDirection;
25 #define MAX_BLEND_SHAPE_NUMBER 128
26 uniform int uNumberOfBlendShapes; ///< Total number of blend shapes loaded.
27 uniform highp float uBlendShapeWeight[MAX_BLEND_SHAPE_NUMBER]; ///< The weight of each blend shape.
28 #ifdef MORPH_VERSION_2_0
29 uniform highp float uBlendShapeUnnormalizeFactor; ///< Factor used to unnormalize the geometry of the blend shape.
31 uniform highp float uBlendShapeUnnormalizeFactor[MAX_BLEND_SHAPE_NUMBER]; ///< Factor used to unnormalize the geometry of the blend shape.
33 uniform highp int uBlendShapeComponentSize; ///< The size in the texture of either the vertices, normals or tangents. Used to calculate the offset to address them.
36 uniform highp mat4 uShadowLightViewProjectionMatrix;
40 highp vec4 position = vec4(aPosition, 1.0);
43 int width = textureSize( sBlendShapeGeometry, 0 ).x;
45 highp int blendShapeBufferOffset = 0;
47 for( int index = 0; index < uNumberOfBlendShapes; ++index )
49 highp vec3 diff = vec3(0.0);
50 highp int vertexId = 0;
55 // Calculate the index to retrieve the geometry from the texture.
56 vertexId = gl_VertexID + blendShapeBufferOffset;
60 // Retrieves the blend shape geometry from the texture, unnormalizes it and multiply by the weight.
61 if( 0.0 != uBlendShapeWeight[index] )
63 #ifdef MORPH_VERSION_2_0
64 highp float unnormalizeFactor = uBlendShapeUnnormalizeFactor;
66 highp float unnormalizeFactor = uBlendShapeUnnormalizeFactor[index];
69 diff = uBlendShapeWeight[index] * unnormalizeFactor * ( texelFetch( sBlendShapeGeometry, ivec2(x, y), 0 ).xyz - 0.5 );
74 blendShapeBufferOffset += uBlendShapeComponentSize;
78 blendShapeBufferOffset += uBlendShapeComponentSize;
82 blendShapeBufferOffset += uBlendShapeComponentSize;
89 highp mat4 bone = uBone[int(aJoints.x)] * aWeights.x +
90 uBone[int(aJoints.y)] * aWeights.y +
91 uBone[int(aJoints.z)] * aWeights.z +
92 uBone[int(aJoints.w)] * aWeights.w;
93 position = bone * position;
95 highp vec4 positionW = position;
97 highp vec4 positionW = uModelMatrix * position;
100 // To synchronize View-Projection matrix with pbr shader
101 gl_Position = uShadowLightViewProjectionMatrix * positionW;
104 vUV = vec2(aTexCoord.x, 1.0 - aTexCoord.y);
109 vColor = aVertexColor;