Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #ifdef GL_ES
  2. precision mediump float;
  3. #endif
  4.  
  5. varying vec2 v_texCoord;
  6. varying vec4 v_v2Position;
  7.  
  8. uniform sampler2D u_texture;
  9. uniform vec2 u_v2LightPositions[8];
  10. uniform int u_iLightStatus[8];
  11. uniform float u_fRadiusSquared[8];
  12.  
  13.  
  14. void main()
  15. {
  16. vec4 currentTexelColor = texture2D(u_texture, v_texCoord);
  17.  
  18. float gray = dot(currentTexelColor.rgb, vec3( 0.299, 0.587, 0.114 ) );
  19.  
  20. for(int i = 0; i < 8; i++)
  21. {
  22. float fDistance_x = v_v2Position.x - u_v2LightPositions[i].x;
  23. float fDistance_y = v_v2Position.y - u_v2LightPositions[i].y;
  24. if( ( u_iLightStatus[i] == 1 ) && (fDistance_x * fDistance_x ) + (fDistance_y * fDistance_y ) < u_fRadiusSquared[i] )
  25. {
  26. gl_FragColor = currentTexelColor;
  27. return;
  28. }
  29. }
  30.  
  31. gl_FragColor = vec4( gray, gray, gray, currentTexelColor.a );
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement