shader_type spatial;
render_mode depth_prepass_alpha,unshaded;

uniform sampler2D tex : source_color,filter_nearest;
uniform float flash_white;

uniform vec2 deformation_dir = vec2(1, 0);
uniform float deformation_rate = 0;

void vertex() {
	if (length(deformation_dir)>0.0){
		 vec2 dir_center = VERTEX.xy;
	    vec2 dir = normalize(deformation_dir.yx);
	    vec2 dir1 = dir * deformation_rate;
	    vec2 dir2 = cross(vec3(0, 0, 1), vec3(dir, 0)).xy * deformation_rate;
	    vec2 offset1 = -dot(dir1, dir_center) * dir1;
	    vec2 offset2 = dot(dir2, dir_center) * dir2;
		VERTEX.xy += offset1 + offset2;
	}
}

void fragment() {
	vec4 col = texture(tex, UV);
	if(col.a<0.5){discard;}
	if(flash_white>0.0){
		col.rgb = col.rgb * (flash_white + 1.0) * vec3(1,1,1);
	}
	ALBEDO = col.rgb;
	ALPHA = 1.0;
}

void light() {
	DIFFUSE_LIGHT = vec3(0, 0, 0);
}