Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 9, 2018, 1:06:05 PM (6 years ago)
Author:
wiesep
Message:

Updated programs and adjusted Material to work with GLSL>150

File:
1 edited

Legend:

Unmodified
Added
Removed
  • data/branches/Shader_HS18/programs/Example/GLSL150/HardwarePoseAnimationWithNormalsVp.glsl

    r12083 r12091  
    99in vec4 uv4; // pose2norm
    1010
    11 out vec2 oUv;
     11// out vec2 oUv;
    1212out vec4 colour;
    1313
     
    2020void main()
    2121{
    22         // interpolate position
    23         vec4 posinterp = vec4(pos + anim_t.x*uv1.xyz + anim_t.y*uv3.xyz, 1.0);
     22    // interpolate position
     23    vec4 posinterp = vec4(vertex.xyz + anim_t.x * uv1.xyz + anim_t.y * uv3.xyz, 1.0);
    2424
    2525    // 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;
     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;
    2928
    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);
     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);
    3635
    37         gl_Position = worldViewProj * posinterp;
    38         oUv = uv0.xy;
    39        
    40         vec3 lightDir = normalize(
    41                 objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w));
     36    gl_Position = worldViewProj * posinterp;
     37    // oUv = uv0.xy;
    4238
    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);
     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);
    4645}
Note: See TracChangeset for help on using the changeset viewer.