uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;

uniform float near;
uniform float far;

float depth0 = texture(depthtex0, texcoord).x;
float depth1 = texture(depthtex1, texcoord).x;
float depth2 = texture(depthtex2, texcoord).x;

float lind(float depth) {
    return (near * far) / (depth * (near - far) + far);
}

bool isTerrain = depth1<1.0;
bool isSky = !isTerrain;
