Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/HardwareMorphAnimationWithNormalsVp.glsles @ 12091

Last change on this file since 12091 was 12091, checked in by wiesep, 6 years ago

Updated programs and adjusted Material to work with GLSL>150

File size: 933 bytes
Line 
1#version 100
2
3precision mediump int;
4precision mediump float;
5
6attribute vec4 vertex;
7attribute vec4 normal;
8attribute vec4 uv0;
9attribute vec4 uv1; // pos2
10attribute vec4 uv2; // normal2
11
12varying vec2 oUv;
13varying vec4 colour;
14
15uniform mat4 worldViewProj;
16uniform vec4 anim_t;
17uniform vec4 objSpaceLightPos;
18uniform vec4 ambient;
19
20// hardware morph animation (with normals)
21void main()
22{
23        // interpolate position
24        vec4 posinterp = vec4(vertex.xyz + anim_t.x*(uv1.xyz - vertex.xyz), 1.0);
25
26    // nlerp normal
27        vec3 ninterp = normal.xyz + anim_t.x*(uv2.xyz - normal.xyz);
28        ninterp = normalize(ninterp);
29
30        gl_Position = worldViewProj * posinterp;
31        oUv = uv0.xy;
32
33        vec3 lightDir = normalize(
34                objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w));
35
36        // Colour it red to make it easy to identify
37        float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0);
38        colour = vec4((ambient.rgb + vec3(lit,lit,lit)) * vec3(1.0,0.0,0.0), 1.0);
39}
Note: See TracBrowser for help on using the repository browser.