#version 330

in vec2 UV;

layout(location = 0) out uint D;

uniform usampler2D texDepth;
uniform vec2 resolution;

vec2 offset[] = vec2[](vec2(-1,-1), vec2(0,-1), vec2(1,-1),
vec2(-1,0), vec2(1,0),
vec2(-1,1), vec2(0,1), vec2(1,1));


 
void main(){
	uint D0 = texture(texDepth, UV).r;

	//get min from around
	D = D0;
	uint cnt = uint(0);
	for(int i = 0; i < 8; i++) {
		vec2 UV2 = UV + offset[i]/resolution;
		uint D2 = texture(texDepth, UV2).r;
		D = max(D,D2);
	}
}