// tex_0.r is the height above water
// tex_0.g is the amount of earth
// tex_0.b is the amount of grass
// tex_0.a is the amount of sand

#define SAMPLE_MIN(X,Y) Minimum = min(Minimum,tex_0.Sample( samClampedConstant, (PixelPos + float2(X,Y)) / Dimensions ).r);

float4 PS( VS_to_PS input) : SV_Target {
	float4 Original = tex_0.Sample( samClampedConstant, PixelPos / Dimensions );
	
	//  xxx
	// xxxxx
	// xxoxx
	// xxxxx
	//  xxx
	float Minimum = Original.r;
	SAMPLE_MIN(-2.0f,-1.0f)
	SAMPLE_MIN(-2.0f,0.0f)
	SAMPLE_MIN(-2.0f,1.0f)
	SAMPLE_MIN(-1.0f,-2.0f)
	SAMPLE_MIN(-1.0f,-1.0f)
	SAMPLE_MIN(-1.0f,0.0f)
	SAMPLE_MIN(-1.0f,1.0f)
	SAMPLE_MIN(-1.0f,2.0f)
	SAMPLE_MIN(0.0f,-2.0f)
	SAMPLE_MIN(0.0f,-1.0f)
	SAMPLE_MIN(0.0f,1.0f)
	SAMPLE_MIN(0.0f,2.0f)
	SAMPLE_MIN(1.0f,-2.0f)
	SAMPLE_MIN(1.0f,-1.0f)
	SAMPLE_MIN(1.0f,0.0f)
	SAMPLE_MIN(1.0f,1.0f)
	SAMPLE_MIN(1.0f,2.0f)
	SAMPLE_MIN(2.0f,-1.0f)
	SAMPLE_MIN(2.0f,0.0f)
	SAMPLE_MIN(2.0f,1.0f)
	
	return float4(Minimum,Original.g,Original.b,Original.a);
}
