#ifdef MORPH
#define MAX_BLEND_SHAPE_NUMBER 128
-uniform float uNumberOfBlendShapes; ///< Total number of blend shapes loaded.
+uniform int uNumberOfBlendShapes; ///< Total number of blend shapes loaded.
uniform highp float uBlendShapeWeight[MAX_BLEND_SHAPE_NUMBER]; ///< The weight of each blend shape.
#ifdef MORPH_VERSION_2_0
uniform highp float uBlendShapeUnnormalizeFactor; ///< Factor used to unnormalize the geometry of the blend shape.
#else
uniform highp float uBlendShapeUnnormalizeFactor[MAX_BLEND_SHAPE_NUMBER]; ///< Factor used to unnormalize the geometry of the blend shape.
#endif
-uniform highp float uBlendShapeComponentSize; ///< The size in the texture of either the vertices, normals or tangents. Used to calculate the offset to address them.
+uniform highp int uBlendShapeComponentSize; ///< The size in the texture of either the vertices, normals or tangents. Used to calculate the offset to address them.
#endif
void main()
int width = textureSize( sBlendShapeGeometry, 0 ).x;
highp int blendShapeBufferOffset = 0;
- highp int blendShapeComponentSize = int(uBlendShapeComponentSize);
- int numberOfBlendShapes = int(uNumberOfBlendShapes);
- for( int index = 0; index < numberOfBlendShapes; ++index )
+ for( int index = 0; index < uNumberOfBlendShapes; ++index )
{
highp vec3 diff = vec3(0.0);
highp int vertexId = 0;
position.xyz += diff;
- blendShapeBufferOffset += blendShapeComponentSize;
+ blendShapeBufferOffset += uBlendShapeComponentSize;
#endif
#ifdef MORPH_NORMAL
// Calculate the index to retrieve the normal from the texture.
- vertexId = gl_VertexID + int(blendShapeBufferOffset);
+ vertexId = gl_VertexID + blendShapeBufferOffset;
x = vertexId % width;
y = vertexId / width;
normal += diff.xyz;
- blendShapeBufferOffset += blendShapeComponentSize;
+ blendShapeBufferOffset += uBlendShapeComponentSize;
#endif
#ifdef MORPH_TANGENT
tangent += diff.xyz;
- blendShapeBufferOffset += blendShapeComponentSize;
+ blendShapeBufferOffset += uBlendShapeComponentSize;
#endif
}
void BlendShapes::ConfigureProperties(const BlendShapeData& data, Renderer renderer)
{
- unsigned int index = 0u;
+ uint32_t index = 0u;
char weightNameBuffer[32];
char unnormalizeFactorNameBuffer[64];
renderer.RegisterProperty(UNNORMALIZE_FACTOR, data.unnormalizeFactors[0u]);
}
- renderer.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast<float>(index)));
- renderer.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast<float>(data.bufferOffset)));
+ renderer.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast<int32_t>(index)));
+ renderer.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast<int32_t>(data.bufferOffset)));
// Create a read only property to preserve the components of the blend shape.
renderer.RegisterProperty(COMPONENTS, data.components, Property::AccessMode::READ_ONLY);