1attribute vec3 vertexPosition;
2attribute vec3 vertexNormal;
3attribute vec3 vertexPositionTarget;
4attribute vec3 vertexNormalTarget;
5
6varying vec3 worldPosition;
7varying vec3 worldNormal;
8
9uniform mat4 modelMatrix;
10uniform mat3 modelNormalMatrix;
11uniform mat4 modelViewProjection;
12uniform float interpolator;
13
14void main()
15{
16    vec3 morphPos;
17    vec3 morphNormal;
18    if (interpolator > 0.0) {
19        // normalized
20        morphPos = mix(vertexPosition, vertexPositionTarget, interpolator);
21        morphNormal = normalize(mix(vertexNormal, vertexNormalTarget, interpolator));
22    } else {
23        // relative
24        morphPos = vertexPosition + vertexPositionTarget * abs(interpolator);
25        morphNormal = normalize(vertexNormal + vertexNormalTarget * abs(interpolator));
26    }
27
28    worldNormal = normalize( modelNormalMatrix * morphNormal );
29    worldPosition = vec3( modelMatrix * vec4( morphPos, 1.0 ) );
30
31    gl_Position = modelViewProjection * vec4( morphPos, 1.0 );
32}
33