Advertisement
Guest User

Untitled

a guest
Jun 30th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. uniform vec3 lightLocation; //Just set to 10, 10, 10 in the game class
  2. vec3 lightColor = vec3(100, 100, 100); //The lights color
  3.  
  4. varying vec3 normal; //Normal (not setup through batch yet)
  5. varying vec3 vertex; //Vertex from last stage
  6.  
  7. void main(){
  8. vec3 light = normalize(lightLocation.xyz - vertex); //Normalize length between the light location, and vertex location
  9. vec4 diffuse = vec4(lightColor, 1.0) * max(dot(normal, light), 0.0); //Diffuse color (light color)
  10. diffuse = clamp(diffuse, 0.0, 1.0); //Final light color
  11.  
  12. gl_FragColor = gl_Color * diffuse; //Vertex color + light color
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement