Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Updated programs and adjusted Material to work with GLSL>150

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