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.

26 lines
519 B

4 years ago
  1. attribute vec3 pos;
  2. attribute vec2 texcoord;
  3. attribute vec3 normal;
  4. uniform mat4 M;
  5. uniform mat4 P;
  6. uniform mat4 V;
  7. uniform mat4 NM;
  8. uniform vec3 U_LightPos;
  9. uniform vec4 U_DiffuseLightColor;
  10. uniform vec4 U_DiffuseMaterial;
  11. varying vec4 V_DiffuseColor;
  12. void main()
  13. {
  14. //L vector
  15. vec3 L=U_LightPos;
  16. L=normalize(L);
  17. //N vector
  18. vec3 n=normalize(mat3(NM)*normal);
  19. float diffuseIntensity=max(0.0,dot(L,n));
  20. V_DiffuseColor=U_DiffuseLightColor*U_DiffuseMaterial*diffuseIntensity;
  21. gl_Position=P*V*M*vec4(pos,1.0);
  22. }