[gd_scene load_steps=12 format=3 uid="uid://bdnesuqroi7ss"]

[ext_resource type="Shader" path="res://vfx/particle_mixer.gdshader" id="1_i6oe2"]
[ext_resource type="Texture2D" uid="uid://dq7jm5ufknbb6" path="res://vfx/lens-flare-particle.png" id="2_h5y3k"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_lpenh"]
render_priority = 0
shader = ExtResource("1_i6oe2")
shader_parameter/particle_color = null
shader_parameter/particle_texture = ExtResource("2_h5y3k")

[sub_resource type="Gradient" id="Gradient_tjuvm"]
offsets = PackedFloat32Array(0, 0.50813, 1)
colors = PackedColorArray(1, 0.877403, 0.516545, 1, 0.94702, 0.505309, 0.59484, 1, 0.735853, 0.324231, 0.687053, 1)

[sub_resource type="GradientTexture1D" id="GradientTexture1D_d2t20"]
gradient = SubResource("Gradient_tjuvm")

[sub_resource type="Gradient" id="Gradient_c8r4y"]
offsets = PackedFloat32Array(0, 0.00813008, 0.52439, 1)
colors = PackedColorArray(0, 0, 0, 1, 0.0284553, 0.0284553, 0.0284553, 1, 0.244776, 0.244776, 0.244776, 1, 0, 0, 0, 1)

[sub_resource type="GradientTexture1D" id="GradientTexture1D_2vogp"]
gradient = SubResource("Gradient_c8r4y")

[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_eegys"]
emission_shape = 1
emission_sphere_radius = 0.2
spread = 180.0
initial_velocity_max = 0.2
gravity = Vector3(0, 0.02, 0)
color_ramp = SubResource("GradientTexture1D_2vogp")
color_initial_ramp = SubResource("GradientTexture1D_d2t20")
turbulence_enabled = true
turbulence_noise_strength = 0.1
turbulence_noise_scale = 2.0
turbulence_noise_speed = Vector3(0.1, 0.3, 0.5)
turbulence_noise_speed_random = 0.3
turbulence_influence_min = 0.01
turbulence_influence_max = 0.02
turbulence_initial_displacement_max = 1.0

[sub_resource type="Shader" id="Shader_p2314"]
code = "// NOTE: Shader automatically converted from Godot Engine 4.0.stable's StandardMaterial3D.

shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_disabled;
uniform vec4 albedo : source_color;
uniform sampler2D texture_albedo : source_color,filter_linear_mipmap,repeat_enable;
uniform float point_size : hint_range(0,128);
uniform float roughness : hint_range(0,1);
uniform sampler2D texture_metallic : hint_default_white,filter_linear_mipmap,repeat_enable;
uniform vec4 metallic_texture_channel;
uniform sampler2D texture_roughness : hint_roughness_r,filter_linear_mipmap,repeat_enable;
uniform float specular;
uniform float metallic;
uniform int particles_anim_h_frames;
uniform int particles_anim_v_frames;
uniform bool particles_anim_loop;
uniform vec4 backlight : source_color;
uniform sampler2D texture_backlight : hint_default_black,filter_linear_mipmap,repeat_enable;
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;


void vertex() {
	UV=UV*uv1_scale.xy+uv1_offset.xy;
	mat4 mat_world = mat4(normalize(INV_VIEW_MATRIX[0]), normalize(INV_VIEW_MATRIX[1]) ,normalize(INV_VIEW_MATRIX[2]), MODEL_MATRIX[3]);
	mat_world = mat_world * mat4(vec4(cos(INSTANCE_CUSTOM.x), -sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));
	MODELVIEW_MATRIX = VIEW_MATRIX * mat_world;
	MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX);
	float h_frames = float(particles_anim_h_frames);
	float v_frames = float(particles_anim_v_frames);
	float particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);
	float particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));
	if (!particles_anim_loop) {
		particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);
	} else {
		particle_frame = mod(particle_frame, particle_total_frames);
	}
	UV /= vec2(h_frames, v_frames);
	UV += vec2(mod(particle_frame, h_frames) / h_frames, floor((particle_frame + 0.5) / h_frames) / v_frames);
}






void fragment() {
	vec2 base_uv = UV;
	vec4 albedo_tex = texture(texture_albedo,base_uv);
	albedo_tex *= COLOR;
	ALBEDO = albedo.rgb * albedo_tex.rgb;
	float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
	METALLIC = metallic_tex * metallic;
	vec4 roughness_texture_channel = vec4(1.0,0.0,0.0,0.0);
	float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
	ROUGHNESS = roughness_tex * roughness;
	SPECULAR = specular;
	vec3 backlight_tex = texture(texture_backlight,base_uv).rgb;
	BACKLIGHT = (backlight.rgb+backlight_tex);
}
"

[sub_resource type="ShaderMaterial" id="ShaderMaterial_fgrmi"]
render_priority = 0
shader = SubResource("Shader_p2314")
shader_parameter/albedo = Color(1, 1, 1, 1)
shader_parameter/point_size = 1.0
shader_parameter/roughness = 1.0
shader_parameter/metallic_texture_channel = null
shader_parameter/specular = 0.5
shader_parameter/metallic = 0.0
shader_parameter/particles_anim_h_frames = 1
shader_parameter/particles_anim_v_frames = 1
shader_parameter/particles_anim_loop = false
shader_parameter/backlight = Color(0, 0, 0, 1)
shader_parameter/uv1_scale = Vector3(1, 1, 1)
shader_parameter/uv1_offset = Vector3(0, 0, 0)
shader_parameter/uv2_scale = Vector3(1, 1, 1)
shader_parameter/uv2_offset = Vector3(0, 0, 0)
shader_parameter/texture_albedo = ExtResource("2_h5y3k")
shader_parameter/texture_backlight = ExtResource("2_h5y3k")

[sub_resource type="QuadMesh" id="QuadMesh_ea2fp"]
material = SubResource("ShaderMaterial_fgrmi")
size = Vector2(0.06, 0.06)

[node name="collectable_particles" type="GPUParticles3D"]
material_override = SubResource("ShaderMaterial_lpenh")
cast_shadow = 0
amount = 50
lifetime = 10.0
speed_scale = 0.5
process_material = SubResource("ParticleProcessMaterial_eegys")
draw_pass_1 = SubResource("QuadMesh_ea2fp")
