shader_type spatial;
render_mode unshaded, blend_add, cull_disabled, depth_draw_never;

uniform float speed : hint_range(0.1, 3.0) = 0.8;
uniform float scale : hint_range(1.0, 20.0) = 8.0;
uniform float intensity : hint_range(0.0, 2.0) = 0.6;
uniform vec3 caustic_color : source_color = vec3(0.7, 0.9, 1.0);

void fragment() {
	vec2 uv = UV * scale;

	float pattern1 = sin(TIME * speed + uv.x * 10.0 + sin(uv.y * 10.0 + TIME * speed));
	float pattern2 = sin(TIME * speed * 0.7 + uv.y * 12.0 + sin(uv.x * 8.0 + TIME * speed * 1.3));
	float pattern3 = sin(TIME * speed * 1.1 + (uv.x + uv.y) * 7.0 + sin(uv.x * 5.0 - TIME * speed * 0.5));

	float caustic = (pattern1 + pattern2 + pattern3) / 3.0;
	caustic = pow(max(caustic, 0.0), 2.0) * intensity;

	EMISSION = caustic_color * caustic;
	ALBEDO = vec3(0.0);
}
