diff --git a/asset_dev/item_octahedron/item_octahedron.blend b/asset_dev/item_octahedron/item_octahedron.blend new file mode 100644 index 0000000..8a3fcfa --- /dev/null +++ b/asset_dev/item_octahedron/item_octahedron.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef69fc46b5d8fc418deb7e89869be64d4ebb5ecc0041568b6a7930c492ffc4c7 +size 873104 diff --git a/asset_dev/item_octahedron/item_octahedron.blend1 b/asset_dev/item_octahedron/item_octahedron.blend1 new file mode 100644 index 0000000..7d02ad8 Binary files /dev/null and b/asset_dev/item_octahedron/item_octahedron.blend1 differ diff --git a/assets/materials/crystal.tres b/assets/materials/crystal.tres new file mode 100644 index 0000000..ec18963 --- /dev/null +++ b/assets/materials/crystal.tres @@ -0,0 +1,25 @@ +[gd_resource type="ShaderMaterial" load_steps=4 format=3 uid="uid://c5hidbq5gbmr"] + +[ext_resource type="Shader" path="res://src/shaders/frosted_glass.gdshader" id="1_iki28"] +[ext_resource type="Texture2D" uid="uid://c2p2in2p7mjyo" path="res://assets/materials/crystal_noise_normal_map.tres" id="2_cvxma"] +[ext_resource type="Texture2D" uid="uid://cx33n4h5mfcdb" path="res://assets/materials/crystal_noise_map.tres" id="3_v8v67"] + +[resource] +render_priority = 0 +shader = ExtResource("1_iki28") +shader_parameter/albedo = Color(0.5146, 0.62, 0.62, 0.0392157) +shader_parameter/roughness = 0.3 +shader_parameter/roughness_texture = ExtResource("3_v8v67") +shader_parameter/refraction = 0.0100008 +shader_parameter/refraction_texture_channel = Vector4(1, 0, 0, 0) +shader_parameter/texture_refraction = ExtResource("3_v8v67") +shader_parameter/normal_strength = 0.400001 +shader_parameter/normal_map = ExtResource("2_cvxma") +shader_parameter/subsurface_scattering_strength = 1.0 +shader_parameter/texture_subsurface_scattering = ExtResource("3_v8v67") +shader_parameter/edge_color = Color(0, 1, 1.2, 1) +shader_parameter/surface_contribution = 0.2 +shader_parameter/specular_contribution = 0.5 +shader_parameter/refraction_contribution = 10.0 +shader_parameter/uv1_scale = Vector3(1, 1, 1) +shader_parameter/uv1_offset = Vector3(0, 0, 0) diff --git a/assets/materials/crystal_noise.tres b/assets/materials/crystal_noise.tres new file mode 100644 index 0000000..1199d48 --- /dev/null +++ b/assets/materials/crystal_noise.tres @@ -0,0 +1,5 @@ +[gd_resource type="FastNoiseLite" format=3 uid="uid://637qo4uj5mk"] + +[resource] +seed = 2 +fractal_octaves = 3 diff --git a/assets/materials/crystal_noise_map.tres b/assets/materials/crystal_noise_map.tres new file mode 100644 index 0000000..29f3634 --- /dev/null +++ b/assets/materials/crystal_noise_map.tres @@ -0,0 +1,9 @@ +[gd_resource type="NoiseTexture2D" load_steps=2 format=3 uid="uid://cx33n4h5mfcdb"] + +[ext_resource type="FastNoiseLite" uid="uid://637qo4uj5mk" path="res://assets/materials/crystal_noise.tres" id="1_wv67w"] + +[resource] +width = 1024 +height = 1024 +seamless = true +noise = ExtResource("1_wv67w") diff --git a/assets/materials/crystal_noise_normal_map.tres b/assets/materials/crystal_noise_normal_map.tres new file mode 100644 index 0000000..e7e4cb5 --- /dev/null +++ b/assets/materials/crystal_noise_normal_map.tres @@ -0,0 +1,10 @@ +[gd_resource type="NoiseTexture2D" load_steps=2 format=3 uid="uid://c2p2in2p7mjyo"] + +[ext_resource type="FastNoiseLite" uid="uid://637qo4uj5mk" path="res://assets/materials/crystal_noise.tres" id="1_lwomp"] + +[resource] +width = 1024 +height = 1024 +seamless = true +as_normal_map = true +noise = ExtResource("1_lwomp") diff --git a/assets/models/items/octahedron.bin b/assets/models/items/octahedron.bin new file mode 100644 index 0000000..c6b42d2 Binary files /dev/null and b/assets/models/items/octahedron.bin differ diff --git a/assets/models/items/octahedron.gltf b/assets/models/items/octahedron.gltf new file mode 100644 index 0000000..17e8bdd --- /dev/null +++ b/assets/models/items/octahedron.gltf @@ -0,0 +1,104 @@ +{ + "asset":{ + "generator":"Khronos glTF Blender I/O v4.2.60", + "version":"2.0" + }, + "scene":0, + "scenes":[ + { + "name":"Scene", + "nodes":[ + 0 + ] + } + ], + "nodes":[ + { + "mesh":0, + "name":"Octahedron" + } + ], + "meshes":[ + { + "name":"Cube.002", + "primitives":[ + { + "attributes":{ + "POSITION":0, + "NORMAL":1, + "TEXCOORD_0":2 + }, + "indices":3 + } + ] + } + ], + "accessors":[ + { + "bufferView":0, + "componentType":5126, + "count":44, + "max":[ + 1, + 1, + 1 + ], + "min":[ + -1, + -1, + -1 + ], + "type":"VEC3" + }, + { + "bufferView":1, + "componentType":5126, + "count":44, + "type":"VEC3" + }, + { + "bufferView":2, + "componentType":5126, + "count":44, + "type":"VEC2" + }, + { + "bufferView":3, + "componentType":5123, + "count":132, + "type":"SCALAR" + } + ], + "bufferViews":[ + { + "buffer":0, + "byteLength":528, + "byteOffset":0, + "target":34962 + }, + { + "buffer":0, + "byteLength":528, + "byteOffset":528, + "target":34962 + }, + { + "buffer":0, + "byteLength":352, + "byteOffset":1056, + "target":34962 + }, + { + "buffer":0, + "byteLength":264, + "byteOffset":1408, + "target":34963 + } + ], + "buffers":[ + { + "byteLength":1672, + "uri":"octahedron.bin" + } + ] +} diff --git a/assets/models/items/octahedron.gltf.import b/assets/models/items/octahedron.gltf.import new file mode 100644 index 0000000..9b672db --- /dev/null +++ b/assets/models/items/octahedron.gltf.import @@ -0,0 +1,36 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://djfbit4v0qncc" +path="res://.godot/imported/octahedron.gltf-966cdbfd42ea420a19b9a9427efc8ac9.scn" + +[deps] + +source_file="res://assets/models/items/octahedron.gltf" +dest_files=["res://.godot/imported/octahedron.gltf-966cdbfd42ea420a19b9a9427efc8ac9.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={} +gltf/naming_version=1 +gltf/embedded_image_handling=1 diff --git a/levels/debug_level/debug_level.tscn b/levels/debug_level/debug_level.tscn index 695585e..1be60c4 100644 --- a/levels/debug_level/debug_level.tscn +++ b/levels/debug_level/debug_level.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=62 format=3 uid="uid://bm2o3mex10v11"] +[gd_scene load_steps=63 format=3 uid="uid://bm2o3mex10v11"] [ext_resource type="Terrain3DAssets" uid="uid://cwl34gstabgrx" path="res://levels/debug_level/terrain_assets.res" id="1_5smdk"] [ext_resource type="Shader" path="res://src/shaders/psx_water.gdshader" id="6_0efu4"] @@ -10,6 +10,7 @@ [ext_resource type="PackedScene" uid="uid://cjubxs7peir5k" path="res://src/props/scenery/city/kana_signboard.tscn" id="11_evxup"] [ext_resource type="PackedScene" uid="uid://di7aql54lksn7" path="res://src/props/scenery/trees/palm_tree/palm_tree.tscn" id="12_sswxf"] [ext_resource type="PackedScene" uid="uid://c7l58wuuahn7w" path="res://src/props/flag/flag.tscn" id="13_6jtao"] +[ext_resource type="PackedScene" uid="uid://comd88yp45mnb" path="res://src/items/item/item.tscn" id="13_ydvlu"] [ext_resource type="PackedScene" uid="uid://cl0goj38u7r72" path="res://src/props/scenery/beach/sailboat.tscn" id="14_6reiy"] [ext_resource type="PackedScene" uid="uid://dwfckgdxnwwru" path="res://src/world/effects/zephyr/zephyr_particle.tscn" id="16_2kyww"] [ext_resource type="Texture2D" uid="uid://du3vk5nnksohs" path="res://assets/sprites/particles/sparkle.png" id="16_2m5yu"] @@ -398,6 +399,9 @@ transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, -0. [node name="ConcreteBuilding3" parent="CityBuildings" instance=ExtResource("10_lf15j")] transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, -0.01, 40) +[node name="Item" parent="CityBuildings/ConcreteBuilding3" instance=ExtResource("13_ydvlu")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 25.5, 0) + [node name="PalmTree" parent="CityBuildings" instance=ExtResource("12_sswxf")] transform = Transform3D(-0.69799, 0, -0.716107, 0, 1, 0, 0.716107, 0, -0.69799, 11.468, 0, -12.468) diff --git a/src/equipment/balls/physics_ball/game_ball.gd b/src/equipment/balls/physics_ball/game_ball.gd index 7ec49da..bf48fd0 100644 --- a/src/equipment/balls/physics_ball/game_ball.gd +++ b/src/equipment/balls/physics_ball/game_ball.gd @@ -44,6 +44,8 @@ const MAGNUS_EPSILON := 1e-3 var current_gravity: Vector3 +var player: WorldPlayer + var _last_contact_normal: Vector3 = Vector3.UP var _position_on_last_wake: Vector3 var _awake := false diff --git a/src/items/item/item.gd b/src/items/item/item.gd new file mode 100644 index 0000000..624afd9 --- /dev/null +++ b/src/items/item/item.gd @@ -0,0 +1,19 @@ +class_name Item extends Node3D +## Base class for item pick-ups in the world. + +signal on_collect(player: WorldPlayer) + +@onready var explosion_player: AnimationPlayer = %ExplosionPlayer + + +func _collect(player: WorldPlayer) -> void: + # Note that this animation will call `queue_free` in 5 seconds! + explosion_player.play("explode") + on_collect.emit(player) + + +func _on_collection_area_body_entered(body: Node3D) -> void: + if body is GameBall: + var ball: GameBall = body + if ball.player: + _collect(ball.player) diff --git a/src/items/item/item.tscn b/src/items/item/item.tscn new file mode 100644 index 0000000..782e239 --- /dev/null +++ b/src/items/item/item.tscn @@ -0,0 +1,450 @@ +[gd_scene load_steps=29 format=3 uid="uid://comd88yp45mnb"] + +[ext_resource type="PackedScene" uid="uid://djfbit4v0qncc" path="res://assets/models/items/octahedron.gltf" id="1_a0q17"] +[ext_resource type="Script" path="res://src/items/item/item.gd" id="1_kesm6"] +[ext_resource type="Material" uid="uid://c5hidbq5gbmr" path="res://assets/materials/crystal.tres" id="2_dtimm"] +[ext_resource type="Shader" path="res://src/shaders/spatial_shine.gdshader" id="5_hvjqo"] +[ext_resource type="Texture2D" uid="uid://du3vk5nnksohs" path="res://assets/sprites/particles/sparkle.png" id="5_k1sdu"] + +[sub_resource type="Animation" id="Animation_7sxyq"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:position:y") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/2/type = "bezier" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:position:z") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath(".:rotation") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, -0.0523599)] +} + +[sub_resource type="Animation" id="Animation_j8bih"] +resource_name = "pivot" +length = 1.6 +loop_mode = 1 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.4, 0.1, 0, -0.4, -0.1, 0.4, 0.1, 0, -0.4, -0.1, 0.25, 0), +"times": PackedFloat32Array(0, 0.8, 1.6) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:position:y") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(0.05, -0.25, 0, 0.4, 0, -0.05, -0.25, 0, 0.25, 0, 0.05, -0.4, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.8, 1.6) +} +tracks/2/type = "bezier" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:position:z") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.4, 0.1), +"times": PackedFloat32Array(0) +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath(".:rotation") +tracks/3/interp = 2 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.4, 0.8, 1.2, 1.6), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0.0523599), Vector3(0, 0, -0.0523599), Vector3(0, 0, 0.0523599), Vector3(0, 0, -0.0523599), Vector3(0, 0, 0.0523599)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_3k4mu"] +_data = { +"RESET": SubResource("Animation_7sxyq"), +"pivot": SubResource("Animation_j8bih") +} + +[sub_resource type="Animation" id="Animation_jhb3c"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ItemMeshContainer:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, -0.2, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Octahedron:rotation") +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)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("ItemMeshContainer:rotation") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 0)] +} + +[sub_resource type="Animation" id="Animation_283tf"] +resource_name = "hover" +length = 24.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ItemMeshContainer:position") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 6, 12, 18), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector3(0, -0.05, 0), Vector3(0, 0.05, 0), Vector3(0, -0.05, 0), Vector3(0, 0.05, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Octahedron:rotation") +tracks/1/interp = 1 +tracks/1/loop_wrap = false +tracks/1/keys = { +"times": PackedFloat32Array(0, 24), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, 6.28319, -6.28319)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("ItemMeshContainer:rotation") +tracks/2/interp = 1 +tracks/2/loop_wrap = false +tracks/2/keys = { +"times": PackedFloat32Array(0, 24), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, -6.28319, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_jwejx"] +_data = { +"RESET": SubResource("Animation_jhb3c"), +"idle": SubResource("Animation_283tf") +} + +[sub_resource type="Curve" id="Curve_1syyy"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.751579, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_3g61g"] +curve = SubResource("Curve_1syyy") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_jocqm"] +lifetime_randomness = 0.63 +particle_flag_align_y = true +emission_shape = 2 +emission_sphere_radius = 0.5 +direction = Vector3(0, 0, 0) +radial_velocity_min = 4.99998 +radial_velocity_max = 4.99998 +gravity = Vector3(0, -4, 0) +scale_curve = SubResource("CurveTexture_3g61g") + +[sub_resource type="PrismMesh" id="PrismMesh_32wcu"] +material = ExtResource("2_dtimm") +size = Vector3(0.3, -0.2, 0.3) + +[sub_resource type="Gradient" id="Gradient_f63as"] +offsets = PackedFloat32Array(0.211663, 1) +colors = PackedColorArray(1, 1, 0.51, 1, 1, 1, 1, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_r7x43"] +gradient = SubResource("Gradient_f63as") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_wolv7"] +render_priority = 0 +shader = ExtResource("5_hvjqo") +shader_parameter/spread = 0.5 +shader_parameter/cutoff = 0.5 +shader_parameter/size = 1.0 +shader_parameter/speed = 1.0 +shader_parameter/ray1_density = 8.0 +shader_parameter/ray2_density = 30.0 +shader_parameter/ray2_intensity = 0.3 +shader_parameter/core_intensity = 0.5 +shader_parameter/hdr = true +shader_parameter/seed = 5.0 +shader_parameter/grow = -0.0999992 +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/gradient = SubResource("GradientTexture1D_r7x43") + +[sub_resource type="QuadMesh" id="QuadMesh_iuh4w"] +material = SubResource("ShaderMaterial_wolv7") +size = Vector2(3, 3) + +[sub_resource type="SphereShape3D" id="SphereShape3D_munrb"] +radius = 1.0 + +[sub_resource type="Curve" id="Curve_4pwcs"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.248421, 1), 0.0, 0.0, 0, 0, Vector2(0.549474, 0.555075), 5.83005, 5.83005, 0, 0, Vector2(0.80421, 0.232888), 7.10071, 7.10071, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 5 + +[sub_resource type="CurveTexture" id="CurveTexture_xmh5j"] +curve = SubResource("Curve_4pwcs") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_xdagn"] +direction = Vector3(0, 0, 0) +spread = 180.0 +initial_velocity_min = 0.5 +initial_velocity_max = 0.5 +gravity = Vector3(0, 0, 0) +damping_min = 0.1 +damping_max = 0.1 +scale_curve = SubResource("CurveTexture_xmh5j") + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ttptx"] +transparency = 1 +shading_mode = 0 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("5_k1sdu") +texture_filter = 4 +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 1 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="QuadMesh" id="QuadMesh_es7cm"] +material = SubResource("StandardMaterial3D_ttptx") +size = Vector2(0.05, 0.05) + +[sub_resource type="Animation" id="Animation_niure"] +resource_name = "explode" +length = 5.0 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Pivot/Octahedron/ExplosionParticles:emitting") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Pivot/Octahedron/Octahedron:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Pivot/SparkleParticles:emitting") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/3/type = "method" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath(".") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(5), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"queue_free" +}] +} + +[sub_resource type="Animation" id="Animation_50jqd"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Pivot/Octahedron/ExplosionParticles:emitting") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Pivot/Octahedron/Octahedron:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Pivot/SparkleParticles:emitting") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_lqra6"] +_data = { +"RESET": SubResource("Animation_50jqd"), +"explode": SubResource("Animation_niure") +} + +[node name="Item" type="Node3D"] +script = ExtResource("1_kesm6") + +[node name="Pivot" type="Node3D" parent="."] + +[node name="Octahedron" parent="Pivot" instance=ExtResource("1_a0q17")] + +[node name="Octahedron" parent="Pivot/Octahedron" index="0"] +surface_material_override/0 = ExtResource("2_dtimm") + +[node name="ItemMeshContainer" type="Node3D" parent="Pivot/Octahedron"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, 0) + +[node name="Pivot" type="Node3D" parent="Pivot/Octahedron/ItemMeshContainer"] +transform = Transform3D(0.99863, 0.052336, 0, -0.052336, 0.99863, 0, 0, 0, 1, 0, 0, 0) + +[node name="PivotAnimation" type="AnimationPlayer" parent="Pivot/Octahedron/ItemMeshContainer/Pivot"] +libraries = { +"": SubResource("AnimationLibrary_3k4mu") +} +autoplay = "pivot" +speed_scale = 0.5 + +[node name="ItemAnimation" type="AnimationPlayer" parent="Pivot/Octahedron"] +libraries = { +"": SubResource("AnimationLibrary_jwejx") +} +autoplay = "idle" + +[node name="ExplosionParticles" type="GPUParticles3D" parent="Pivot/Octahedron"] +emitting = false +amount = 64 +one_shot = true +explosiveness = 1.0 +fixed_fps = 60 +interpolate = false +process_material = SubResource("ParticleProcessMaterial_jocqm") +draw_pass_1 = SubResource("PrismMesh_32wcu") + +[node name="Shine" type="MeshInstance3D" parent="Pivot"] +visible = false +mesh = SubResource("QuadMesh_iuh4w") + +[node name="CollectionArea" type="Area3D" parent="Pivot"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Pivot/CollectionArea"] +shape = SubResource("SphereShape3D_munrb") + +[node name="SparkleParticles" type="GPUParticles3D" parent="Pivot"] +amount = 64 +lifetime = 5.0 +preprocess = 5.0 +process_material = SubResource("ParticleProcessMaterial_xdagn") +draw_pass_1 = SubResource("QuadMesh_es7cm") + +[node name="ExplosionPlayer" type="AnimationPlayer" parent="."] +unique_name_in_owner = true +libraries = { +"": SubResource("AnimationLibrary_lqra6") +} + +[connection signal="body_entered" from="Pivot/CollectionArea" to="." method="_on_collection_area_body_entered"] + +[editable path="Pivot/Octahedron"] diff --git a/src/player/shot_setup/ball_point.gd b/src/player/shot_setup/ball_point.gd index 4cf404e..cb5fc45 100644 --- a/src/player/shot_setup/ball_point.gd +++ b/src/player/shot_setup/ball_point.gd @@ -16,13 +16,17 @@ const SCENE_MAP: Dictionary = { ball = value ball_changed.emit(ball) +@onready var shot_setup: ShotSetup = $".." + ## Get a new instance of a ball of the given type. ## Returns null if the type can't be instantiated (e.g. NONE type) func get_instance(type: GameBall.Type) -> GameBall: if type in SCENE_MAP: var scene: PackedScene = SCENE_MAP.get(type) - return scene.instantiate() as GameBall + var ball: GameBall = scene.instantiate() + ball.player = shot_setup.player + return ball return null diff --git a/src/shaders/frosted_glass.gdshader b/src/shaders/frosted_glass.gdshader index b2c85ed..b9bcbfc 100644 --- a/src/shaders/frosted_glass.gdshader +++ b/src/shaders/frosted_glass.gdshader @@ -47,24 +47,24 @@ void vertex() { 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))); diff --git a/src/shaders/spatial_shine.gdshader b/src/shaders/spatial_shine.gdshader new file mode 100644 index 0000000..47a6ac5 --- /dev/null +++ b/src/shaders/spatial_shine.gdshader @@ -0,0 +1,91 @@ +/* Spatial shine + * Based on https://godotshaders.com/shader/radial-shine-highlight/ + */ + +shader_type spatial; +render_mode blend_mix, depth_draw_opaque, cull_back, unshaded, diffuse_burley, specular_schlick_ggx; + +uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap_anisotropic; +uniform sampler2D gradient; +uniform float spread = 0.5; +uniform float cutoff = 0.1; +uniform float size = 1.0; +uniform float speed = 1.0; +uniform float ray1_density = 8.0; +uniform float ray2_density = 30.0; +uniform float ray2_intensity = 0.3; +uniform float core_intensity = 2.0; +uniform bool hdr = false; +uniform float seed = 5.0; + + +uniform float grow : hint_range(-16.0, 16.0, 0.001); + +uniform vec3 uv1_scale; +uniform vec3 uv1_offset; +uniform vec3 uv2_scale; +uniform vec3 uv2_offset; + +float random(vec2 _uv) { + return fract(sin(dot(_uv.xy, vec2(12.9898, 78.233))) * 43758.5453123); +} + +float noise(in vec2 uv) { + vec2 i = floor(uv); + vec2 f = fract(uv); + float a = random(i); + float b = random(i + vec2(1.0, 0.0)); + float c = random(i + vec2(0.0, 1.0)); + float d = random(i + vec2(1.0, 1.0)); + vec2 u = f * f * (3.0-2.0 * f); + return mix(a, b, u.x) + (c - a)* u.y * (1.0 - u.x) + (d - b) * u.x * u.y; +} + +vec4 screen(vec4 base, vec4 blend){ + return 1.0 - (1.0 - base) * (1.0 - blend); +} + +void vertex() { + UV = UV * uv1_scale.xy + uv1_offset.xy; + + // Billboard Mode: Enabled + MODELVIEW_MATRIX = VIEW_MATRIX * mat4( + MAIN_CAM_INV_VIEW_MATRIX[0], + MAIN_CAM_INV_VIEW_MATRIX[1], + MAIN_CAM_INV_VIEW_MATRIX[2], + MODEL_MATRIX[3]); + MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX); + + // Grow: Enabled + VERTEX += NORMAL * grow; +} + +void fragment() { + vec2 centered_uv = (UV - 0.5) * size; + float radius = length(centered_uv); + float angle = atan(centered_uv.y, centered_uv.x) + PI; // Add PI to fix left side cutoff + + vec2 ray1 = vec2(angle * ray1_density + TIME * speed + seed + sin(angle * 3.0), radius * 2.0); + vec2 ray2 = vec2(angle * ray2_density + TIME * speed * 1.5 + seed + cos(angle * 2.0), radius * 2.0); + + float cut = 1.0 - smoothstep(cutoff, cutoff + 0.2, radius); + ray1 *= cut; + ray2 *= cut; + + float rays = hdr ? + noise(ray1) + (noise(ray2) * ray2_intensity) : + clamp(noise(ray1) + (noise(ray2) * ray2_intensity), 0., 1.); + + rays *= smoothstep(spread, spread * 0.3, radius); + float core = smoothstep(0.2, 0.0, radius) * core_intensity; + rays += core; + + vec4 gradient_color = texture(gradient, vec2(rays, 0.5)); + vec3 shine = vec3(rays) * gradient_color.rgb; + + float blur_amount = radius * 0.1; + vec2 blur_uv = SCREEN_UV + centered_uv * blur_amount; + vec4 blurred = texture(SCREEN_TEXTURE, blur_uv); + ALBEDO = screen(blurred, vec4(shine, rays)).rgb; + ALPHA = rays * gradient_color.a; +}