#version 130

uniform sampler2D vegetationTexture;
uniform sampler2D noiseTexture;
uniform vec3 sunPosition;
uniform vec3 playerPosition;

in vec3 fWorldPos;
in vec2 fTexcoord;
in vec3 fNormal;
in vec4 fColor;
in float fAlpha;

void main()
{   
    vec4 color = texture2D(vegetationTexture, vec2(fTexcoord.st));
    
    float noise = texture2D(noiseTexture, vec2(fWorldPos.st * 0.1)).r;        
    color.rgb = mix(color.rgb, color.rgb * 1.5, noise);
    
    if (color.a < 0.5 || fAlpha == 0)
    {		
			discard;
	} 
	else 
	{
		gl_FragColor = fColor * vec4(color.rgb, fAlpha);
    }    
}
