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.

24 lines
583 B

  1. #ifdef GL_ES
  2. precision mediump float;
  3. #endif
  4. uniform vec4 U_AmbientMaterial;
  5. uniform vec4 U_AmbientLight;
  6. uniform vec4 U_LightPos;
  7. uniform vec4 U_DiffuseMaterial;
  8. uniform vec4 U_DiffuseLight;
  9. varying vec4 V_Normal;
  10. void main()
  11. {
  12. //ambient
  13. vec4 ambirntColor = U_AmbientMaterial*U_AmbientLight;
  14. //diffuse
  15. vec3 L = normalize(U_LightPos.xyz - vec3(0));
  16. vec3 n = normalize(V_Normal.xyz);
  17. float diffuseIntensity = max(0.0, dot(L,n));
  18. vec4 diffuseColor = U_DiffuseMaterial * U_DiffuseLight * diffuseIntensity;
  19. gl_FragColor=ambirntColor + diffuseColor;
  20. }