Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Attributes & Uniforms
- sMVPMatrixHandle = glGetUniformLocation(programHandle, "u_MVPMatrix");
- checkGlError("mvpHandle");
- sPositionHandle = glGetAttribLocation(programHandle, "a_Position");
- checkGlError("positionHandle");
- lightposHandle = glGetUniformLocation(programHandle, "lightpositions");
- checkGlError("lightposHandle");
- // lightcolorHandle = glGetUniformLocation(programHandle, "lightcolors");
- // checkGlError("lighcolorhandle");
- SHADER
- precision highp float;
- //uniform vec4 lightcolors[4];
- uniform vec2 lightpositions[4];
- void main() {
- vec4 result;
- for (int i = 0; i < 4; i++) {
- vec2 pixel = gl_FragCoord.xy;
- vec2 aux = lightpositions[i] - pixel;
- float distance = length(aux);
- float attenuation = 1.0 / (1.0 + 0.001 * distance + 0.009 * distance); //Hoe hoger de waardes des te meer licht
- gl_FragColor = vec4(attenuation, attenuation, attenuation, 1.0);
- }
- // gl_FragColor = result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement