Debian Codegraph @

src/extras/shaders/es2/morphphong.vert

raw
1 attribute vec3 vertexPosition;
2 attribute vec3 vertexNormal;
3 attribute vec3 vertexPositionTarget;
4 attribute vec3 vertexNormalTarget;
5
6 varying vec3 worldPosition;
7 varying vec3 worldNormal;
8
9 uniform mat4 modelMatrix;
10 uniform mat3 modelNormalMatrix;
11 uniform mat4 modelViewProjection;
12 uniform float interpolator;
13
14 void 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 }