diff --git a/asset_dev/arrow.blend b/asset_dev/arrow.blend new file mode 100644 index 0000000..1ca9035 Binary files /dev/null and b/asset_dev/arrow.blend differ diff --git a/asset_dev/arrow.blend.import b/asset_dev/arrow.blend.import new file mode 100644 index 0000000..731a61b --- /dev/null +++ b/asset_dev/arrow.blend.import @@ -0,0 +1,50 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://byrygy8j6yeur" +valid=false + +[deps] + +source_file="res://asset_dev/arrow.blend" + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +meshes/force_disable_compression=false +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="" +_subresources={} +blender/nodes/visible=0 +blender/nodes/active_collection_only=false +blender/nodes/punctual_lights=true +blender/nodes/cameras=true +blender/nodes/custom_properties=true +blender/nodes/modifiers=1 +blender/meshes/colors=false +blender/meshes/uvs=true +blender/meshes/normals=true +blender/meshes/tangents=true +blender/meshes/skins=2 +blender/meshes/export_bones_deforming_mesh_only=false +blender/materials/unpack_enabled=true +blender/materials/export_materials=1 +blender/animation/limit_playback=true +blender/animation/always_sample=true +blender/animation/group_tracks=true diff --git a/asset_dev/arrow.blend1 b/asset_dev/arrow.blend1 new file mode 100644 index 0000000..a8013f5 Binary files /dev/null and b/asset_dev/arrow.blend1 differ diff --git a/assets/materials/gummy_material.tres b/assets/materials/gummy_material.tres new file mode 100644 index 0000000..de5d4e3 --- /dev/null +++ b/assets/materials/gummy_material.tres @@ -0,0 +1,45 @@ +[gd_resource type="ShaderMaterial" load_steps=8 format=3 uid="uid://d3ka0yjhxu5ks"] + +[ext_resource type="Shader" path="res://src/shaders/frosted_glass.gdshader" id="1_jx055"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_ieey5"] +noise_type = 2 +fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_7g8ap"] +seamless = true +as_normal_map = true +noise = SubResource("FastNoiseLite_ieey5") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_etunr"] +noise_type = 2 +seed = 1 +fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_5huy0"] +seamless = true +noise = SubResource("FastNoiseLite_etunr") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_bxk71"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_umhmc"] +noise = SubResource("FastNoiseLite_bxk71") + +[resource] +render_priority = 0 +shader = ExtResource("1_jx055") +shader_parameter/albedo = Color(1, 0.6, 1, 0.34902) +shader_parameter/roughness = 0.55 +shader_parameter/refraction = 0.0500008 +shader_parameter/refraction_texture_channel = Vector4(1, 0, 0, 0) +shader_parameter/texture_refraction = SubResource("NoiseTexture2D_5huy0") +shader_parameter/normal_strength = 0.200001 +shader_parameter/normal_map = SubResource("NoiseTexture2D_7g8ap") +shader_parameter/subsurface_scattering_strength = 1.0 +shader_parameter/texture_subsurface_scattering = SubResource("NoiseTexture2D_umhmc") +shader_parameter/edge_color = Color(0, 0, 0, 1) +shader_parameter/surface_contribution = 0.9 +shader_parameter/specular_contribution = 20.0 +shader_parameter/refraction_contribution = 3.0 +shader_parameter/uv1_scale = Vector3(1, 1, 1) +shader_parameter/uv1_offset = Vector3(0, 0, 0) diff --git a/assets/models/ui/arrow/arrow.glb b/assets/models/ui/arrow/arrow.glb new file mode 100644 index 0000000..6ffa494 Binary files /dev/null and b/assets/models/ui/arrow/arrow.glb differ diff --git a/assets/models/ui/arrow/arrow.glb.import b/assets/models/ui/arrow/arrow.glb.import new file mode 100644 index 0000000..4af3905 --- /dev/null +++ b/assets/models/ui/arrow/arrow.glb.import @@ -0,0 +1,43 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://bw54bi35myvpg" +path="res://.godot/imported/arrow.glb-529b70086bc22d1673d9206ecda53d79.scn" + +[deps] + +source_file="res://assets/models/ui/arrow/arrow.glb" +dest_files=["res://.godot/imported/arrow.glb-529b70086bc22d1673d9206ecda53d79.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +meshes/force_disable_compression=false +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="" +_subresources={ +"materials": { +"Material": { +"use_external/enabled": false, +"use_external/path": "res://assets/materials/gummy_material.tres" +} +} +} +gltf/naming_version=1 +gltf/embedded_image_handling=1 diff --git a/src/shaders/frosted_glass.gdshader b/src/shaders/frosted_glass.gdshader new file mode 100644 index 0000000..b2c85ed --- /dev/null +++ b/src/shaders/frosted_glass.gdshader @@ -0,0 +1,76 @@ +shader_type spatial; +// render_mode blend_mix, depth_draw_always, cull_disabled; +render_mode diffuse_burley, specular_schlick_ggx, blend_mix, depth_draw_always, cull_disabled, sss_mode_skin; + +group_uniforms albedo; +uniform vec4 albedo: source_color = vec4(1.0, 1.0, 1.0, 0.0); +uniform sampler2D albedo_texture: source_color, hint_default_white; + +group_uniforms roughness; +uniform float roughness: hint_range(0.0, 1.0) = 0.15; +uniform sampler2D roughness_texture: hint_roughness_r; + +group_uniforms refraction; +uniform float refraction: hint_range(-16,16) = 0.5; +uniform sampler2D texture_refraction: filter_linear_mipmap,repeat_enable; +uniform vec4 refraction_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); +uniform sampler2D screen_texture: hint_screen_texture, repeat_disable, filter_linear_mipmap; + +group_uniforms normal; +uniform float normal_strength: hint_range(-16.0, 16.0) = 0.0; +uniform sampler2D normal_map: hint_normal; + +group_uniforms subsurface_scattering; +uniform float subsurface_scattering_strength: hint_range(0.0, 1.0, 0.01); +uniform sampler2D texture_subsurface_scattering : hint_default_white, filter_linear_mipmap, repeat_enable; + +group_uniforms misc; +uniform vec4 edge_color: source_color = vec4(0.0, 0.0, 0.0, 1.0); +uniform float surface_contribution = 0.2; +uniform float specular_contribution = 0.2; +uniform float refraction_contribution = 1.0; + +group_uniforms uv; +uniform vec3 uv1_scale = vec3(1.0); +uniform vec3 uv1_offset = vec3(0.0); + +float SchlickFresnel(float u) { + float m = 1.0 - u; + float m2 = m * m; + return m2 * m2 * m; +} + +void vertex() { + UV=UV*uv1_scale.xy+uv1_offset.xy; +} + +void fragment() { + NORMAL_MAP = texture(normal_map, UV).xyz; + NORMAL_MAP_DEPTH = normal_strength; + + float VdotN = dot(VIEW, NORMAL); + float fresnel = clamp(SchlickFresnel(VdotN), 0.0, 1.0); + + vec4 albedo_mix = texture(albedo_texture, UV) * albedo; + float roughness_mix = texture(roughness_texture, UV).r * roughness; + float sss_mix = texture(texture_subsurface_scattering, UV).r * subsurface_scattering_strength; + + float a = mix(0.001, 1.0, albedo_mix.a); + float a_factor_0 = mix(fresnel * edge_color.a, 1.0, a); + float a_factor_1 = 0.5 * sqrt(a); + float a_factor_2 = a_factor_0 + a_factor_1; + + ALBEDO = mix(edge_color.rgb * edge_color.a, albedo_mix.rgb * surface_contribution, a); + ROUGHNESS = roughness_mix; + SPECULAR = 0.5 * inversesqrt(specular_contribution); + SSS_STRENGTH = sss_mix; + + vec3 unpacked_normal = NORMAL_MAP; + unpacked_normal.xy = unpacked_normal.xy * 2.0 - 1.0; + unpacked_normal.z = sqrt(max(0.0, 1.0 - dot(unpacked_normal.xy, unpacked_normal.xy))); + vec3 ref_normal = normalize(mix(NORMAL,TANGENT * unpacked_normal.x + BINORMAL * unpacked_normal.y + NORMAL * unpacked_normal.z,NORMAL_MAP_DEPTH)); + vec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(texture(texture_refraction, UV),refraction_texture_channel) * refraction; + float ref_amount = 1.0 - albedo_mix.a; + EMISSION += (textureLod(screen_texture,ref_ofs,ROUGHNESS * 8.0).rgb * ref_amount * EXPOSURE * mix(vec3(mix(0.02, 0.1, a)), albedo_mix.rgb*refraction_contribution, a))/a_factor_2; + ALBEDO *= 1.0 - ref_amount; +} diff --git a/src/ui/arrow.gd b/src/ui/arrow.gd new file mode 100644 index 0000000..5bb809f --- /dev/null +++ b/src/ui/arrow.gd @@ -0,0 +1,31 @@ +@tool +extends Node3D + +const COLOR_PARAMETER := "albedo" + +enum Loop { + RESET, + BOB_TIP, + BOB_TAIL, +} + +@export var loop_animation: Loop: + set(value): + if is_instance_valid(animation_player): + animation_player.play(str(Loop.keys()[value])) + loop_animation = value + +@export var color := Color("#ff99ff99"): + set(value): + if is_instance_valid(cube): + var shader: ShaderMaterial = cube.get_surface_override_material(0) + shader.set_shader_parameter(COLOR_PARAMETER, value) + color = value + +@onready var cube: MeshInstance3D = %Cube +@onready var animation_player: AnimationPlayer = %AnimationPlayer + + +func _ready() -> void: + loop_animation = loop_animation + color = color diff --git a/src/ui/arrow.tscn b/src/ui/arrow.tscn new file mode 100644 index 0000000..695845f --- /dev/null +++ b/src/ui/arrow.tscn @@ -0,0 +1,112 @@ +[gd_scene load_steps=9 format=3 uid="uid://c2k88ns0h5ie1"] + +[ext_resource type="PackedScene" uid="uid://bw54bi35myvpg" path="res://assets/models/ui/arrow/arrow.glb" id="1_xifl6"] +[ext_resource type="Script" path="res://src/ui/arrow.gd" id="2_0viam"] +[ext_resource type="Material" uid="uid://d3ka0yjhxu5ks" path="res://assets/materials/gummy_material.tres" id="3_g7vwe"] + +[sub_resource type="Animation" id="Animation_hsqkd"] +resource_name = "bob_tail" +length = 0.8 +loop_mode = 1 +step = 0.01 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Cube:scale") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.4, 0.8), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(1, 1, 1), Vector3(1, 0.95, 1), Vector3(1, 1, 1)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Cube:position") +tracks/1/interp = 2 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.4, 0.8), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, 0.38, 0), Vector3(0, 0, 0)] +} + +[sub_resource type="Animation" id="Animation_evviq"] +resource_name = "loop" +length = 0.8 +loop_mode = 1 +step = 0.01 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Cube:scale") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.4, 0.8), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(1, 1, 1), Vector3(1, 0.95, 1), Vector3(1, 1, 1)] +} + +[sub_resource type="Animation" id="Animation_uoidj"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Cube:scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(1, 1, 1)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Cube:position") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_7avkl"] +_data = { +"BOB_TAIL": SubResource("Animation_hsqkd"), +"BOB_TIP": SubResource("Animation_evviq"), +"RESET": SubResource("Animation_uoidj") +} + +[sub_resource type="BoxMesh" id="BoxMesh_q4cym"] + +[node name="Arrow" instance=ExtResource("1_xifl6")] +script = ExtResource("2_0viam") + +[node name="Cube" parent="." index="0"] +unique_name_in_owner = true +surface_material_override/0 = ExtResource("3_g7vwe") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="1"] +unique_name_in_owner = true +libraries = { +"": SubResource("AnimationLibrary_7avkl") +} +autoplay = "BOB_TIP" + +[node name="Node3D" type="Node3D" parent="." index="2"] +transform = Transform3D(1, 0, 0, 0, 7.619, 0, 0, 0, 1, 0, 0, 0) +visible = false + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Node3D" index="0"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.500484, 0) +mesh = SubResource("BoxMesh_q4cym") +skeleton = NodePath("../..")