SkinnedFragShader.fsh 672 B

123456789101112131415161718192021222324252627
  1. uniform sampler2D sTexture;
  2. uniform sampler2D sNormalMap;
  3. uniform bool bUseDot3;
  4. varying mediump vec2 TexCoord;
  5. varying mediump vec3 Light;
  6. void main()
  7. {
  8. if(bUseDot3)
  9. {
  10. /*
  11. Note:
  12. In the normal map red = y, green = x, blue = z which is why when we get the normal
  13. from the texture we use the swizzle .grb so the colours are mapped to the correct
  14. co-ordinate variable.
  15. */
  16. mediump vec3 fNormal = texture2D(sNormalMap, TexCoord).grb;
  17. mediump float fNDotL = dot((fNormal - 0.5) * 2.0, Light);
  18. gl_FragColor = texture2D(sTexture, TexCoord) * fNDotL;
  19. }
  20. else
  21. gl_FragColor = texture2D(sTexture, TexCoord) * Light.x;
  22. }