Advertisement
Guest User

Untitled

a guest
Jun 13th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. //Attributes & Uniforms
  2.     sMVPMatrixHandle = glGetUniformLocation(programHandle, "u_MVPMatrix");
  3.     checkGlError("mvpHandle");
  4.     sPositionHandle = glGetAttribLocation(programHandle, "a_Position");
  5.     checkGlError("positionHandle");
  6.     lightposHandle = glGetUniformLocation(programHandle, "lightpositions");
  7.     checkGlError("lightposHandle");
  8. //  lightcolorHandle = glGetUniformLocation(programHandle, "lightcolors");
  9. //  checkGlError("lighcolorhandle");
  10.  
  11. SHADER
  12.  
  13. precision highp float;
  14.  
  15. //uniform vec4 lightcolors[4];
  16. uniform vec2 lightpositions[4];
  17.  
  18. void main() {
  19.     vec4 result;
  20.  
  21.     for (int i = 0; i < 4; i++) {
  22.         vec2 pixel = gl_FragCoord.xy;
  23.         vec2 aux = lightpositions[i] - pixel;
  24.         float distance = length(aux);
  25.         float attenuation = 1.0 / (1.0 + 0.001 * distance + 0.009 * distance); //Hoe hoger de waardes des te meer licht
  26.  
  27.         gl_FragColor = vec4(attenuation, attenuation, attenuation, 1.0);
  28.     }
  29. //  gl_FragColor = result;
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement