// NOTE: Shader automatically converted from Godot Engine 4.1.3.stable.mono's StandardMaterial3D.

shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_disabled,unshaded,shadows_disabled,ambient_light_disabled, depth_test_disabled;
uniform float grow;
uniform sampler2D colors : source_color, repeat_disable;
uniform float charge = 1.0;

void vertex() {
	// Billboarding
	MODELVIEW_MATRIX = VIEW_MATRIX * mat4(INV_VIEW_MATRIX[0], INV_VIEW_MATRIX[1], INV_VIEW_MATRIX[2], MODEL_MATRIX[3]);
	MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX);
	VERTEX+=NORMAL*grow;
	
	
	float speed = pow(2.0, ((charge+.4)*5.0));
	float dy = sin(speed*.7) * 0.005;
	float dx = sin(speed) * 0.005;
	VERTEX.y += dy;
	VERTEX.x += dx;
}
uniform sampler2D alpha_falloff : repeat_disable;

void fragment() {
	float where = distance(UV, vec2(0.5))*2.0;
	if (where >= charge) {
		discard;
	}
	vec2 buv = floor(UV * 350.0);
	int bx = int(buv.x);
	int by = int(buv.y);
	int amount = 2;
	
	ALPHA = texture(alpha_falloff, vec2(where/charge)).r;
	
	ALBEDO = texture(colors, vec2(where)).rgb;
}