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
823 B

  1. #ifdef GL_ES
  2. precision mediump float;
  3. #endif;
  4. attribute vec4 position;
  5. attribute vec4 texcoord;
  6. attribute vec2 normal;
  7. uniform mat4 ModelMatrix;
  8. uniform mat4 ViewMatrix;
  9. uniform mat4 ProjectionMatrix;
  10. uniform mat4 IT_ModelMatrix;
  11. uniform vec4 U_AmbientMaterial;
  12. uniform vec4 U_AmbientLight;
  13. uniform vec4 U_LightPos;
  14. uniform vec4 U_DiffuseMaterial;
  15. uniform vec4 U_DiffuseLight;
  16. varying vec4 V_Color;
  17. void main(){
  18. //ambient
  19. vec4 ambientColor = U_AmbientMaterial*U_AmbientLight;
  20. //diffuse
  21. vec3 L = normalize(U_LightPos.xyz - vec3(0));
  22. vec3 n = normalize(IT_ModelMatrix * normal.xyz);
  23. float diffuseIntensity = max(0.0, dot(L,n));
  24. vec4 diffuseColor = U_DiffuseMaterial * U_DiffuseLight * diffuseIntensity;
  25. V_Color = ambientColor + diffuseColor;
  26. gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * position;
  27. }