From 0b1abe8fda3201b6caf6de67d972110b9d2ddbc2 Mon Sep 17 00:00:00 2001 From: lucastucious Date: Tue, 25 Mar 2025 18:23:14 +0100 Subject: [PATCH] player inputs on boat --- .gitattributes | 2 + Boats/boat.gd | 52 ++++++++++++-- Boats/boat.tscn | 67 +++++++++++++++++++ Boats/buyancy_probe.gd | 7 +- Boats/cartoon-boat/source/boat 4.fbx | 3 + Boats/cartoon-boat/source/boat 4.fbx.import | 50 ++++++++++++++ Boats/cartoon-boat/textures/boat.tres | 61 +++++++++++++++++ Boats/cartoon-boat/textures/boatMat.tres | 7 ++ .../textures/boat_4_lambert1_BaseColor.png | 3 + .../boat_4_lambert1_BaseColor.png.import | 35 ++++++++++ .../textures/boat_4_lambert1_Metalness.png | 3 + .../boat_4_lambert1_Metalness.png.import | 35 ++++++++++ .../textures/boat_4_lambert1_Normal.png | 3 + .../boat_4_lambert1_Normal.png.import | 35 ++++++++++ .../textures/boat_4_lambert1_Roughness.png | 3 + .../boat_4_lambert1_Roughness.png.import | 35 ++++++++++ Boats/wooden-boat/source/untitled.fbx | 3 + Boats/wooden-boat/source/untitled.fbx.import | 38 +++++++++++ Boats/wooden-boat/textures/Untitled.png | 3 + .../wooden-boat/textures/Untitled.png.import | 35 ++++++++++ Ocean/OceanShader_Calm.tres | 4 +- Ocean/OceanTile.gdshader | 12 +++- OpenWorld.tscn | 14 ++-- 23 files changed, 491 insertions(+), 19 deletions(-) create mode 100644 Boats/boat.tscn create mode 100644 Boats/cartoon-boat/source/boat 4.fbx create mode 100644 Boats/cartoon-boat/source/boat 4.fbx.import create mode 100644 Boats/cartoon-boat/textures/boat.tres create mode 100644 Boats/cartoon-boat/textures/boatMat.tres create mode 100644 Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png create mode 100644 Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png.import create mode 100644 Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png create mode 100644 Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png.import create mode 100644 Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png create mode 100644 Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png.import create mode 100644 Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png create mode 100644 Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png.import create mode 100644 Boats/wooden-boat/source/untitled.fbx create mode 100644 Boats/wooden-boat/source/untitled.fbx.import create mode 100644 Boats/wooden-boat/textures/Untitled.png create mode 100644 Boats/wooden-boat/textures/Untitled.png.import diff --git a/.gitattributes b/.gitattributes index 3dc56b8..5186e4b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,5 @@ # Normalize EOL for all files that Git considers text files. * text=auto eol=lf *.psd filter=lfs diff=lfs merge=lfs -text +*.fbx filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text diff --git a/Boats/boat.gd b/Boats/boat.gd index c831b45..acd98c6 100644 --- a/Boats/boat.gd +++ b/Boats/boat.gd @@ -2,14 +2,54 @@ extends RigidBody3D class_name Boat +@export var max_thrust_force: float = 2048*3.0 +@export var max_steering: float = 50.0 + +var steering: float = 0 # steering rudder angle in radians +var thrust_force: float = 0 # forward thrust force in Newtons +var cam_rotation:Vector3 + +var is_docked: bool = false +var submerged := false + +func _ready(): + add_to_group("boats",true) -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. +func _physics_process(delta): + ## Code for user-input movement + if thrust_force >0.0: + apply_central_force(self.global_transform.basis.x.normalized() * Vector3(1, 0, 1) * thrust_force * delta) + #apply_torque(Vector3.UP * steering * delta) + apply_torque(global_transform.basis.y.normalized() * steering ) # for sideways motion + reset_forces() + +func _process(_delta): + if Input.get_action_strength("move_forward") > 0.0: + thrust() + if Input.get_action_strength("turn_right") > 0.0: + steer_right() + if Input.get_action_strength("turn_left") > 0.0: + steer_left() + if Input.get_action_strength("camera_left") > 0.0: + cam_rotation += Vector3(0.0,1.0,0.0)*_delta + if Input.get_action_strength("camera_right") > 0.0: + cam_rotation += Vector3(0.0,-1.0,0.0)*_delta + +func thrust(_strength:=1.0): + if not is_docked: + thrust_force = max_thrust_force + +func steer_right(_strength:=1.0): + if not is_docked: + steering = -PI * max_steering + +func steer_left(_strength:=1.0): + if not is_docked: + steering = PI * max_steering -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(_delta: float) -> void: - pass +func reset_forces(): + thrust_force = 0 + steering = 0 diff --git a/Boats/boat.tscn b/Boats/boat.tscn new file mode 100644 index 0000000..5420c12 --- /dev/null +++ b/Boats/boat.tscn @@ -0,0 +1,67 @@ +[gd_scene load_steps=6 format=3 uid="uid://bdfqifxsvpts4"] + +[ext_resource type="Script" uid="uid://cjo6l2ykgvn4e" path="res://Boats/boat.gd" id="1_q76at"] +[ext_resource type="PackedScene" uid="uid://bu6chp8qribgy" path="res://Boats/cartoon-boat/source/boat 4.fbx" id="2_bmmu8"] +[ext_resource type="Script" uid="uid://cnfkxclrq0i0s" path="res://Boats/buyancy_probe.gd" id="3_dd4jx"] + +[sub_resource type="GDScript" id="GDScript_dd4jx"] +script/source = "extends Node3D + +func _process(_delta): + pass + #global_rotation = $\"../..\".cam_rotation +" + +[sub_resource type="BoxShape3D" id="BoxShape3D_g5njt"] +size = Vector3(5.26923, 1, 3.88843) + +[node name="Boat" type="RigidBody3D"] +mass = 50.0 +script = ExtResource("1_q76at") +max_thrust_force = 3000.0 +max_steering = 150.0 +metadata/_custom_type_script = "uid://cjo6l2ykgvn4e" + +[node name="boat 4" parent="." instance=ExtResource("2_bmmu8")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -4.8577) + +[node name="CamRoot" type="Node3D" parent="boat 4"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.02675, 1.50566, 4.94378) +script = SubResource("GDScript_dd4jx") + +[node name="SpringArm3D" type="SpringArm3D" parent="boat 4/CamRoot"] +transform = Transform3D(0.489698, 0.510696, -0.706672, -0.000524942, 0.810677, 0.585494, 0.871892, -0.286344, 0.397255, 0, 0, 0) +collision_mask = 0 +spring_length = 10.0 + +[node name="Camera3D" type="Camera3D" parent="boat 4/CamRoot/SpringArm3D"] +transform = Transform3D(1, 0, 5.96046e-08, 0, 1, -1.04308e-07, 0, 2.98023e-08, 1, 1.78167, 1.43974, 8.17264) +current = true + +[node name="BuyancyProbe" type="Marker3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.15306, 1.02582, 1.3511) +script = ExtResource("3_dd4jx") +show_probe = true +metadata/_custom_type_script = "uid://cnfkxclrq0i0s" + +[node name="BuyancyProbe2" type="Marker3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.933215, 1.32675, -1.50793) +script = ExtResource("3_dd4jx") +show_probe = true +metadata/_custom_type_script = "uid://cnfkxclrq0i0s" + +[node name="BuyancyProbe3" type="Marker3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.95977, 1.07616, 1.18863) +script = ExtResource("3_dd4jx") +show_probe = true +metadata/_custom_type_script = "uid://cnfkxclrq0i0s" + +[node name="BuyancyProbe4" type="Marker3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.95977, 0.847872, -0.88629) +script = ExtResource("3_dd4jx") +show_probe = true +metadata/_custom_type_script = "uid://cnfkxclrq0i0s" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.789459, 1.27738, 0) +shape = SubResource("BoxShape3D_g5njt") diff --git a/Boats/buyancy_probe.gd b/Boats/buyancy_probe.gd index 99e316b..1a3e557 100644 --- a/Boats/buyancy_probe.gd +++ b/Boats/buyancy_probe.gd @@ -64,9 +64,10 @@ func _process(_delta: float) -> void: func get_wave_height(world_position: Vector3, time: float) -> float: var uv_x = wrapf(world_position.x / noise_scale + time * wave_speed, 0, 1) var uv_y = wrapf(world_position.z / noise_scale + time * wave_speed, 0, 1) - - var pixel_pos = Vector2(uv_x * noise.get_width(), uv_y * noise.get_height()) - return OceanNode.global_position.y + noise.get_pixelv(pixel_pos).r * height_scale; + if noise != null: + var pixel_pos = Vector2(uv_x * noise.get_width(), uv_y * noise.get_height()) + return OceanNode.global_position.y + noise.get_pixelv(pixel_pos).r * height_scale; + return world_position.y func update_param(): if ocean_mat != null: diff --git a/Boats/cartoon-boat/source/boat 4.fbx b/Boats/cartoon-boat/source/boat 4.fbx new file mode 100644 index 0000000..245ca6a --- /dev/null +++ b/Boats/cartoon-boat/source/boat 4.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a5391b966d25c71ee316bbe14b836973f1fb28c2866db0096ae4dc5d7de8dc7 +size 650320 diff --git a/Boats/cartoon-boat/source/boat 4.fbx.import b/Boats/cartoon-boat/source/boat 4.fbx.import new file mode 100644 index 0000000..d42d50d --- /dev/null +++ b/Boats/cartoon-boat/source/boat 4.fbx.import @@ -0,0 +1,50 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://bu6chp8qribgy" +path="res://.godot/imported/boat 4.fbx-4f459f3d14e15dbdd6449d0939ad6231.scn" + +[deps] + +source_file="res://Boats/cartoon-boat/source/boat 4.fbx" +dest_files=["res://.godot/imported/boat 4.fbx-4f459f3d14e15dbdd6449d0939ad6231.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +nodes/use_node_type_suffixes=true +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=true +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="" +_subresources={ +"materials": { +"lambert1": { +"use_external/enabled": true, +"use_external/path": "uid://b0r2c7455ns2l" +} +}, +"nodes": { +"PATH:AnimationPlayer": { +"import/skip_import": true +} +} +} +fbx/importer=0 +fbx/allow_geometry_helper_nodes=false +fbx/embedded_image_handling=1 diff --git a/Boats/cartoon-boat/textures/boat.tres b/Boats/cartoon-boat/textures/boat.tres new file mode 100644 index 0000000..0cf6fda --- /dev/null +++ b/Boats/cartoon-boat/textures/boat.tres @@ -0,0 +1,61 @@ +[gd_resource type="VisualShader" load_steps=9 format=3 uid="uid://5is85o5k05lb"] + +[ext_resource type="Texture2D" uid="uid://b3htar5wp3ag2" path="res://Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png" id="1_igkxg"] +[ext_resource type="Texture2D" uid="uid://conebiij3gpe8" path="res://Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png" id="2_c0qec"] +[ext_resource type="Texture2D" uid="uid://cqu3udiqdiw5u" path="res://Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png" id="3_ygw4n"] +[ext_resource type="Texture2D" uid="uid://brltubuleyx6p" path="res://Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png" id="4_yj6bl"] + +[sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_v2np7"] +texture = ExtResource("1_igkxg") + +[sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_y2thm"] +texture = ExtResource("2_c0qec") + +[sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_2d07w"] +texture = ExtResource("3_ygw4n") + +[sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_fban5"] +texture = ExtResource("4_yj6bl") + +[resource] +code = "shader_type spatial; +render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_toon, specular_toon; + +uniform sampler2D tex_frg_2; +uniform sampler2D tex_frg_5; +uniform sampler2D tex_frg_4; + + + +void fragment() { +// Texture2D:2 + vec4 n_out2p0 = texture(tex_frg_2, UV); + + +// Texture2D:5 + vec4 n_out5p0 = texture(tex_frg_5, UV); + + +// Texture2D:4 + vec4 n_out4p0 = texture(tex_frg_4, UV); + + +// Output:0 + ALBEDO = vec3(n_out2p0.xyz); + ROUGHNESS = n_out5p0.x; + NORMAL = vec3(n_out4p0.xyz); + + +} +" +modes/diffuse = 3 +modes/specular = 1 +nodes/fragment/2/node = SubResource("VisualShaderNodeTexture_v2np7") +nodes/fragment/2/position = Vector2(40, 20) +nodes/fragment/3/node = SubResource("VisualShaderNodeTexture_y2thm") +nodes/fragment/3/position = Vector2(-40, 360) +nodes/fragment/4/node = SubResource("VisualShaderNodeTexture_2d07w") +nodes/fragment/4/position = Vector2(-40, 680) +nodes/fragment/5/node = SubResource("VisualShaderNodeTexture_fban5") +nodes/fragment/5/position = Vector2(-400, 440) +nodes/fragment/connections = PackedInt32Array(2, 0, 0, 0, 5, 0, 0, 3, 4, 0, 0, 8) diff --git a/Boats/cartoon-boat/textures/boatMat.tres b/Boats/cartoon-boat/textures/boatMat.tres new file mode 100644 index 0000000..4ee77c7 --- /dev/null +++ b/Boats/cartoon-boat/textures/boatMat.tres @@ -0,0 +1,7 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://b0r2c7455ns2l"] + +[ext_resource type="Shader" uid="uid://5is85o5k05lb" path="res://Boats/cartoon-boat/textures/boat.tres" id="1_ydsd6"] + +[resource] +render_priority = 0 +shader = ExtResource("1_ydsd6") diff --git a/Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png b/Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png new file mode 100644 index 0000000..e5e66a9 --- /dev/null +++ b/Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9cc5a2de5a7f03161a2c1582a623dfdec4079c2fbcb38722d6171df03bab3477 +size 1361451 diff --git a/Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png.import b/Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png.import new file mode 100644 index 0000000..bf77950 --- /dev/null +++ b/Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b3htar5wp3ag2" +path.s3tc="res://.godot/imported/boat_4_lambert1_BaseColor.png-c115378871e9c14ec1968c2847d8cb2a.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://Boats/cartoon-boat/textures/boat_4_lambert1_BaseColor.png" +dest_files=["res://.godot/imported/boat_4_lambert1_BaseColor.png-c115378871e9c14ec1968c2847d8cb2a.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png b/Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png new file mode 100644 index 0000000..62c1c1a --- /dev/null +++ b/Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33020deec22acdb90eb58fe19ce25db608a486d02d8734bd14558c03c64273b2 +size 85121 diff --git a/Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png.import b/Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png.import new file mode 100644 index 0000000..44ddd14 --- /dev/null +++ b/Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://conebiij3gpe8" +path.s3tc="res://.godot/imported/boat_4_lambert1_Metalness.png-b09edd3d302acb8e51ce4c4cff9fe7de.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://Boats/cartoon-boat/textures/boat_4_lambert1_Metalness.png" +dest_files=["res://.godot/imported/boat_4_lambert1_Metalness.png-b09edd3d302acb8e51ce4c4cff9fe7de.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png b/Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png new file mode 100644 index 0000000..627413c --- /dev/null +++ b/Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90c921ece8dcf7d98b2d74ef3f0a381ae58aee82e9fd0167b679c447deaecf04 +size 2074498 diff --git a/Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png.import b/Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png.import new file mode 100644 index 0000000..84daf07 --- /dev/null +++ b/Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cqu3udiqdiw5u" +path.s3tc="res://.godot/imported/boat_4_lambert1_Normal.png-f950f375cb3203315d9984306087da8f.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://Boats/cartoon-boat/textures/boat_4_lambert1_Normal.png" +dest_files=["res://.godot/imported/boat_4_lambert1_Normal.png-f950f375cb3203315d9984306087da8f.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png b/Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png new file mode 100644 index 0000000..a7c60ca --- /dev/null +++ b/Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf4523a037b767998cc143947c44848058614d08661819e2cee7d93c8c8f1c63 +size 549089 diff --git a/Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png.import b/Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png.import new file mode 100644 index 0000000..2422799 --- /dev/null +++ b/Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://brltubuleyx6p" +path.s3tc="res://.godot/imported/boat_4_lambert1_Roughness.png-47634d56a8d31c3aeafe4adb7842f89b.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://Boats/cartoon-boat/textures/boat_4_lambert1_Roughness.png" +dest_files=["res://.godot/imported/boat_4_lambert1_Roughness.png-47634d56a8d31c3aeafe4adb7842f89b.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/Boats/wooden-boat/source/untitled.fbx b/Boats/wooden-boat/source/untitled.fbx new file mode 100644 index 0000000..6b4fca9 --- /dev/null +++ b/Boats/wooden-boat/source/untitled.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a30887a3dd375ce35f04840735da95940571c473b4cb05913d811ad4a5ddc616 +size 324524 diff --git a/Boats/wooden-boat/source/untitled.fbx.import b/Boats/wooden-boat/source/untitled.fbx.import new file mode 100644 index 0000000..ea7191c --- /dev/null +++ b/Boats/wooden-boat/source/untitled.fbx.import @@ -0,0 +1,38 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://dnxg7m7qb17m2" +path="res://.godot/imported/untitled.fbx-885fefb9c878ef12b4480941c30cc4bf.scn" + +[deps] + +source_file="res://Boats/wooden-boat/source/untitled.fbx" +dest_files=["res://.godot/imported/untitled.fbx-885fefb9c878ef12b4480941c30cc4bf.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +nodes/use_node_type_suffixes=true +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=true +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="" +_subresources={} +fbx/importer=0 +fbx/allow_geometry_helper_nodes=false +fbx/embedded_image_handling=1 diff --git a/Boats/wooden-boat/textures/Untitled.png b/Boats/wooden-boat/textures/Untitled.png new file mode 100644 index 0000000..d66a2e8 --- /dev/null +++ b/Boats/wooden-boat/textures/Untitled.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2aef8bc54f9c174305ec5e953217c2dc45a09cb414fb944f4ccf79060ca19380 +size 877790 diff --git a/Boats/wooden-boat/textures/Untitled.png.import b/Boats/wooden-boat/textures/Untitled.png.import new file mode 100644 index 0000000..b976323 --- /dev/null +++ b/Boats/wooden-boat/textures/Untitled.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://lsn1rdgt1ahf" +path.s3tc="res://.godot/imported/Untitled.png-256d0bdd70e310aad901568479012ae9.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://Boats/wooden-boat/textures/Untitled.png" +dest_files=["res://.godot/imported/Untitled.png-256d0bdd70e310aad901568479012ae9.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/Ocean/OceanShader_Calm.tres b/Ocean/OceanShader_Calm.tres index de8f8b2..56eaf88 100644 --- a/Ocean/OceanShader_Calm.tres +++ b/Ocean/OceanShader_Calm.tres @@ -49,10 +49,12 @@ shader_parameter/shore_fade = 0.165 shader_parameter/shore_intensity = 0.7 shader_parameter/metallic = 0.0 shader_parameter/roughness = 0.02 +shader_parameter/water_alpha_fade = 4.407 +shader_parameter/water_alpha_max = 3.791 shader_parameter/texture_normal = SubResource("NoiseTexture2D_d50os") shader_parameter/texture_normal2 = SubResource("NoiseTexture2D_ca8p6") shader_parameter/wave = SubResource("NoiseTexture2D_cuet1") -shader_parameter/wave_time = 46.1837 +shader_parameter/wave_time = 82.8805 shader_parameter/wave_direction = Vector2(2, 0) shader_parameter/wave_2_direction = Vector2(0, 0.9) shader_parameter/time_scale = 0.02 diff --git a/Ocean/OceanTile.gdshader b/Ocean/OceanTile.gdshader index 1322ded..aa58b87 100644 --- a/Ocean/OceanTile.gdshader +++ b/Ocean/OceanTile.gdshader @@ -12,6 +12,8 @@ uniform float shore_fade = 1.0; uniform float shore_intensity = 1.0; uniform float metallic : hint_range(0.0, 1.0) = 0; uniform float roughness : hint_range(0.0, 1.0) = 0.02; +uniform float water_alpha_fade : hint_range(0.0, 5.0) = 1.0; +uniform float water_alpha_max : hint_range(0.001, 15.0) = 1.0; uniform sampler2D texture_normal; uniform sampler2D texture_normal2; @@ -80,9 +82,17 @@ void fragment() { float fresnel = fresnel(5.0, NORMAL, VIEW); vec3 surface_color = mix(albedo, albedo2, fresnel); vec3 depth_color_adj = mix(edge_color, color, step(edge_scale, z_dif)); +// Compute the world-space position from the depth texture as before. + vec4 alpha_depth_world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, texture(DEPTH_TEXTURE, SCREEN_UV).r, 1.0); + alpha_depth_world_pos.xyz /= alpha_depth_world_pos.w; + + // Calculate water_alpha based on how far VERTEX.z is from the depth sample. + float water_alpha = clamp(1.0 - smoothstep(clamp(alpha_depth_world_pos.z + water_alpha_fade,0.0,water_alpha_max+alpha_depth_world_pos.z), alpha_depth_world_pos.z, VERTEX.y), 0.0, 1.0) ; + + ALBEDO = clamp(surface_color + depth_color_adj + shore_color * shore_intensity,vec3(0),vec3(1.0)); - ALPHA = 1.0; + ALPHA = water_alpha; METALLIC = metallic; ROUGHNESS = roughness; NORMAL_MAP = normal_blend; diff --git a/OpenWorld.tscn b/OpenWorld.tscn index c9e0451..0579412 100644 --- a/OpenWorld.tscn +++ b/OpenWorld.tscn @@ -6,7 +6,7 @@ [ext_resource type="PlaneMesh" uid="uid://c82xwqk7ljku0" path="res://Ocean/OceanTile_PlaneMesh_Far.tres" id="3_spien"] [ext_resource type="Script" uid="uid://cnfkxclrq0i0s" path="res://Boats/buyancy_probe.gd" id="5_spien"] [ext_resource type="Script" uid="uid://3ympc26kcuul" path="res://Ocean/WeatherManager.gd" id="6_kisq7"] -[ext_resource type="Script" uid="uid://cjo6l2ykgvn4e" path="res://Boats/boat.gd" id="7_0g14k"] +[ext_resource type="PackedScene" uid="uid://bdfqifxsvpts4" path="res://Boats/boat.tscn" id="7_0g14k"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_xncsh"] sky_top_color = Color(0.191699, 0.357914, 1, 1) @@ -26,6 +26,7 @@ sdfgi_enabled = true glow_enabled = true fog_enabled = true fog_sky_affect = 0.699 +volumetric_fog_enabled = true [sub_resource type="BoxMesh" id="BoxMesh_spien"] size = Vector3(5, 0.2, 5) @@ -40,6 +41,7 @@ size = Vector3(0.3, 0.8, 0.3) size = Vector3(0.3, 0.8, 0.3) [node name="OpenWorld" type="Node3D"] +metadata/_edit_lock_ = true [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_q57bq") @@ -48,6 +50,7 @@ environment = SubResource("Environment_q57bq") transform = Transform3D(-0.149535, -0.420992, 0.894653, 0, 0.904827, 0.425779, -0.988756, 0.0636691, -0.135304, 0, 1.45796, 0) light_color = Color(0.969986, 0.876638, 0.798898, 1) shadow_enabled = true +metadata/_edit_lock_ = true [node name="Ocean" type="Node3D" parent="." groups=["Ocean"]] script = ExtResource("1_xncsh") @@ -631,13 +634,8 @@ float_strength = 2.0 show_probe = true metadata/_custom_type_script = "uid://cnfkxclrq0i0s" -[node name="DebugCamera3D" type="Camera3D" parent="."] -transform = Transform3D(0.817859, -0.4492, 0.35962, 0, 0.62497, 0.780649, -0.575419, -0.63846, 0.511137, 8.74584, 11.0902, 11.4458) -current = true - [node name="WeatherManager" type="Node" parent="."] script = ExtResource("6_kisq7") -[node name="Boat" type="RigidBody3D" parent="."] -script = ExtResource("7_0g14k") -metadata/_custom_type_script = "uid://cjo6l2ykgvn4e" +[node name="Boat" parent="." instance=ExtResource("7_0g14k")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.13393, 0, -0.448954)