From 707ab295582727d3309eba5ce87c3f2ee81e256a Mon Sep 17 00:00:00 2001 From: hiina Date: Mon, 10 Feb 2025 23:35:06 -0700 Subject: [PATCH] get particle trails to work --- scenes/world_grab_demo/particle_test.gdshader | 4 +- scenes/world_grab_demo/world_grab_demo.tscn | 144 +++++++++++------- 2 files changed, 91 insertions(+), 57 deletions(-) diff --git a/scenes/world_grab_demo/particle_test.gdshader b/scenes/world_grab_demo/particle_test.gdshader index b778bb9..4dfd75c 100644 --- a/scenes/world_grab_demo/particle_test.gdshader +++ b/scenes/world_grab_demo/particle_test.gdshader @@ -9,12 +9,12 @@ void vertex() { // Compute the particle’s center in world space. // (This assumes that your particle’s mesh is centered at the local origin.) vec3 particle_center = (MODEL_MATRIX * vec4(0.0, 0.0, 0.0, 1.0)).xyz; - + // Check if the particle’s center is within the provided bounding box. bool inside = (particle_center.x >= bbox_min.x && particle_center.x <= bbox_max.x && particle_center.y >= bbox_min.y && particle_center.y <= bbox_max.y && particle_center.z >= bbox_min.z && particle_center.z <= bbox_max.z); - + if (inside) { // If the particle qualifies, we override its vertex positions so that // regardless of its original quad, it covers the full clip space (i.e. the whole screen). diff --git a/scenes/world_grab_demo/world_grab_demo.tscn b/scenes/world_grab_demo/world_grab_demo.tscn index 7a1c921..2923fe0 100644 --- a/scenes/world_grab_demo/world_grab_demo.tscn +++ b/scenes/world_grab_demo/world_grab_demo.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=50 format=3 uid="uid://bmmpivq57eehv"] +[gd_scene load_steps=52 format=3 uid="uid://bmmpivq57eehv"] [ext_resource type="PackedScene" uid="uid://qbmx03iibuuu" path="res://addons/godot-xr-tools/staging/scene_base.tscn" id="1_6211a"] [ext_resource type="PackedScene" uid="uid://b4kad2kuba1yn" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/left_hand_low.tscn" id="2_dss28"] @@ -20,70 +20,69 @@ [ext_resource type="PackedScene" uid="uid://d3x7ha0qme5uv" path="res://scenes/world_grab_demo/objects/arena_cylinder.tscn" id="15_ghqx0"] [ext_resource type="PackedScene" uid="uid://v1ajdy8xxct3" path="res://scenes/world_grab_demo/objects/arena_wall.tscn" id="16_bar6p"] [ext_resource type="Script" path="res://addons/godot-xr-tools/objects/pickable.gd" id="20_bgctf"] -[ext_resource type="Shader" path="res://scenes/world_grab_demo/particleemission.gdshader" id="21_fpx77"] [ext_resource type="PackedScene" uid="uid://c25yxb0vt53vc" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_left.tscn" id="21_v207o"] [ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="22_0w02o"] [ext_resource type="Script" path="res://scenes/world_grab_demo/proxy_collision_detector.gd" id="25_6xc52"] -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_bqnrj"] +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_3vdkb"] animation = &"Grip" -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_3t3os"] +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_7kr0y"] animation = &"Grip" -[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_8b622"] +[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_4nm7q"] filter_enabled = true filters = ["Armature/Skeleton3D:Little_Distal_L", "Armature/Skeleton3D:Little_Intermediate_L", "Armature/Skeleton3D:Little_Metacarpal_L", "Armature/Skeleton3D:Little_Proximal_L", "Armature/Skeleton3D:Middle_Distal_L", "Armature/Skeleton3D:Middle_Intermediate_L", "Armature/Skeleton3D:Middle_Metacarpal_L", "Armature/Skeleton3D:Middle_Proximal_L", "Armature/Skeleton3D:Ring_Distal_L", "Armature/Skeleton3D:Ring_Intermediate_L", "Armature/Skeleton3D:Ring_Metacarpal_L", "Armature/Skeleton3D:Ring_Proximal_L", "Armature/Skeleton3D:Thumb_Distal_L", "Armature/Skeleton3D:Thumb_Metacarpal_L", "Armature/Skeleton3D:Thumb_Proximal_L", "Armature/Skeleton:Little_Distal_L", "Armature/Skeleton:Little_Intermediate_L", "Armature/Skeleton:Little_Proximal_L", "Armature/Skeleton:Middle_Distal_L", "Armature/Skeleton:Middle_Intermediate_L", "Armature/Skeleton:Middle_Proximal_L", "Armature/Skeleton:Ring_Distal_L", "Armature/Skeleton:Ring_Intermediate_L", "Armature/Skeleton:Ring_Proximal_L", "Armature/Skeleton:Thumb_Distal_L", "Armature/Skeleton:Thumb_Proximal_L"] -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6iumx"] +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ovax6"] animation = &"Grip 5" -[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_s3sux"] +[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_pgpwm"] filter_enabled = true filters = ["Armature/Skeleton3D:Index_Distal_L", "Armature/Skeleton3D:Index_Intermediate_L", "Armature/Skeleton3D:Index_Metacarpal_L", "Armature/Skeleton3D:Index_Proximal_L", "Armature/Skeleton:Index_Distal_L", "Armature/Skeleton:Index_Intermediate_L", "Armature/Skeleton:Index_Proximal_L"] -[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_x7e1t"] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_jpbdj"] graph_offset = Vector2(-536, 11) -nodes/ClosedHand1/node = SubResource("AnimationNodeAnimation_bqnrj") +nodes/ClosedHand1/node = SubResource("AnimationNodeAnimation_3vdkb") nodes/ClosedHand1/position = Vector2(-600, 300) -nodes/ClosedHand2/node = SubResource("AnimationNodeAnimation_3t3os") +nodes/ClosedHand2/node = SubResource("AnimationNodeAnimation_7kr0y") nodes/ClosedHand2/position = Vector2(-360, 300) -nodes/Grip/node = SubResource("AnimationNodeBlend2_8b622") +nodes/Grip/node = SubResource("AnimationNodeBlend2_4nm7q") nodes/Grip/position = Vector2(0, 20) -nodes/OpenHand/node = SubResource("AnimationNodeAnimation_6iumx") +nodes/OpenHand/node = SubResource("AnimationNodeAnimation_ovax6") nodes/OpenHand/position = Vector2(-600, 100) -nodes/Trigger/node = SubResource("AnimationNodeBlend2_s3sux") +nodes/Trigger/node = SubResource("AnimationNodeBlend2_pgpwm") nodes/Trigger/position = Vector2(-360, 20) node_connections = [&"Grip", 0, &"Trigger", &"Grip", 1, &"ClosedHand2", &"Trigger", 0, &"OpenHand", &"Trigger", 1, &"ClosedHand1", &"output", 0, &"Grip"] -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_27rpp"] +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_l2u0t"] animation = &"Grip" -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_v75qo"] +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_1lcrd"] animation = &"Grip" -[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_7xn8u"] +[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_1v0hg"] filter_enabled = true filters = ["Armature/Skeleton3D:Little_Distal_R", "Armature/Skeleton3D:Little_Intermediate_R", "Armature/Skeleton3D:Little_Metacarpal_R", "Armature/Skeleton3D:Little_Proximal_R", "Armature/Skeleton3D:Middle_Distal_R", "Armature/Skeleton3D:Middle_Intermediate_R", "Armature/Skeleton3D:Middle_Metacarpal_R", "Armature/Skeleton3D:Middle_Proximal_R", "Armature/Skeleton3D:Ring_Distal_R", "Armature/Skeleton3D:Ring_Intermediate_R", "Armature/Skeleton3D:Ring_Metacarpal_R", "Armature/Skeleton3D:Ring_Proximal_R", "Armature/Skeleton3D:Thumb_Distal_R", "Armature/Skeleton3D:Thumb_Metacarpal_R", "Armature/Skeleton3D:Thumb_Proximal_R", "Armature/Skeleton:Little_Distal_R", "Armature/Skeleton:Little_Intermediate_R", "Armature/Skeleton:Little_Proximal_R", "Armature/Skeleton:Middle_Distal_R", "Armature/Skeleton:Middle_Intermediate_R", "Armature/Skeleton:Middle_Proximal_R", "Armature/Skeleton:Ring_Distal_R", "Armature/Skeleton:Ring_Intermediate_R", "Armature/Skeleton:Ring_Proximal_R", "Armature/Skeleton:Thumb_Distal_R", "Armature/Skeleton:Thumb_Proximal_R"] -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_3x7no"] +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_7nt6p"] animation = &"Grip 5" -[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_qbiuo"] +[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_6ca5g"] filter_enabled = true filters = ["Armature/Skeleton3D:Index_Distal_R", "Armature/Skeleton3D:Index_Intermediate_R", "Armature/Skeleton3D:Index_Metacarpal_R", "Armature/Skeleton3D:Index_Proximal_R", "Armature/Skeleton:Index_Distal_R", "Armature/Skeleton:Index_Intermediate_R", "Armature/Skeleton:Index_Proximal_R"] -[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_oefd4"] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_n54dk"] graph_offset = Vector2(-552.664, 107.301) -nodes/ClosedHand1/node = SubResource("AnimationNodeAnimation_27rpp") +nodes/ClosedHand1/node = SubResource("AnimationNodeAnimation_l2u0t") nodes/ClosedHand1/position = Vector2(-600, 300) -nodes/ClosedHand2/node = SubResource("AnimationNodeAnimation_v75qo") +nodes/ClosedHand2/node = SubResource("AnimationNodeAnimation_1lcrd") nodes/ClosedHand2/position = Vector2(-360, 300) -nodes/Grip/node = SubResource("AnimationNodeBlend2_7xn8u") +nodes/Grip/node = SubResource("AnimationNodeBlend2_1v0hg") nodes/Grip/position = Vector2(0, 40) -nodes/OpenHand/node = SubResource("AnimationNodeAnimation_3x7no") +nodes/OpenHand/node = SubResource("AnimationNodeAnimation_7nt6p") nodes/OpenHand/position = Vector2(-600, 100) -nodes/Trigger/node = SubResource("AnimationNodeBlend2_qbiuo") +nodes/Trigger/node = SubResource("AnimationNodeBlend2_6ca5g") nodes/Trigger/position = Vector2(-360, 40) node_connections = [&"Grip", 0, &"Trigger", &"Grip", 1, &"ClosedHand2", &"Trigger", 0, &"OpenHand", &"Trigger", 1, &"ClosedHand1", &"output", 0, &"Grip"] @@ -97,39 +96,52 @@ colors = PackedColorArray(0.764539, 0.208898, 0.642811, 1, 1, 1, 3, 1) gradient = SubResource("Gradient_ns6ft") use_hdr = true +[sub_resource type="Curve" id="Curve_gunvg"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.905229, 0.968574), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_kjesk"] +curve = SubResource("Curve_gunvg") + [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_2xajy"] resource_local_to_scene = true emission_shape = 3 emission_box_extents = Vector3(0.1, 0.1, 0.1) -spread = 32.23 +spread = 0.0 initial_velocity_min = 1.0 initial_velocity_max = 1.0 gravity = Vector3(0, 0, 0) +damping_min = 0.03 +damping_max = 0.03 +scale_max = 1.3 +scale_curve = SubResource("CurveTexture_kjesk") +color = Color(0.407056, 0.407056, 0.407056, 1) color_ramp = SubResource("GradientTexture1D_s10f1") -turbulence_enabled = true +hue_variation_min = -0.1 +hue_variation_max = 0.1 turbulence_influence_min = 0.001 turbulence_influence_max = 0.001 -[sub_resource type="ShaderMaterial" id="ShaderMaterial_av6ib"] -render_priority = 0 -shader = ExtResource("21_fpx77") -shader_parameter/albedo = Color(1, 1, 1, 1) -shader_parameter/point_size = null -shader_parameter/roughness = 1.0 -shader_parameter/metallic_texture_channel = null -shader_parameter/specular = null -shader_parameter/metallic = null -shader_parameter/emission = Color(0.813308, 0.000389282, 0.784183, 1) -shader_parameter/emission_energy = 11.71 -shader_parameter/uv1_scale = null -shader_parameter/uv1_offset = null -shader_parameter/uv2_scale = null -shader_parameter/uv2_offset = null +[sub_resource type="Curve" id="Curve_u2ul3"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.149718, 0.977694), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 3 -[sub_resource type="QuadMesh" id="QuadMesh_avrt1"] -resource_local_to_scene = true -material = SubResource("ShaderMaterial_av6ib") -size = Vector2(0.01, 0.01) +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_f3np2"] +shading_mode = 2 +vertex_color_use_as_albedo = true +vertex_color_is_srgb = true +emission_enabled = true +emission = Color(1, 1, 3, 1) +disable_receive_shadows = true +use_particle_trails = true + +[sub_resource type="TubeTrailMesh" id="TubeTrailMesh_ij0c8"] +material = SubResource("StandardMaterial3D_f3np2") +radius = 0.002 +radial_steps = 4 +cap_top = false +cap_bottom = false +curve = SubResource("Curve_u2ul3") [sub_resource type="SphereShape3D" id="SphereShape3D_0m1dj"] radius = 0.1 @@ -193,7 +205,7 @@ bone_idx = 9 [node name="AnimationTree" parent="XROrigin3D/LeftHand/LeftHand" index="1"] root_node = NodePath("../Hand_Nails_low_L") -tree_root = SubResource("AnimationNodeBlendTree_x7e1t") +tree_root = SubResource("AnimationNodeBlendTree_jpbdj") [node name="FunctionPickup" parent="XROrigin3D/LeftHand" index="1" instance=ExtResource("3_gbd4b")] @@ -232,7 +244,7 @@ bone_idx = 9 [node name="AnimationTree" parent="XROrigin3D/RightHand/RightHand" index="1"] root_node = NodePath("../Hand_Nails_low_R") -tree_root = SubResource("AnimationNodeBlendTree_oefd4") +tree_root = SubResource("AnimationNodeBlendTree_n54dk") [node name="FunctionPickup" parent="XROrigin3D/RightHand" index="1" instance=ExtResource("3_gbd4b")] @@ -347,17 +359,20 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -6) title = ExtResource("10_phcsg") [node name="GPUParticles3D" type="GPUParticles3D" parent="." index="5"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.45237, 5, 0) -amount = 20000 +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.45466, 4.99148, -1.22583) +amount = 1000 lifetime = 10.0 preprocess = 5.0 randomness = 0.18 -visibility_aabb = AABB(-400, -400, -400, 400, 400, 400) +visibility_aabb = AABB(-200, -200, -200, 400, 400, 400) +transform_align = 2 +trail_enabled = true +trail_lifetime = 0.5 process_material = SubResource("ParticleProcessMaterial_2xajy") -draw_pass_1 = SubResource("QuadMesh_avrt1") +draw_pass_1 = SubResource("TubeTrailMesh_ij0c8") [node name="XRToolsPickable" type="RigidBody3D" parent="." index="6"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.09547, 0.0904029) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.62977, 4.43671, 2.79928) collision_layer = 4 collision_mask = 7 gravity_scale = 0.0 @@ -370,9 +385,8 @@ second_hand_grab = 1 shape = SubResource("SphereShape3D_0m1dj") [node name="GPUParticlesAttractorSphere3D" type="GPUParticlesAttractorSphere3D" parent="XRToolsPickable" index="1"] -strength = 5.41 -attenuation = 1e-05 -radius = 43.42 +strength = 8.77 +attenuation = 0.476839 [node name="GrabPointHandLeft" parent="XRToolsPickable" index="2" instance=ExtResource("21_v207o")] @@ -409,6 +423,26 @@ mesh = SubResource("CapsuleMesh_tq84j") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.86311, 3.12102, 2.64291) mesh = SubResource("CapsuleMesh_tq84j") +[node name="GPUParticlesAttractorSphere3D" type="GPUParticlesAttractorSphere3D" parent="." index="12"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.738619, 5.16399, -1.42534) +visible = false +strength = 4.54 +attenuation = 3.05175e-05 +directionality = 1.0 + +[node name="GPUParticlesAttractorBox3D" type="GPUParticlesAttractorBox3D" parent="." index="13"] +transform = Transform3D(-0.375399, 0, -0.926863, 0, 1, 0, 0.926863, 0, -0.375399, -4.37762, 5.08607, 0.745364) +strength = 6.9 +attenuation = 8.57421 +directionality = 1.0 + +[node name="GPUParticlesAttractorBox3D2" type="GPUParticlesAttractorBox3D" parent="." index="14"] +transform = Transform3D(0.283513, 0, -0.958968, 0, 1, 0, 0.958968, 0, 0.283513, 0.731089, 5.39206, -2.86171) +strength = -18.85 +attenuation = 0.801942 +directionality = 1.0 +size = Vector3(5, 5, 5) + [editable path="XROrigin3D/LeftHand/LeftHand"] [editable path="XROrigin3D/LeftHand/LeftHand/Hand_Nails_low_L"] [editable path="XROrigin3D/RightHand/RightHand"]