Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef GL_FRAGMENT_PRECISION_HIGH
- precision highp float;
- #else
- precision mediump float;
- #endif
- uniform vec2 resolution;
- uniform vec2 cameraAddent;
- uniform mat2 cameraOrientation;
- uniform samplerExternalOES cameraBack;
- uniform sampler2D backbuffer;
- uniform int pointerCount;
- uniform vec2 touch;
- vec3 at_cam(vec2 offset)
- {
- vec2 uv = (gl_FragCoord.xy + offset) / resolution.xy;
- vec2 st = cameraAddent + uv * cameraOrientation;
- return texture2D(cameraBack, st).rgb;
- }
- vec3 at_back(vec2 offset)
- {
- vec2 uv = (gl_FragCoord.xy + offset) / resolution.xy;
- return texture2D(backbuffer, uv).rgb;
- }
- void main(void) {
- const int layers = 8;
- const int range = 5;
- float lyf = float(layers-1);
- const int hlist_size = layers;
- vec2 tuv = touch / resolution.xy;
- float final;
- if (pointerCount == 0) {
- final = at_back(vec2(0)).r;
- } else if (tuv.y > 0.3) {
- float hlist[hlist_size];
- for (int i = 0; i < hlist_size; i++)
- hlist[i] = 0.0;
- final = at_back(vec2(0)).r;
- int greatest = int(final*lyf);
- for (int dx = -range; dx <= range; dx++) {
- for(int dy = -range; dy <= range; dy++) {
- vec2 delta = vec2(dx, dy);
- if (delta == vec2(0))
- continue;
- float value = at_back(delta).r;
- int hash = int(value*lyf);
- hlist[hash] += exp(1.0-length(delta));
- if(hlist[hash] > hlist[greatest]) {
- greatest = hash;
- final = value;
- }
- }
- }
- } else {
- vec3 cam = at_cam(vec2(0));
- float lum = (cam.r + cam.g + cam.b) / 3.0;
- final = floor(lum*(lyf-1.0))/(lyf-1.0);
- }
- gl_FragColor = vec4(vec3(final), 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment