Игра Маджонг | Mahjong game
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
666B

  1. #ifdef GL_ES
  2. precision highp float;
  3. #endif
  4. varying vec3 position;
  5. varying vec3 normal;
  6. const vec3 lightPosition = vec3(10, 20, 10);
  7. varying vec2 texCoord;
  8. uniform sampler2D image;
  9. float lambertianReflectanceStrength(vec3 position, vec3 lightPosition)
  10. {
  11. vec3 lightDirection = normalize(lightPosition - position);
  12. // Light flux direction.
  13. float strength = dot(normal, lightDirection);
  14. float diffuse = max(strength, 0.2);
  15. return diffuse;
  16. }
  17. void main()
  18. {
  19. vec3 texColor = texture2D(image, texCoord).rgb;
  20. vec3 finalColor = texColor * lambertianReflectanceStrength(position, lightPosition);
  21. gl_FragColor = vec4(finalColor, 1.0);
  22. }