Add SDF shader for hand

This commit is contained in:
Rodolphe Houdas 2022-11-16 09:26:02 +00:00
parent b81b667a97
commit 3b28f1c5a5
6 changed files with 798 additions and 175 deletions

View file

@ -8,216 +8,217 @@
[ext_resource type="Script" path="res://scripts/ImagePuller.gd" id="4_sgil3"]
[ext_resource type="Script" path="res://scripts/DebugHands.gd" id="8_uah46"]
[sub_resource type="UltraleapBone" id="UltraleapBone_60p2w"]
[sub_resource type="UltraleapBone" id="UltraleapBone_g7ckt"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_7lbi6"]
width = 0.261
[sub_resource type="UltraleapBone" id="UltraleapBone_0iy1e"]
width = 2.31263e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_0g2ik"]
[sub_resource type="UltraleapBone" id="UltraleapBone_slmmg"]
[sub_resource type="UltraleapBone" id="UltraleapBone_vvs30"]
width = 2.04212e-37
[sub_resource type="UltraleapDigit" id="UltraleapDigit_dgpni"]
metacarpal = SubResource("UltraleapBone_0g2ik")
proximal = SubResource("UltraleapBone_slmmg")
intermediate = SubResource("UltraleapBone_0iy1e")
distal = SubResource("UltraleapBone_7lbi6")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_m2fa6"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_dh8l7"]
width = nan
[sub_resource type="UltraleapBone" id="UltraleapBone_3bkj7"]
[sub_resource type="UltraleapBone" id="UltraleapBone_1hy65"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_g2u7t"]
metacarpal = SubResource("UltraleapBone_3bkj7")
proximal = SubResource("UltraleapBone_1hy65")
intermediate = SubResource("UltraleapBone_dh8l7")
distal = SubResource("UltraleapBone_m2fa6")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_0lyh1"]
[sub_resource type="UltraleapBone" id="UltraleapBone_iipxn"]
[sub_resource type="UltraleapBone" id="UltraleapBone_3sia7"]
[sub_resource type="UltraleapBone" id="UltraleapBone_yi4b4"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_5vnu5"]
metacarpal = SubResource("UltraleapBone_3sia7")
proximal = SubResource("UltraleapBone_yi4b4")
intermediate = SubResource("UltraleapBone_iipxn")
distal = SubResource("UltraleapBone_0lyh1")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_hwbxs"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_sdraq"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_4hpny"]
[sub_resource type="UltraleapBone" id="UltraleapBone_db8j3"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_1cy2n"]
metacarpal = SubResource("UltraleapBone_4hpny")
proximal = SubResource("UltraleapBone_db8j3")
intermediate = SubResource("UltraleapBone_sdraq")
distal = SubResource("UltraleapBone_hwbxs")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_4irm2"]
[sub_resource type="UltraleapBone" id="UltraleapBone_pvipj"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_7gldd"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_eeydk"]
[sub_resource type="UltraleapBone" id="UltraleapBone_xrujr"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_5tsc5"]
[sub_resource type="UltraleapBone" id="UltraleapBone_j5gje"]
width = 2.04212e-37
[sub_resource type="UltraleapDigit" id="UltraleapDigit_dpgkm"]
metacarpal = SubResource("UltraleapBone_xrujr")
proximal = SubResource("UltraleapBone_5tsc5")
intermediate = SubResource("UltraleapBone_7gldd")
distal = SubResource("UltraleapBone_4irm2")
[sub_resource type="UltraleapDigit" id="UltraleapDigit_gy2sj"]
metacarpal = SubResource("UltraleapBone_eeydk")
proximal = SubResource("UltraleapBone_j5gje")
intermediate = SubResource("UltraleapBone_pvipj")
distal = SubResource("UltraleapBone_vvs30")
is_extended = true
[sub_resource type="UltraleapPalm" id="UltraleapPalm_hqs0c"]
[sub_resource type="UltraleapHand" id="UltraleapHand_bw4r0"]
thumb = SubResource("UltraleapDigit_dgpni")
index = SubResource("UltraleapDigit_g2u7t")
middle = SubResource("UltraleapDigit_5vnu5")
ring = SubResource("UltraleapDigit_1cy2n")
pinky = SubResource("UltraleapDigit_dpgkm")
arm = SubResource("UltraleapBone_60p2w")
palm = SubResource("UltraleapPalm_hqs0c")
digits = [SubResource("UltraleapDigit_dgpni"), SubResource("UltraleapDigit_g2u7t"), SubResource("UltraleapDigit_5vnu5"), SubResource("UltraleapDigit_1cy2n"), SubResource("UltraleapDigit_dpgkm")]
[sub_resource type="UltraleapBone" id="UltraleapBone_s01d6"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_mphv6"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_fl41v"]
[sub_resource type="UltraleapBone" id="UltraleapBone_3vpae"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_62u62"]
[sub_resource type="UltraleapBone" id="UltraleapBone_amdaf"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_5qail"]
width = 2.31929e-37
[sub_resource type="UltraleapDigit" id="UltraleapDigit_y1mkw"]
metacarpal = SubResource("UltraleapBone_62u62")
proximal = SubResource("UltraleapBone_5qail")
intermediate = SubResource("UltraleapBone_fl41v")
distal = SubResource("UltraleapBone_mphv6")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_58x2k"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_y3f0w"]
[sub_resource type="UltraleapBone" id="UltraleapBone_32l3n"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_nndgs"]
[sub_resource type="UltraleapBone" id="UltraleapBone_gfpy2"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_hd1bc"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_p7xdm"]
metacarpal = SubResource("UltraleapBone_nndgs")
proximal = SubResource("UltraleapBone_hd1bc")
intermediate = SubResource("UltraleapBone_y3f0w")
distal = SubResource("UltraleapBone_58x2k")
[sub_resource type="UltraleapDigit" id="UltraleapDigit_c3wev"]
metacarpal = SubResource("UltraleapBone_32l3n")
proximal = SubResource("UltraleapBone_gfpy2")
intermediate = SubResource("UltraleapBone_amdaf")
distal = SubResource("UltraleapBone_3vpae")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_vdu7e"]
[sub_resource type="UltraleapBone" id="UltraleapBone_k02ek"]
[sub_resource type="UltraleapBone" id="UltraleapBone_5cnaf"]
[sub_resource type="UltraleapBone" id="UltraleapBone_3d1ka"]
[sub_resource type="UltraleapBone" id="UltraleapBone_ueya3"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_ni8yl"]
metacarpal = SubResource("UltraleapBone_3d1ka")
proximal = SubResource("UltraleapBone_ueya3")
intermediate = SubResource("UltraleapBone_5cnaf")
distal = SubResource("UltraleapBone_k02ek")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_t87m1"]
[sub_resource type="UltraleapBone" id="UltraleapBone_1d67u"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_7y6jv"]
[sub_resource type="UltraleapBone" id="UltraleapBone_isges"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_7m3vc"]
width = 2.31929e-37
[sub_resource type="UltraleapDigit" id="UltraleapDigit_wmc47"]
metacarpal = SubResource("UltraleapBone_7y6jv")
proximal = SubResource("UltraleapBone_isges")
intermediate = SubResource("UltraleapBone_1d67u")
distal = SubResource("UltraleapBone_t87m1")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_a68r5"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_0nugs"]
[sub_resource type="UltraleapBone" id="UltraleapBone_dlhn3"]
[sub_resource type="UltraleapBone" id="UltraleapBone_acunq"]
width = 4.62428e-44
[sub_resource type="UltraleapBone" id="UltraleapBone_1ilym"]
width = 2.04212e-37
[sub_resource type="UltraleapDigit" id="UltraleapDigit_6bnci"]
metacarpal = SubResource("UltraleapBone_a68r5")
proximal = SubResource("UltraleapBone_dlhn3")
intermediate = SubResource("UltraleapBone_7m3vc")
distal = SubResource("UltraleapBone_vdu7e")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_8ykej"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_tkh6a"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_8g6cu"]
metacarpal = SubResource("UltraleapBone_1ilym")
proximal = SubResource("UltraleapBone_8ykej")
intermediate = SubResource("UltraleapBone_acunq")
distal = SubResource("UltraleapBone_0nugs")
is_extended = false
[sub_resource type="UltraleapBone" id="UltraleapBone_q8674"]
[sub_resource type="UltraleapPalm" id="UltraleapPalm_5afam"]
[sub_resource type="UltraleapBone" id="UltraleapBone_n0ppa"]
[sub_resource type="UltraleapHand" id="UltraleapHand_1qku5"]
thumb = SubResource("UltraleapDigit_gy2sj")
index = SubResource("UltraleapDigit_c3wev")
middle = SubResource("UltraleapDigit_ni8yl")
ring = SubResource("UltraleapDigit_wmc47")
pinky = SubResource("UltraleapDigit_8g6cu")
arm = SubResource("UltraleapBone_g7ckt")
palm = SubResource("UltraleapPalm_5afam")
digits = [SubResource("UltraleapDigit_gy2sj"), SubResource("UltraleapDigit_c3wev"), SubResource("UltraleapDigit_ni8yl"), SubResource("UltraleapDigit_wmc47"), SubResource("UltraleapDigit_8g6cu")]
[sub_resource type="UltraleapBone" id="UltraleapBone_t34vi"]
[sub_resource type="UltraleapBone" id="UltraleapBone_q0b40"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_lfuwv"]
metacarpal = SubResource("UltraleapBone_n0ppa")
proximal = SubResource("UltraleapBone_t34vi")
intermediate = SubResource("UltraleapBone_q8674")
distal = SubResource("UltraleapBone_tkh6a")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_7asb2"]
[sub_resource type="UltraleapBone" id="UltraleapBone_mxu8u"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_77br3"]
[sub_resource type="UltraleapBone" id="UltraleapBone_x68su"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_coec7"]
[sub_resource type="UltraleapBone" id="UltraleapBone_j05bx"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_ecdio"]
[sub_resource type="UltraleapBone" id="UltraleapBone_ugr3j"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_of323"]
metacarpal = SubResource("UltraleapBone_coec7")
proximal = SubResource("UltraleapBone_ecdio")
intermediate = SubResource("UltraleapBone_77br3")
distal = SubResource("UltraleapBone_7asb2")
[sub_resource type="UltraleapDigit" id="UltraleapDigit_h045l"]
metacarpal = SubResource("UltraleapBone_j05bx")
proximal = SubResource("UltraleapBone_ugr3j")
intermediate = SubResource("UltraleapBone_x68su")
distal = SubResource("UltraleapBone_mxu8u")
is_extended = true
[sub_resource type="UltraleapPalm" id="UltraleapPalm_sil3o"]
[sub_resource type="UltraleapBone" id="UltraleapBone_sjehr"]
width = 2.04212e-37
[sub_resource type="UltraleapHand" id="UltraleapHand_uv62d"]
type = 523932736
visible_time = 576683680
pinch_distance = 2.90069e-18
pinch_strength = 3.07243e-34
thumb = SubResource("UltraleapDigit_y1mkw")
index = SubResource("UltraleapDigit_p7xdm")
middle = SubResource("UltraleapDigit_6bnci")
ring = SubResource("UltraleapDigit_lfuwv")
pinky = SubResource("UltraleapDigit_of323")
arm = SubResource("UltraleapBone_s01d6")
palm = SubResource("UltraleapPalm_sil3o")
digits = [SubResource("UltraleapDigit_y1mkw"), SubResource("UltraleapDigit_p7xdm"), SubResource("UltraleapDigit_6bnci"), SubResource("UltraleapDigit_lfuwv"), SubResource("UltraleapDigit_of323")]
[sub_resource type="UltraleapBone" id="UltraleapBone_svvw1"]
width = 2.31929e-37
[sub_resource type="UltraleapFrame" id="UltraleapFrame_u8pm8"]
left_hand = SubResource("UltraleapHand_bw4r0")
right_hand = SubResource("UltraleapHand_uv62d")
[sub_resource type="UltraleapBone" id="UltraleapBone_s0h4g"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_0dir3"]
width = 2.04212e-37
[sub_resource type="UltraleapDigit" id="UltraleapDigit_l437w"]
metacarpal = SubResource("UltraleapBone_s0h4g")
proximal = SubResource("UltraleapBone_0dir3")
intermediate = SubResource("UltraleapBone_svvw1")
distal = SubResource("UltraleapBone_sjehr")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_ie81l"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_n2p57"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_xoonb"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_mfnja"]
width = 2.04212e-37
[sub_resource type="UltraleapDigit" id="UltraleapDigit_nxxyv"]
metacarpal = SubResource("UltraleapBone_xoonb")
proximal = SubResource("UltraleapBone_mfnja")
intermediate = SubResource("UltraleapBone_n2p57")
distal = SubResource("UltraleapBone_ie81l")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_nr6ib"]
[sub_resource type="UltraleapBone" id="UltraleapBone_ifofg"]
[sub_resource type="UltraleapBone" id="UltraleapBone_v04hn"]
width = 2.04212e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_0damx"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_wkjrw"]
metacarpal = SubResource("UltraleapBone_v04hn")
proximal = SubResource("UltraleapBone_0damx")
intermediate = SubResource("UltraleapBone_ifofg")
distal = SubResource("UltraleapBone_nr6ib")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_yfn1t"]
[sub_resource type="UltraleapBone" id="UltraleapBone_tfvvi"]
width = 2.31929e-37
[sub_resource type="UltraleapBone" id="UltraleapBone_6onis"]
[sub_resource type="UltraleapBone" id="UltraleapBone_wvhs1"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_wqpjp"]
metacarpal = SubResource("UltraleapBone_6onis")
proximal = SubResource("UltraleapBone_wvhs1")
intermediate = SubResource("UltraleapBone_tfvvi")
distal = SubResource("UltraleapBone_yfn1t")
is_extended = true
[sub_resource type="UltraleapPalm" id="UltraleapPalm_ne27h"]
[sub_resource type="UltraleapHand" id="UltraleapHand_6yce5"]
type = 563041008
visible_time = 617206064
pinch_distance = 1.62381e-31
pinch_strength = 4.5141e-34
thumb = SubResource("UltraleapDigit_h045l")
index = SubResource("UltraleapDigit_l437w")
middle = SubResource("UltraleapDigit_nxxyv")
ring = SubResource("UltraleapDigit_wkjrw")
pinky = SubResource("UltraleapDigit_wqpjp")
arm = SubResource("UltraleapBone_q0b40")
palm = SubResource("UltraleapPalm_ne27h")
digits = [SubResource("UltraleapDigit_h045l"), SubResource("UltraleapDigit_l437w"), SubResource("UltraleapDigit_nxxyv"), SubResource("UltraleapDigit_wkjrw"), SubResource("UltraleapDigit_wqpjp")]
[sub_resource type="UltraleapFrame" id="UltraleapFrame_h1nox"]
left_hand = SubResource("UltraleapHand_1qku5")
right_hand = SubResource("UltraleapHand_6yce5")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_a0ntw"]
shader = ExtResource("2_2055g")
@ -437,7 +438,7 @@ rings = 4
[sub_resource type="CapsuleMesh" id="CapsuleMesh_2kqg1"]
material = SubResource("StandardMaterial3D_crn3t")
radius = 0.00734281
radius = 0.0073428
height = 0.0146856
radial_segments = 8
rings = 4
@ -590,7 +591,7 @@ rings = 4
[sub_resource type="CapsuleMesh" id="CapsuleMesh_nnsu1"]
material = SubResource("StandardMaterial3D_u1n1q")
radius = 0.00811001
radius = 0.00811
height = 0.01622
radial_segments = 8
rings = 4
@ -626,7 +627,7 @@ rings = 4
[sub_resource type="CapsuleMesh" id="CapsuleMesh_mtm4i"]
material = SubResource("StandardMaterial3D_jt6xy")
radius = 0.00708436
radius = 0.00708435
height = 0.0141687
radial_segments = 8
rings = 4
@ -634,7 +635,7 @@ rings = 4
[node name="Node3d" type="Node3D"]
[node name="UltraleapHandTracking" type="UltraleapHandTracking" parent="."]
last_frame = SubResource("UltraleapFrame_u8pm8")
last_frame = SubResource("UltraleapFrame_h1nox")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0572538, 0.0773736, 0.281333)
script = ExtResource("1_pwqvd")
@ -666,7 +667,6 @@ size_flags_vertical = 3
theme_override_constants/separation = 0
[node name="TextureRect" type="TextureRect" parent="CanvasLayer/HBoxContainer" node_paths=PackedStringArray("tracker")]
layout_mode = 2
offset_right = 576.0
offset_bottom = 648.0
size_flags_horizontal = 3
@ -678,7 +678,6 @@ img = SubResource("Image_nymqy")
data_img = SubResource("Image_an1lj")
[node name="TextureRect2" type="TextureRect" parent="CanvasLayer/HBoxContainer" node_paths=PackedStringArray("tracker")]
layout_mode = 2
offset_left = 576.0
offset_right = 1152.0
offset_bottom = 648.0

View file

@ -0,0 +1,36 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://d18vxmfysiyw8"]
[ext_resource type="Shader" path="res://shaders/RayMarching.gdshader" id="1_713ba"]
[resource]
render_priority = 0
shader = ExtResource("1_713ba")
shader_parameter/colour = Color(1, 1, 1, 1)
shader_parameter/disable_threshold = null
shader_parameter/epsilon = 0.03
shader_parameter/left_hand_bones_basis = PackedFloat32Array()
shader_parameter/left_hand_bones_length = PackedVector3Array()
shader_parameter/left_hand_bones_offset = PackedVector3Array()
shader_parameter/left_hand_bones_width = PackedVector3Array()
shader_parameter/left_index_distal = null
shader_parameter/left_index_intermediate = null
shader_parameter/left_index_metacarpal = null
shader_parameter/left_index_proximal = null
shader_parameter/left_middle_distal = null
shader_parameter/left_middle_intermediate = null
shader_parameter/left_middle_metacarpal = null
shader_parameter/left_middle_proximal = null
shader_parameter/left_pinky_distal = null
shader_parameter/left_pinky_intermediate = null
shader_parameter/left_pinky_metacarpal = null
shader_parameter/left_pinky_proximal = null
shader_parameter/left_ring_distal = null
shader_parameter/left_ring_intermediate = null
shader_parameter/left_ring_metacarpal = null
shader_parameter/left_ring_proximal = null
shader_parameter/left_thumb_distal = null
shader_parameter/left_thumb_intermediate = null
shader_parameter/left_thumb_metacarpal = null
shader_parameter/left_thumb_proximal = null
shader_parameter/max_iterations = null
shader_parameter/threshold = null

View file

@ -0,0 +1,226 @@
[gd_scene load_steps=66 format=3 uid="uid://b7vwxs7054ms1"]
[ext_resource type="Material" uid="uid://d18vxmfysiyw8" path="res://materials/RayMarching.tres" id="1_f82w7"]
[ext_resource type="Script" path="res://scripts/HandSDFShader.gd" id="2_37vri"]
[ext_resource type="Script" path="res://scripts/Starter.gd" id="3_6705f"]
[ext_resource type="Script" path="res://scripts/FreeLookCamera.gd" id="4_g4jax"]
[sub_resource type="BoxMesh" id="BoxMesh_pxd2x"]
material = ExtResource("1_f82w7")
[sub_resource type="UltraleapBone" id="UltraleapBone_2l76v"]
[sub_resource type="UltraleapBone" id="UltraleapBone_eew4g"]
[sub_resource type="UltraleapBone" id="UltraleapBone_v6usb"]
[sub_resource type="UltraleapBone" id="UltraleapBone_nk21h"]
[sub_resource type="UltraleapBone" id="UltraleapBone_sby5b"]
width = 4.2039e-45
[sub_resource type="UltraleapDigit" id="UltraleapDigit_hibh1"]
metacarpal = SubResource("UltraleapBone_nk21h")
proximal = SubResource("UltraleapBone_sby5b")
intermediate = SubResource("UltraleapBone_v6usb")
distal = SubResource("UltraleapBone_eew4g")
is_extended = false
[sub_resource type="UltraleapBone" id="UltraleapBone_jnno7"]
[sub_resource type="UltraleapBone" id="UltraleapBone_8qujs"]
[sub_resource type="UltraleapBone" id="UltraleapBone_y0xqs"]
[sub_resource type="UltraleapBone" id="UltraleapBone_w16ba"]
width = 8.05994e-19
[sub_resource type="UltraleapDigit" id="UltraleapDigit_iyv5o"]
metacarpal = SubResource("UltraleapBone_y0xqs")
proximal = SubResource("UltraleapBone_w16ba")
intermediate = SubResource("UltraleapBone_8qujs")
distal = SubResource("UltraleapBone_jnno7")
is_extended = false
[sub_resource type="UltraleapBone" id="UltraleapBone_3s20u"]
[sub_resource type="UltraleapBone" id="UltraleapBone_5ydts"]
width = 2.55162e-19
[sub_resource type="UltraleapBone" id="UltraleapBone_1p3a6"]
[sub_resource type="UltraleapBone" id="UltraleapBone_oipwo"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_4ntn8"]
metacarpal = SubResource("UltraleapBone_1p3a6")
proximal = SubResource("UltraleapBone_oipwo")
intermediate = SubResource("UltraleapBone_5ydts")
distal = SubResource("UltraleapBone_3s20u")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_10fyy"]
[sub_resource type="UltraleapBone" id="UltraleapBone_bcdvq"]
[sub_resource type="UltraleapBone" id="UltraleapBone_02y2j"]
[sub_resource type="UltraleapBone" id="UltraleapBone_w3q0o"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_g5x3p"]
metacarpal = SubResource("UltraleapBone_02y2j")
proximal = SubResource("UltraleapBone_w3q0o")
intermediate = SubResource("UltraleapBone_bcdvq")
distal = SubResource("UltraleapBone_10fyy")
is_extended = false
[sub_resource type="UltraleapBone" id="UltraleapBone_d0jld"]
[sub_resource type="UltraleapBone" id="UltraleapBone_c1cw0"]
width = 9.87375e-17
[sub_resource type="UltraleapBone" id="UltraleapBone_phw0a"]
[sub_resource type="UltraleapBone" id="UltraleapBone_4ui8e"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_o6vgg"]
metacarpal = SubResource("UltraleapBone_phw0a")
proximal = SubResource("UltraleapBone_4ui8e")
intermediate = SubResource("UltraleapBone_c1cw0")
distal = SubResource("UltraleapBone_d0jld")
is_extended = false
[sub_resource type="UltraleapPalm" id="UltraleapPalm_rp1bo"]
[sub_resource type="UltraleapHand" id="UltraleapHand_wavde"]
thumb = SubResource("UltraleapDigit_hibh1")
index = SubResource("UltraleapDigit_iyv5o")
middle = SubResource("UltraleapDigit_4ntn8")
ring = SubResource("UltraleapDigit_g5x3p")
pinky = SubResource("UltraleapDigit_o6vgg")
arm = SubResource("UltraleapBone_2l76v")
palm = SubResource("UltraleapPalm_rp1bo")
digits = [SubResource("UltraleapDigit_hibh1"), SubResource("UltraleapDigit_iyv5o"), SubResource("UltraleapDigit_4ntn8"), SubResource("UltraleapDigit_g5x3p"), SubResource("UltraleapDigit_o6vgg")]
[sub_resource type="UltraleapBone" id="UltraleapBone_lmcgi"]
[sub_resource type="UltraleapBone" id="UltraleapBone_itfn3"]
[sub_resource type="UltraleapBone" id="UltraleapBone_2514y"]
[sub_resource type="UltraleapBone" id="UltraleapBone_ylxo6"]
[sub_resource type="UltraleapBone" id="UltraleapBone_qd38w"]
width = 1.39237e-18
[sub_resource type="UltraleapDigit" id="UltraleapDigit_m6m2q"]
metacarpal = SubResource("UltraleapBone_ylxo6")
proximal = SubResource("UltraleapBone_qd38w")
intermediate = SubResource("UltraleapBone_2514y")
distal = SubResource("UltraleapBone_itfn3")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_b8lug"]
[sub_resource type="UltraleapBone" id="UltraleapBone_15o1s"]
[sub_resource type="UltraleapBone" id="UltraleapBone_idqwc"]
[sub_resource type="UltraleapBone" id="UltraleapBone_r56ns"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_d8q8v"]
metacarpal = SubResource("UltraleapBone_idqwc")
proximal = SubResource("UltraleapBone_r56ns")
intermediate = SubResource("UltraleapBone_15o1s")
distal = SubResource("UltraleapBone_b8lug")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_owdnc"]
[sub_resource type="UltraleapBone" id="UltraleapBone_2bqht"]
[sub_resource type="UltraleapBone" id="UltraleapBone_eoj1u"]
[sub_resource type="UltraleapBone" id="UltraleapBone_0yvgb"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_xb0no"]
metacarpal = SubResource("UltraleapBone_eoj1u")
proximal = SubResource("UltraleapBone_0yvgb")
intermediate = SubResource("UltraleapBone_2bqht")
distal = SubResource("UltraleapBone_owdnc")
is_extended = false
[sub_resource type="UltraleapBone" id="UltraleapBone_r8wa3"]
[sub_resource type="UltraleapBone" id="UltraleapBone_end5x"]
[sub_resource type="UltraleapBone" id="UltraleapBone_s6ukd"]
[sub_resource type="UltraleapBone" id="UltraleapBone_n4d73"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_0re2c"]
metacarpal = SubResource("UltraleapBone_s6ukd")
proximal = SubResource("UltraleapBone_n4d73")
intermediate = SubResource("UltraleapBone_end5x")
distal = SubResource("UltraleapBone_r8wa3")
is_extended = true
[sub_resource type="UltraleapBone" id="UltraleapBone_5hltt"]
[sub_resource type="UltraleapBone" id="UltraleapBone_3nqdn"]
[sub_resource type="UltraleapBone" id="UltraleapBone_yhuix"]
[sub_resource type="UltraleapBone" id="UltraleapBone_x1j70"]
[sub_resource type="UltraleapDigit" id="UltraleapDigit_7ns81"]
metacarpal = SubResource("UltraleapBone_yhuix")
proximal = SubResource("UltraleapBone_x1j70")
intermediate = SubResource("UltraleapBone_3nqdn")
distal = SubResource("UltraleapBone_5hltt")
is_extended = false
[sub_resource type="UltraleapPalm" id="UltraleapPalm_f4uay"]
width = 2.30713e-18
[sub_resource type="UltraleapHand" id="UltraleapHand_gecac"]
thumb = SubResource("UltraleapDigit_m6m2q")
index = SubResource("UltraleapDigit_d8q8v")
middle = SubResource("UltraleapDigit_xb0no")
ring = SubResource("UltraleapDigit_0re2c")
pinky = SubResource("UltraleapDigit_7ns81")
arm = SubResource("UltraleapBone_lmcgi")
palm = SubResource("UltraleapPalm_f4uay")
digits = [SubResource("UltraleapDigit_m6m2q"), SubResource("UltraleapDigit_d8q8v"), SubResource("UltraleapDigit_xb0no"), SubResource("UltraleapDigit_0re2c"), SubResource("UltraleapDigit_7ns81")]
[sub_resource type="UltraleapFrame" id="UltraleapFrame_pimlo"]
left_hand = SubResource("UltraleapHand_wavde")
right_hand = SubResource("UltraleapHand_gecac")
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_rkcie"]
[sub_resource type="Sky" id="Sky_xnkye"]
sky_material = SubResource("ProceduralSkyMaterial_rkcie")
[sub_resource type="Environment" id="Environment_5xgn3"]
background_mode = 2
sky = SubResource("Sky_xnkye")
[node name="RayMarchingHands" type="Node3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="." node_paths=PackedStringArray("tracker")]
mesh = SubResource("BoxMesh_pxd2x")
script = ExtResource("2_37vri")
tracker = NodePath("../UltraleapHandTracking")
[node name="UltraleapHandTracking" type="UltraleapHandTracking" parent="."]
last_frame = SubResource("UltraleapFrame_pimlo")
script = ExtResource("3_6705f")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.94971)
script = ExtResource("4_g4jax")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_5xgn3")

View file

@ -0,0 +1,113 @@
extends Camera3D
# Modifier keys' speed multiplier
const SHIFT_MULTIPLIER = 2.5
const ALT_MULTIPLIER = 1.0 / SHIFT_MULTIPLIER
@export var sensitivity : float = 0.25
# Mouse state
var _mouse_position = Vector2(0.0, 0.0)
var _total_pitch = 0.0
# Movement state
var _direction = Vector3(0.0, 0.0, 0.0)
var _velocity = Vector3(0.0, 0.0, 0.0)
var _acceleration = 30
var _deceleration = -10
var _vel_multiplier = 4
# Keyboard state
var _w = false
var _s = false
var _a = false
var _d = false
var _q = false
var _e = false
var _shift = false
var _alt = false
func _input(event):
# Receives mouse motion
if event is InputEventMouseMotion:
_mouse_position = event.relative
# Receives mouse button input
if event is InputEventMouseButton:
match event.button_index:
MOUSE_BUTTON_RIGHT: # Only allows rotation if right click down
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED if event.pressed else Input.MOUSE_MODE_VISIBLE)
MOUSE_BUTTON_WHEEL_UP: # Increases max velocity
_vel_multiplier = clamp(_vel_multiplier * 1.1, 0.2, 20)
MOUSE_BUTTON_WHEEL_DOWN: # Decereases max velocity
_vel_multiplier = clamp(_vel_multiplier / 1.1, 0.2, 20)
# Receives key input
if event is InputEventKey:
match event.keycode:
KEY_W:
_w = event.pressed
KEY_S:
_s = event.pressed
KEY_A:
_a = event.pressed
KEY_D:
_d = event.pressed
KEY_Q:
_q = event.pressed
KEY_E:
_e = event.pressed
KEY_SHIFT:
_shift = event.pressed
KEY_ALT:
_alt = event.pressed
# Updates mouselook and movement every frame
func _process(delta):
_update_mouselook()
_update_movement(delta)
# Updates camera movement
func _update_movement(delta):
# Computes desired direction from key states
_direction = Vector3(float(_d) - float(_a),
float(_e) - float(_q),
float(_s) - float(_w))
# Computes the change in velocity due to desired direction and "drag"
# The "drag" is a constant acceleration on the camera to bring it's velocity to 0
var offset = _direction.normalized() * _acceleration * _vel_multiplier * delta \
+ _velocity.normalized() * _deceleration * _vel_multiplier * delta
# Compute modifiers' speed multiplier
var speed_multi = 1
if _shift: speed_multi *= SHIFT_MULTIPLIER
if _alt: speed_multi *= ALT_MULTIPLIER
# Checks if we should bother translating the camera
if _direction == Vector3.ZERO and offset.length_squared() > _velocity.length_squared():
# Sets the velocity to 0 to prevent jittering due to imperfect deceleration
_velocity = Vector3.ZERO
else:
# Clamps speed to stay within maximum value (_vel_multiplier)
_velocity.x = clamp(_velocity.x + offset.x, -_vel_multiplier, _vel_multiplier)
_velocity.y = clamp(_velocity.y + offset.y, -_vel_multiplier, _vel_multiplier)
_velocity.z = clamp(_velocity.z + offset.z, -_vel_multiplier, _vel_multiplier)
translate(_velocity * delta * speed_multi)
# Updates mouse look
func _update_mouselook():
# Only rotates mouse if the mouse is captured
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
_mouse_position *= sensitivity
var yaw = _mouse_position.x
var pitch = _mouse_position.y
_mouse_position = Vector2(0, 0)
# Prevents looking up/down too far
pitch = clamp(pitch, -90 - _total_pitch, 90 - _total_pitch)
_total_pitch += pitch
rotate_y(deg_to_rad(-yaw))
rotate_object_local(Vector3(1,0,0), deg_to_rad(-pitch))

View file

@ -0,0 +1,50 @@
extends MeshInstance3D
@export var tracker : UltraleapHandTracking
var material : ShaderMaterial
@onready var offsets : PackedVector3Array = PackedVector3Array()
@onready var widths : PackedFloat32Array = PackedFloat32Array()
@onready var lengths : PackedFloat32Array = PackedFloat32Array()
func _ready():
material = mesh.material
func _process(_delta):
var frame = tracker.last_frame
set_hand_transform(frame.left_hand, "left")
material.set_shader_parameter("left_hand_bones_offset", offsets)
material.set_shader_parameter("left_hand_bones_width", widths)
material.set_shader_parameter("left_hand_bones_length", lengths)
func set_hand_transform(hand : UltraleapHand, name : String):
offsets.clear()
widths.clear()
lengths.clear()
set_finger_transform(hand.thumb, name + "_thumb")
set_finger_transform(hand.index, name + "_index")
set_finger_transform(hand.middle, name + "_middle")
set_finger_transform(hand.ring, name + "_ring")
set_finger_transform(hand.pinky, name + "_pinky")
func set_finger_transform(finger : UltraleapDigit, name : String):
set_bone_transform(finger.metacarpal, name + "_metacarpal")
set_bone_transform(finger.proximal, name + "_proximal")
set_bone_transform(finger.intermediate, name + "_intermediate")
set_bone_transform(finger.distal, name + "_distal")
func set_bone_transform(bone : UltraleapBone, name : String):
var pos = (bone.next_joint + bone.prev_joint) / 2
var length = (bone.next_joint - bone.prev_joint).length()
var transform_m : Transform3D = Transform3D(global_transform)
pos = transform_m * pos
# Multiply by quaternion, which is this object rotation, to rotate the hands
var rot = (quaternion * bone.rotation * Quaternion(Vector3.RIGHT, deg_to_rad(90))).get_euler()
material.set_shader_parameter(name, -pos)
offsets.push_back(-pos)
widths.push_back(bone.width)
lengths.push_back(length)

View file

@ -0,0 +1,199 @@
shader_type spatial;
uniform bool disable_threshold = false;
uniform float threshold = 0.001f;
uniform int max_iterations = 300;
uniform vec4 colour : source_color;
uniform float epsilon = 0.1f;
uniform mat3 left_hand_bones_basis[20];
uniform vec3 left_hand_bones_offset[20];
uniform float left_hand_bones_length[20];
uniform float left_hand_bones_width[20];
uniform vec3 left_thumb_metacarpal = vec3(0);
uniform vec3 left_thumb_proximal = vec3(0);
uniform vec3 left_thumb_intermediate = vec3(0);
uniform vec3 left_thumb_distal = vec3(0);
uniform vec3 left_index_metacarpal = vec3(0);
uniform vec3 left_index_proximal = vec3(0);
uniform vec3 left_index_intermediate = vec3(0);
uniform vec3 left_index_distal = vec3(0);
uniform vec3 left_middle_metacarpal = vec3(0);
uniform vec3 left_middle_proximal = vec3(0);
uniform vec3 left_middle_intermediate = vec3(0);
uniform vec3 left_middle_distal = vec3(0);
uniform vec3 left_ring_metacarpal = vec3(0);
uniform vec3 left_ring_proximal = vec3(0);
uniform vec3 left_ring_intermediate = vec3(0);
uniform vec3 left_ring_distal = vec3(0);
uniform vec3 left_pinky_metacarpal = vec3(0);
uniform vec3 left_pinky_proximal = vec3(0);
uniform vec3 left_pinky_intermediate = vec3(0);
uniform vec3 left_pinky_distal = vec3(0);
// polynomial smooth min
float sminCubic( float a, float b, float k )
{
float h = max( k-abs(a-b), 0.0 )/k;
return min( a, b ) - h*h*h*k*(1.0/6.0);
}
float intersectSDF(float distA, float distB) {
return max(distA, distB);
}
float unionSDF(float distA, float distB) {
return min(distA, distB);
}
float differenceSDF(float distA, float distB) {
return max(distA, -distB);
}
void vertex() {
//POSITION = vec4(VERTEX, 1.0);
}
float sdEllipsoid( vec3 p, vec3 r ) {
float k0 = length(p/r);
float k1 = length(p/(r*r));
return (k0<1.0) ? (k0-1.0)*min(min(r.x,r.y),r.z) : k0*(k0-1.0)/k1;
}
float sdPlane(vec3 p, vec3 n, float h) {
return dot(n, p) + h;
}
float sdBox( vec3 b, vec3 p ) {
vec3 q = abs(p) - b;
return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
}
float dstFromSphere(vec3 target, vec3 pos, float r) {
return distance(target, pos) - r;
}
float sdVerticalCapsule( vec3 p, float h, float r ) {
p.y -= clamp( p.y, 0.0, h );
return length( p ) - r;
}
float sdFinger(vec3 p, int index) {
return
sminCubic(
sminCubic(
sdVerticalCapsule(p + left_hand_bones_offset[index + 3], left_hand_bones_length[index + 3], left_hand_bones_width[index + 3] / 2.0),
sdVerticalCapsule(p + left_hand_bones_offset[index + 2], left_hand_bones_length[index + 2], left_hand_bones_width[index + 2] / 2.0),
epsilon
),
sdVerticalCapsule(p + left_hand_bones_offset[index + 1], left_hand_bones_length[index + 1], left_hand_bones_width[index + 1] / 2.0),
epsilon
);
}
float get_distance(vec3 p) {
float palm =
sminCubic(
sminCubic(
sminCubic(
sminCubic(
sdVerticalCapsule(p + left_hand_bones_offset[0], left_hand_bones_length[0], left_hand_bones_width[0] / 2.0),
sdVerticalCapsule(p + left_hand_bones_offset[4], left_hand_bones_length[4], left_hand_bones_width[4] / 2.0),
epsilon
),
sdVerticalCapsule(p + left_hand_bones_offset[8], left_hand_bones_length[8], left_hand_bones_width[8] / 2.0),
epsilon
),
sdVerticalCapsule(p + left_hand_bones_offset[12], left_hand_bones_length[12], left_hand_bones_width[12] / 2.0),
epsilon
),
sdVerticalCapsule(p + left_hand_bones_offset[16], left_hand_bones_length[16], left_hand_bones_width[16] / 2.0),
epsilon
);
float thumb = sdFinger(p, 0);
float index = sdFinger(p, 4);
float middle = sdFinger(p, 8);
float ring = sdFinger(p, 12);
float pinky = sdFinger(p, 16);
return
sminCubic(
unionSDF(
unionSDF(
unionSDF(
unionSDF(
thumb, index
), middle
), ring
), pinky
),
palm,
epsilon
);
}
vec3 get_normal(vec3 p) {
vec2 e = vec2(1e-5, 0);
vec3 n = get_distance(p) - vec3(
get_distance(p - e.xyy),
get_distance(p - e.yxy),
get_distance(p - e.yyx)
);
return normalize(n);
}
vec4 rayMarch(vec3 orig, vec3 dir) {
vec3 sphere_orig = vec3(0, 0, 0);
float dst = get_distance(orig);
int inc = 0;
for (int i = 0; i < max_iterations; i++) {
if (dst <= threshold && !disable_threshold) {
break;
}
orig += dst * dir;
dst = get_distance(orig);
}
if (dst <= threshold) {
// We touched a shape
return vec4(orig, 1.0f);
}
else {
// Render some white transparent background so we can still see the quad
return vec4(vec3(1), 0);
}
}
void fragment() {
vec2 uv = SCREEN_UV * 2.0 - 1.0;
vec4 camera = INV_VIEW_MATRIX * INV_PROJECTION_MATRIX * vec4(uv, 1, 1);
vec3 orig = INV_VIEW_MATRIX[3].xyz;
vec3 dir = normalize(camera.xyz);
vec4 point = rayMarch(orig, dir);
// Render white transparent background by default
vec4 col = vec4(1, 1, 1, 0.1f);
// The w member of the vec4 is used to convey that we hit something.
// Let put a colour on that and compute the normal
if (point.w > 0.0f) {
col = colour;
col.a = point.w;
NORMAL = (vec4(get_normal(point.xyz), 1) * INV_VIEW_MATRIX).xyz;
}
ALPHA = col.a;
ALBEDO = col.rgb;
}