Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSL150/HardwarePoseAnimationWithNormalsVp.glsl @ 12083

Last change on this file since 12083 was 12083, checked in by wiesep, 5 years ago

Reorganised shader programs

File size: 1.3 KB
Line 
1#version 150
2
3in vec4 vertex;
4in vec4 normal;
5in vec4 uv0;
6in vec4 uv1; // pose1pos
7in vec4 uv2; // pose1norm
8in vec4 uv3; // pose2pos
9in vec4 uv4; // pose2norm
10
11out vec2 oUv;
12out vec4 colour;
13
14uniform mat4 worldViewProj;
15uniform vec4 anim_t;
16uniform vec4 objSpaceLightPos;
17uniform vec4 ambient;
18
19// hardware pose animation (with normals)
20void main()
21{
22        // interpolate position
23        vec4 posinterp = vec4(pos + anim_t.x*uv1.xyz + anim_t.y*uv3.xyz, 1.0);
24
25    // nlerp normal
26        // nlerp normal
27        // First apply the pose normals (these are actual normals, not offsets)
28        vec3 ninterp = anim_t.x*uv2.xyz + anim_t.y*uv4.xyz;
29
30        // Now add back any influence of the original normal
31        // This depends on what the cumulative weighting left the normal at, if it's lacking or cancelled out
32        //float remainder = 1.0 - min(anim_t.x + anim_t.y, 1.0);
33        float remainder = 1.0 - min(length(ninterp), 1.0);
34        ninterp = ninterp + (normal * remainder);
35        ninterp = normalize(ninterp);
36
37        gl_Position = worldViewProj * posinterp;
38        oUv = uv0.xy;
39       
40        vec3 lightDir = normalize(
41                objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w));
42
43        // Colour it red to make it easy to identify
44        float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0);
45        colour = vec4((ambient.rgb + vec3(lit,lit,lit)) * vec3(1.0,0.0,0.0), 1.0);
46}
Note: See TracBrowser for help on using the repository browser.