#version 330 core
// waterfall frag.shader

in vec2 UV;
in vec4 aPos;

out vec4 color;

uniform sampler2D sprite;
uniform vec3 wPos;
uniform vec3 wRad;

void main(){
	color = texture( sprite, UV).rgba;

	//fadeout away from X-centerline:
	float xradius = abs( aPos.x - wPos.x ) / wRad.x;
	float xfade = 1.0 - clamp( 2.0*xradius, 0.0, 1.0 );

	//fadeout away from Z-center:
	float zradius = abs( aPos.z - wPos.z ) / wRad.z;
	zradius = clamp( zradius, 0.0, 1.0 );
	float zfade = 1.0 - zradius;

	//x-Center fade:
	float cfade = 5.0 * xradius / wRad.x; //center 20%
	cfade = clamp( cfade, 0.0, 1.0 );

	color.a *= xfade*xfade * zfade * cfade;
}

