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.

22 lines
607 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #ifdef GL_ES
  2. precision mediump float;
  3. #endif
  4. uniform vec4 U_LightPos;
  5. uniform vec4 U_LightAmbient;
  6. uniform vec4 U_LightDiffuse;
  7. uniform vec4 U_AmbientMaterial;
  8. uniform vec4 U_DiffuseMaterial;
  9. varying vec4 V_Color;
  10. varying vec4 V_Normal;
  11. void main()
  12. {
  13. vec4 color=vec4(0.0,0.0,0.0,0.0);
  14. vec4 ambientColor=U_LightAmbient*U_AmbientMaterial;
  15. vec3 lightPos=U_LightPos.xyz;
  16. vec3 L=lightPos;
  17. L=normalize(L);
  18. vec3 n=normalize(V_Normal.xyz);
  19. float diffuseIntensity=max(0.0,dot(L,n));
  20. vec4 diffuseColor=U_LightDiffuse*U_DiffuseMaterial*diffuseIntensity;
  21. color=ambientColor+diffuseColor;
  22. gl_FragColor=color;
  23. }