Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. attribute vec3 position;
  2. attribute vec3 normal;
  3. attribute vec2 texcoord;
  4.  
  5. uniform mat4 ModelViewProjectionMatrix;
  6. uniform mat4 NormalMatrix;
  7.  
  8. varying vec4 Color;
  9. varying vec2 TextureCoord;
  10.  
  11. void main(void)
  12. {
  13.     // Transform the normal to eye coordinates
  14.     vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));
  15.  
  16.     // The LightSourcePosition is actually its direction for directional light
  17.     vec3 L = normalize(LightSourcePosition.xyz);
  18.  
  19.     // Multiply the diffuse value by the vertex color (which is fixed in this case)
  20.     // to get the actual color that we will use to draw this vertex with
  21.     float diffuse = max(dot(N, L), 0.0);
  22.  
  23.     if (position.x != 0.5)
  24.         Color = vec4(0.9, 0.0, 0.0, 1.0); // red
  25.     else
  26.         Color = vec4(0.0, 0.9, 0.0, 1.0); // green
  27.  
  28. //    Color = vec4(diffuse * MaterialDiffuse.rgb, MaterialDiffuse.a);
  29.  
  30.     // Set the texture coordinates as a varying
  31.     TextureCoord = texcoord;
  32.  
  33.     // Transform the position to clip coordinates
  34.     gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement