uniform sampler2D sceneSampler; // 0 uniform sampler2D depthSampler; // 1 float LinearizeDepth(vec2 uv) { float n = 1.0; // camera z near float f = 100.0; // camera z far float z = texture2D(depthSampler, uv).x; return (2.0 * n) / (f + n - z * (f - n)); } void main() { vec2 uv = gl_TexCoord[0].xy; //vec4 sceneTexel = texture2D(sceneSampler, uv); float d; if (uv.x < 0.5) // left part d = LinearizeDepth(uv); else // right part d = texture2D(depthSampler, uv).x; // int depth = int(d * 10000.0); // if (depth > 10000 || depth < 800) // depth = 0; // int red = int(mod(float(depth), 32.0)); // int green = int(mod(float(depth / 32), 32.0)); // int blue = int(mod(float(depth / 1024), 32.0)); // float fRed = float(red) / 32.0; // float fGreen = float(green) / 32.0; // float fBlue = float(blue) / 32.0; // gl_FragColor.rgb = vec4(fRed, fGreen, fBlue, 1.0); gl_FragColor.rgb = vec4(d, d, d, 1.0); }