Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Changed folder structure, deletet some unused files and cleaned up code

File size: 1.3 KB
RevLine 
[12115]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
11// out 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(vertex.xyz + anim_t.x * uv1.xyz + anim_t.y * uv3.xyz, 1.0);
24
25    // nlerp normal
26    // First apply the pose normals (these are actual normals, not offsets)
27    vec3 ninterp = anim_t.x * uv2.xyz + anim_t.y * uv4.xyz;
28
29    // Now add back any influence of the original normal
30    // This depends on what the cumulative weighting left the normal at, if it's lacking or cancelled out
31    //float remainder = 1.0 - min(anim_t.x + anim_t.y, 1.0);
32    float remainder = 1.0 - min(length(ninterp), 1.0);
33    ninterp = ninterp + (remainder * normal.xyz);
34    ninterp = normalize(ninterp);
35
36    gl_Position = worldViewProj * posinterp;
37    // oUv = uv0.xy;
38
39    vec3 lightDir = normalize(
40        objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w));
41
42    // Colour it red to make it easy to identify
43    float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0);
44    colour = vec4((ambient.rgb + vec3(lit, lit, lit)) * vec3(1.0, 0.0, 0.0), 1.0);
45}
Note: See TracBrowser for help on using the repository browser.