Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. // Vertex Shader
  2. attribute vec3 inPosition;
  3. attribute vec3 inNormal;
  4.  
  5. uniform vec4 m_Color;
  6. uniform mat4 g_WorldViewProjectionMatrix;
  7. uniform mat4 g_WorldViewMatrix;
  8. uniform mat3 g_NormalMatrix;
  9.  
  10. varying vec4 vertColor;
  11.  
  12. void main() {
  13. gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
  14. //vec3 lightDir = vec3(g_WorldViewMatrix * vec4(gl_LightSource[0].position));
  15. vec3 lightDir = vec3(gl_LightSource[0].position);
  16. //vec3 lightDir = vec3(-1.0, -1.0, -1.0);
  17. vec3 normal = g_NormalMatrix * inNormal;
  18. float factor = dot(-1 * lightDir, normal);
  19. vertColor = m_Color * factor;
  20. }
  21.  
  22.  
  23. // Fragment Shader (just a passthrough)
  24. varying vec4 vertColor;
  25.  
  26. void main() {
  27. gl_FragColor = vertColor;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement