skinned.frag 389 B

12345678910111213141516
  1. precision mediump float;
  2. uniform vec4 color;
  3. uniform sampler2D texture;
  4. varying vec3 vertexNormal;
  5. varying vec2 vertexTexCoord;
  6. void main() {
  7. vec3 normal = normalize(vertexNormal);
  8. float lambert = max(0.0, -normal.z);
  9. float rim = 1.0 - lambert;
  10. rim *= rim * rim;
  11. vec4 texColor = texture2D(texture, vertexTexCoord);
  12. gl_FragColor = rim + (0.4 + 0.4 * lambert) * texColor * color;
  13. }