Add ship class and new enviroment

This commit is contained in:
Gary Steven Keough 2024-12-14 22:07:51 -05:00
parent f1f56d52cd
commit ffb947c6e7
62 changed files with 2080 additions and 98 deletions

View File

@ -3,25 +3,26 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://becx0d2aass76" uid="uid://becx0d2aass76"
path="res://.godot/imported/texture_purple (1).png-280110f53f224c96b93436181ab481d7.ctex" path.s3tc="res://.godot/imported/texture_purple (1).png-280110f53f224c96b93436181ab481d7.s3tc.ctex"
metadata={ metadata={
"vram_texture": false "imported_formats": ["s3tc_bptc"],
"vram_texture": true
} }
[deps] [deps]
source_file="res://addons/kennysprototypetextures/Purple/texture_purple (1).png" source_file="res://addons/kennysprototypetextures/Purple/texture_purple (1).png"
dest_files=["res://.godot/imported/texture_purple (1).png-280110f53f224c96b93436181ab481d7.ctex"] dest_files=["res://.godot/imported/texture_purple (1).png-280110f53f224c96b93436181ab481d7.s3tc.ctex"]
[params] [params]
compress/mode=0 compress/mode=2
compress/high_quality=false compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_compression=1 compress/hdr_compression=1
compress/normal_map=0 compress/normal_map=0
compress/channel_pack=0 compress/channel_pack=0
mipmaps/generate=false mipmaps/generate=true
mipmaps/limit=-1 mipmaps/limit=-1
roughness/mode=0 roughness/mode=0
roughness/src_normal="" roughness/src_normal=""
@ -31,4 +32,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false process/hdr_as_srgb=false
process/hdr_clamp_exposure=false process/hdr_clamp_exposure=false
process/size_limit=0 process/size_limit=0
detect_3d/compress_to=1 detect_3d/compress_to=0

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Ronny Mühle (Platinguin)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,22 @@
# Godot-Cloud-Worlds
This is more or less a prototype to see if its possible to implement volumetric clouds which can be reached by the player. These clouds are not production ready.
The project was created with Godot 4.2.2 win64
Technical Details:
The clouds are generated via a pre-baked SDF texture. This ensures good performance, as the raymarch loop knows exactly how far it has to step to reach the clouds. As soon as the raymarcher hits the cloud surface, it goes into a fixed step sampling mode to sample the volume texture.
The lighting is calculated afterwards. There is only one light-march loop per pixel. Normally you would have to calculate the light at every step within the cloud, but the visual difference is minimal and it saves performance. The light-march steps are using the same sdf texture to determine how far they have to march. (the steps are not in a fixed size) They are also reduced over distance to save performance.
Known Issues:
- To see the clouds in the editor, you have to increase the camera z-clipping plane
- The clouds can't generate cubemap reflections (to make this work they have to be rendered differently as a sky shader to generate a radiance map)
- The clouds can't generate shadows to affect other objects in the scene
- The clouds cause sorting issues with other alpha blended materials (as they are rendered as post-effect)
Feel free to edit them or use the code in your own Godot project.
Future Ideas:
Most likely I will use this tech to create a skybox baker to make the clouds static, but as cheap as they can get with highest quality looks. So you could have a semi-realtime sky with clouds which are generated via GPU in the background. In the end they would be as cheap as a standard HDRI skybox, but you would still have the customizablity of a dynamic sky. (it would however take like a second to generate this one, so it's not realtime)

View File

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

View File

@ -0,0 +1,38 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://6gc3033y8tar"
path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@ -0,0 +1,126 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="Godot - Cloud Worlds"
run/main_scene="res://scenes/basic/main.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://icon.svg"
[display]
window/vsync/vsync_mode=0
[input]
keyboard_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
]
}
keyboard_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
]
}
keyboard_forward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
]
}
keyboard_back={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
]
}
hide_menu={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
[rendering]
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=5
textures/default_filters/anisotropic_filtering_level=0
anti_aliasing/quality/use_taa=true
occlusion_culling/use_occlusion_culling=true
[shader_globals]
cloud_base_texture={
"type": "sampler3D",
"value": "res://textures/clouds/cloud_sdf_base.exr"
}
cloud_detail_texture={
"type": "sampler3D",
"value": "res://textures/clouds/cloud_sdf_detail.exr"
}
cloud_base_height={
"type": "float",
"value": 1000.0
}
cloud_base_scale={
"type": "float",
"value": 1000.0
}
cloud_detail_scale={
"type": "float",
"value": 420.0
}
cloud_detail_amount={
"type": "float",
"value": 0.5
}
cloud_detail_dist={
"type": "float",
"value": 10.0
}
cloud_volume_scale={
"type": "float",
"value": 150.0
}
cloud_volume_density_low={
"type": "float",
"value": 4.0
}
cloud_volume_density_high={
"type": "float",
"value": 10.0
}
wind_vector={
"type": "vec2",
"value": Vector2(1, 0)
}
sun_light_direction={
"type": "vec3",
"value": Vector3(0, 0, 0)
}
sun_light_color={
"type": "vec3",
"value": Vector3(0, 0, 0)
}
sun_light_energy={
"type": "float",
"value": 0.3
}
cloud_volume_texture={
"type": "sampler3D",
"value": "res://textures/clouds/cloud_volume_a.png"
}
wind_uplift={
"type": "float",
"value": 2.0
}
cloud_base_squeeze={
"type": "float",
"value": 0.5
}

View File

@ -0,0 +1,27 @@
extends Camera3D
var camera_movement_speed : float = 100.0
var camera_rotation_speed : float = 0.005
func _process(delta):
if Input.is_action_pressed("keyboard_right"):
self.transform.origin += self.transform.basis.x * Input.get_action_strength("keyboard_right") * delta * camera_movement_speed
if Input.is_action_pressed("keyboard_left"):
self.transform.origin -= self.transform.basis.x * Input.get_action_strength("keyboard_left") * delta * camera_movement_speed
if Input.is_action_pressed("keyboard_forward"):
self.transform.origin -= self.transform.basis.z * Input.get_action_strength("keyboard_forward") * delta * camera_movement_speed
if Input.is_action_pressed("keyboard_back"):
self.transform.origin += self.transform.basis.z * Input.get_action_strength("keyboard_back") * delta * camera_movement_speed
func _input(event):
# RIGHT MOUSE CLICK
if (event is InputEventMouseMotion and event.button_mask == 2):
self.look_at(self.transform.origin - self.transform.basis.z + self.transform.basis.x * camera_rotation_speed * event.relative.x - self.transform.basis.y * camera_rotation_speed * event.relative.y)
# MOUSE WHEEL UP + RIGHT MOUSE CLICK (8+2)
if (event is InputEventMouseButton and event.button_mask == 10):
camera_movement_speed *= 1.1
# MOUSE WHEEL DOWN+ RIGHT MOUSE CLICK (16+2)
if (event is InputEventMouseButton and event.button_mask == 18):
camera_movement_speed *= 0.9
if camera_movement_speed < 1.0:
camera_movement_speed = 1.0

View File

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://croxc3ih02m6b"]
[ext_resource type="Script" path="res://scenes/basic/camera.gd" id="1_oyymy"]
[node name="camera" type="Camera3D"]
current = true
near = 0.01
far = 20000.0
script = ExtResource("1_oyymy")

View File

@ -0,0 +1,5 @@
extends Label
func _process(delta):
var debug_string : String = "FPS = " + str(Engine.get_frames_per_second()) + "\n"
set_text(debug_string)

View File

@ -0,0 +1,95 @@
[gd_scene load_steps=17 format=3 uid="uid://o30gir8h2ufu"]
[ext_resource type="Script" path="res://scenes/basic/debug.gd" id="2_3sqim"]
[ext_resource type="PackedScene" uid="uid://djl3q6ynbkau0" path="res://scenes/world/clouds.tscn" id="2_38qtq"]
[ext_resource type="PackedScene" uid="uid://croxc3ih02m6b" path="res://scenes/basic/camera.tscn" id="2_ew6s1"]
[ext_resource type="CompressedTexture3D" uid="uid://bwvwaoihjy78g" path="res://textures/clouds/cloud_sdf_base.exr" id="3_xqfxp"]
[ext_resource type="CompressedTexture3D" uid="uid://437feiv1oerc" path="res://textures/clouds/cloud_sdf_detail.exr" id="4_6liwh"]
[ext_resource type="Script" path="res://scenes/basic/sunlight.gd" id="4_uk33e"]
[ext_resource type="CompressedTexture3D" uid="uid://4ncscg8jgec0" path="res://textures/clouds/cloud_volume_a.png" id="5_1gko6"]
[ext_resource type="Gradient" uid="uid://cwiiu5dy83cai" path="res://textures/gradients/color_gradient_a.tres" id="5_3hakk"]
[sub_resource type="GradientTexture2D" id="GradientTexture2D_7bm1i"]
gradient = ExtResource("5_3hakk")
width = 256
height = 10
[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_c28mf"]
mie_color = Color(1, 0.811765, 0.552941, 1)
use_debanding = false
[sub_resource type="Sky" id="Sky_dolyt"]
sky_material = SubResource("PhysicalSkyMaterial_c28mf")
[sub_resource type="Environment" id="Environment_288wc"]
background_mode = 2
sky = SubResource("Sky_dolyt")
tonemap_mode = 3
ssao_enabled = true
ssil_enabled = true
volumetric_fog_anisotropy = 0.9
volumetric_fog_length = 256.0
volumetric_fog_ambient_inject = 10.0
adjustment_saturation = 0.3
adjustment_color_correction = SubResource("GradientTexture2D_7bm1i")
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_vf470"]
auto_exposure_enabled = true
auto_exposure_scale = 0.3
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_bfr7x"]
[sub_resource type="SphereMesh" id="SphereMesh_avnke"]
[sub_resource type="PlaneMesh" id="PlaneMesh_e0aqa"]
size = Vector2(10, 10)
[node name="main" type="Node"]
[node name="camera" parent="." instance=ExtResource("2_ew6s1")]
[node name="clouds" parent="." node_paths=PackedStringArray("world_environment", "directional_light", "camera") instance=ExtResource("2_38qtq")]
world_environment = NodePath("../WorldEnvironment")
directional_light = NodePath("../sunlight")
camera = NodePath("../camera")
cloud_base_texture = ExtResource("3_xqfxp")
cloud_detail_texture = ExtResource("4_6liwh")
cloud_volume_texture = ExtResource("5_1gko6")
wind_vector = Vector2(2, 0)
wind_uplift = 3.0
[node name="debug" type="Label" parent="."]
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -225.0
offset_top = 11.0
offset_right = -14.0
offset_bottom = 378.0
grow_horizontal = 0
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
text = "FPS = 100"
horizontal_alignment = 2
script = ExtResource("2_3sqim")
[node name="sunlight" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.682387, -0.466591, 0.562709, -0.397852, 0.408724, 0.821376, -0.613239, -0.784371, 0.0932734, 0, 0, 0)
rotation_edit_mode = 2
light_color = Color(1, 0.811765, 0.552941, 1)
light_energy = 0.3
light_angular_distance = 1.0
shadow_enabled = true
directional_shadow_blend_splits = true
script = ExtResource("4_uk33e")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_288wc")
camera_attributes = SubResource("CameraAttributesPractical_vf470")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
material_override = SubResource("StandardMaterial3D_bfr7x")
mesh = SubResource("SphereMesh_avnke")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource("PlaneMesh_e0aqa")

View File

@ -0,0 +1,9 @@
extends DirectionalLight3D
var a : float = 0.0;
func _process(delta):
a += 0.001 # Dynamic
a = 2.5 # Static Position
self.look_at( transform.origin - Vector3(sin(a * 0.51), sin(a) * 0.5 + 0.52, cos(a * 0.51)) )

View File

@ -0,0 +1,228 @@
@tool
extends Node
@export_subgroup("Dependencies")
@export var world_environment : WorldEnvironment
@export var directional_light : DirectionalLight3D
@export var camera : Camera3D
@export_subgroup("Textures")
@export var cloud_base_texture : Texture3D:
set(new_value):
cloud_base_texture = new_value
update_cloud_textures()
@export var cloud_detail_texture : Texture3D:
set(new_value):
cloud_detail_texture = new_value
update_cloud_textures()
@export var cloud_volume_texture : Texture3D:
set(new_value):
cloud_volume_texture = new_value
update_cloud_textures()
@export_subgroup("Wind")
@export var wind_vector : Vector2 = Vector2(1.0, 0.0):
set(new_value):
wind_vector = new_value
update_cloud_globals()
@export var wind_uplift : float = 2.0:
set(new_value):
wind_uplift = new_value
update_cloud_globals()
@export_subgroup("Cloud Shape")
@export var cloud_base_height : float = 1000.0:
set(new_value):
cloud_base_height = new_value
update_cloud_globals()
@export var cloud_base_scale : float = 2000.0:
set(new_value):
cloud_base_scale = new_value
update_cloud_globals()
@export var cloud_base_squeeze : float = 0.5:
set(new_value):
cloud_base_squeeze = new_value
update_cloud_globals()
@export var cloud_detail_scale : float = 420.0:
set(new_value):
cloud_detail_scale = new_value
update_cloud_globals()
@export var cloud_detail_amount : float = 0.5:
set(new_value):
cloud_detail_amount = new_value
update_cloud_globals()
@export var cloud_detail_dist : float = 10.0:
set(new_value):
cloud_detail_dist = new_value
update_cloud_globals()
@export var cloud_volume_scale : float = 150.0:
set(new_value):
cloud_volume_scale = new_value
update_cloud_globals()
@export var cloud_volume_density_low : float = 4.0:
set(new_value):
cloud_volume_density_low = new_value
update_cloud_globals()
@export var cloud_volume_density_high : float = 10.0:
set(new_value):
cloud_volume_density_high = new_value
update_cloud_globals()
@export_subgroup("Cloud Rendering")
@export var render_normal_offset : float = 7.0:
set(new_value):
render_normal_offset = new_value
update_cloud_shader()
@export var render_normal_blur : float = 10.0:
set(new_value):
render_normal_blur = new_value
update_cloud_shader()
@export var render_ao_amount : float = 2.0:
set(new_value):
render_ao_amount = new_value
update_cloud_shader()
@export var render_hg_base : float = 0.7:
set(new_value):
render_hg_base = new_value
update_cloud_shader()
@export var render_hg_amount : float = 0.5:
set(new_value):
render_hg_amount = new_value
update_cloud_shader()
@export var render_hg_mask : float = 0.05:
set(new_value):
render_hg_mask = new_value
update_cloud_shader()
@export var render_hg_color_saturation : float = 1.0:
set(new_value):
render_hg_color_saturation = new_value
update_cloud_shader()
@export var render_hg_color_power : float = 0.2:
set(new_value):
render_hg_color_power = new_value
update_cloud_shader()
@export var render_sky_color_saturation : float = 1.0:
set(new_value):
render_sky_color_saturation = new_value
update_cloud_shader()
@export var render_direct_shadow_ramp_dist : float = 1000.0:
set(new_value):
render_direct_shadow_ramp_dist = new_value
update_cloud_shader()
@export var render_direct_shadow_jitter : float = 0.05:
set(new_value):
render_direct_shadow_jitter = new_value
update_cloud_shader()
@export var render_short_shadow_amount : float = 0.1:
set(new_value):
render_short_shadow_amount = new_value
update_cloud_shader()
@export var render_short_shadow_dist : float = 70.0:
set(new_value):
render_short_shadow_dist = new_value
update_cloud_shader()
@export var render_smooth_shadow_offset : float = 150.0:
set(new_value):
render_smooth_shadow_offset = new_value
update_cloud_shader()
@export var render_smooth_shadow_bias : float = 100.0:
set(new_value):
render_smooth_shadow_bias = new_value
update_cloud_shader()
@export var render_smooth_shadow_amount : float = 1.0:
set(new_value):
render_smooth_shadow_amount = new_value
update_cloud_shader()
func update_cloud_textures():
# Set Global Texture Variables
RenderingServer.global_shader_parameter_set("cloud_base_texture", cloud_base_texture)
RenderingServer.global_shader_parameter_set("cloud_detail_texture", cloud_detail_texture)
RenderingServer.global_shader_parameter_set("cloud_volume_texture", cloud_volume_texture)
func update_cloud_globals():
# OUTPUT SETTINGS
#print( ProjectSettings.get_setting("shader_globals/cloud_base_height") )
# Set Global Variables In Editor Settings (Not Needed)
#if Engine.is_editor_hint():
# ProjectSettings.set_setting("shader_globals/cloud_base_height", cloud_base_height)
# Set Global Shape Variables
RenderingServer.global_shader_parameter_set("cloud_base_height", cloud_base_height)
RenderingServer.global_shader_parameter_set("cloud_base_scale", cloud_base_scale)
RenderingServer.global_shader_parameter_set("cloud_base_squeeze", cloud_base_squeeze)
RenderingServer.global_shader_parameter_set("cloud_detail_scale", cloud_detail_scale)
RenderingServer.global_shader_parameter_set("cloud_detail_amount", cloud_detail_amount)
RenderingServer.global_shader_parameter_set("cloud_detail_dist", cloud_detail_dist)
RenderingServer.global_shader_parameter_set("cloud_volume_scale", cloud_volume_scale)
RenderingServer.global_shader_parameter_set("cloud_volume_density_low", cloud_volume_density_low)
RenderingServer.global_shader_parameter_set("cloud_volume_density_high", cloud_volume_density_high)
# Set Global Wind Variables
RenderingServer.global_shader_parameter_set("wind_vector", wind_vector)
RenderingServer.global_shader_parameter_set("wind_uplift", wind_uplift)
func update_cloud_shader():
$clouds.material_override.set_shader_parameter("render_normal_offset", render_normal_offset)
$clouds.material_override.set_shader_parameter("render_normal_blur", render_normal_blur)
$clouds.material_override.set_shader_parameter("render_ao_amount", render_ao_amount)
$clouds.material_override.set_shader_parameter("render_hg_base", render_hg_base)
$clouds.material_override.set_shader_parameter("render_hg_amount", render_hg_amount)
$clouds.material_override.set_shader_parameter("render_hg_mask", render_hg_mask)
$clouds.material_override.set_shader_parameter("render_hg_color_saturation", render_hg_color_saturation)
$clouds.material_override.set_shader_parameter("render_hg_color_power", render_hg_color_power)
$clouds.material_override.set_shader_parameter("render_sky_color_saturation", render_sky_color_saturation)
$clouds.material_override.set_shader_parameter("render_direct_shadow_ramp_dist", render_direct_shadow_ramp_dist)
$clouds.material_override.set_shader_parameter("render_direct_shadow_jitter", render_direct_shadow_jitter)
$clouds.material_override.set_shader_parameter("render_short_shadow_amount", render_short_shadow_amount)
$clouds.material_override.set_shader_parameter("render_short_shadow_dist", render_short_shadow_dist)
$clouds.material_override.set_shader_parameter("render_smooth_shadow_offset", render_smooth_shadow_offset)
$clouds.material_override.set_shader_parameter("render_smooth_shadow_bias", render_smooth_shadow_bias)
$clouds.material_override.set_shader_parameter("render_smooth_shadow_amount", render_smooth_shadow_amount)
func update_world_environment():
if !world_environment:
printerr("Error! Clouds need to be linked to a WorldEnvironment node")
else:
# Get Sky-Material From WorldEnvironment Node
var sky_material := world_environment.environment.sky.get_material()
# Sync All Variables To Sky Buffer
$buffer_sky/sky.material_override.set_shader_parameter("rayleigh", sky_material.rayleigh_coefficient )
$buffer_sky/sky.material_override.set_shader_parameter("rayleigh_color", sky_material.rayleigh_color )
$buffer_sky/sky.material_override.set_shader_parameter("mie", sky_material.mie_coefficient )
$buffer_sky/sky.material_override.set_shader_parameter("mie_eccentricity", sky_material.mie_eccentricity )
sky_material.mie_color = directional_light.light_color
$buffer_sky/sky.material_override.set_shader_parameter("mie_color", sky_material.mie_color )
$buffer_sky/sky.material_override.set_shader_parameter("turbidity", sky_material.turbidity )
$buffer_sky/sky.material_override.set_shader_parameter("sun_disk_scale", sky_material.sun_disk_scale )
$buffer_sky/sky.material_override.set_shader_parameter("ground_color", sky_material.ground_color )
$buffer_sky/sky.material_override.set_shader_parameter("exposure", sky_material.energy_multiplier )
func update_directional_light():
if !directional_light:
printerr("Error! Clouds need to be linked to a DirectionalLight3D node")
else:
var light_direction : Vector3 = directional_light.transform.basis.z.normalized()
# Update Global Shader Variables - Sun Light
RenderingServer.global_shader_parameter_set("sun_light_direction", light_direction)
RenderingServer.global_shader_parameter_set("sun_light_energy", directional_light.light_energy)
RenderingServer.global_shader_parameter_set("sun_light_color", directional_light.light_color)
func _ready():
$buffer_sky.size = $buffer_sky.size
$clouds.show()
update_cloud_globals()
update_cloud_shader()
update_cloud_textures()
func update_cloud_positions():
if !camera:
printerr("Error! Clouds need to be linked to a Camera3D node")
else:
$clouds.transform.origin = camera.transform.origin
@warning_ignore("unused_parameter")
func _process(delta):
update_cloud_positions()
update_directional_light()
update_world_environment()

View File

@ -0,0 +1,88 @@
[gd_scene load_steps=11 format=3 uid="uid://djl3q6ynbkau0"]
[ext_resource type="Script" path="res://scenes/world/clouds.gd" id="1_artgg"]
[ext_resource type="Shader" path="res://shaders/cloud_sdf.gdshader" id="3_p8xnm"]
[ext_resource type="Shader" path="res://shaders/buffer_sky.gdshader" id="5_11ck4"]
[sub_resource type="Environment" id="Environment_upbsr"]
[sub_resource type="World3D" id="World3D_dhs8m"]
environment = SubResource("Environment_upbsr")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_syhg6"]
render_priority = 0
shader = ExtResource("5_11ck4")
shader_parameter/rayleigh = 2.0
shader_parameter/rayleigh_color = Color(0.3, 0.405, 0.6, 1)
shader_parameter/mie = 0.005
shader_parameter/mie_eccentricity = 0.8
shader_parameter/mie_color = Color(1, 0.811765, 0.552941, 1)
shader_parameter/turbidity = 10.0
shader_parameter/sun_disk_scale = 1.0
shader_parameter/ground_color = Color(0.1, 0.07, 0.034, 1)
shader_parameter/exposure = 1.0
[sub_resource type="SphereMesh" id="SphereMesh_ruwh8"]
flip_faces = true
radial_segments = 8
rings = 4
[sub_resource type="ViewportTexture" id="ViewportTexture_dago3"]
viewport_path = NodePath("buffer_sky")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_3xcas"]
resource_local_to_scene = true
render_priority = 0
shader = ExtResource("3_p8xnm")
shader_parameter/render_normal_offset = 7.0
shader_parameter/render_normal_blur = 10.0
shader_parameter/render_ao_amount = 2.0
shader_parameter/render_hg_base = 0.7
shader_parameter/render_hg_amount = 0.5
shader_parameter/render_hg_mask = 0.05
shader_parameter/render_hg_color_saturation = 1.0
shader_parameter/render_hg_color_power = 0.2
shader_parameter/render_sky_color_saturation = 1.0
shader_parameter/render_direct_shadow_ramp_dist = 1000.0
shader_parameter/render_direct_shadow_jitter = 0.05
shader_parameter/render_short_shadow_amount = 0.1
shader_parameter/render_short_shadow_dist = 70.0
shader_parameter/render_smooth_shadow_offset = 150.0
shader_parameter/render_smooth_shadow_bias = 100.0
shader_parameter/render_smooth_shadow_amount = 1.0
shader_parameter/buffer_sky = SubResource("ViewportTexture_dago3")
[sub_resource type="SphereMesh" id="SphereMesh_jgq0g"]
flip_faces = true
radius = 9000.0
height = 18000.0
radial_segments = 8
rings = 4
[node name="clouds" type="Node"]
script = ExtResource("1_artgg")
[node name="buffer_sky" type="SubViewport" parent="."]
own_world_3d = true
world_3d = SubResource("World3D_dhs8m")
use_hdr_2d = true
positional_shadow_atlas_size = 64
positional_shadow_atlas_16_bits = false
size = Vector2i(128, 64)
[node name="sky" type="MeshInstance3D" parent="buffer_sky"]
material_override = SubResource("ShaderMaterial_syhg6")
cast_shadow = 0
extra_cull_margin = 16384.0
ignore_occlusion_culling = true
gi_mode = 0
mesh = SubResource("SphereMesh_ruwh8")
skeleton = NodePath("../..")
[node name="camera" type="Camera3D" parent="buffer_sky"]
[node name="clouds" type="MeshInstance3D" parent="."]
material_override = SubResource("ShaderMaterial_3xcas")
cast_shadow = 0
gi_mode = 0
mesh = SubResource("SphereMesh_jgq0g")

View File

@ -0,0 +1,83 @@
// NOTE: Shader automatically converted from Godot Engine 4.1.1.stable's PhysicalSkyMaterial.
shader_type sky;
uniform float rayleigh : hint_range(0, 64) = 2.0;
uniform vec4 rayleigh_color : source_color = vec4(0.3, 0.405, 0.6, 1.0);
uniform float mie : hint_range(0, 1) = 0.005;
uniform float mie_eccentricity : hint_range(-1, 1) = 0.8;
uniform vec4 mie_color : source_color = vec4(0.69, 0.729, 0.812, 1.0);
uniform float turbidity : hint_range(0, 1000) = 10.0;
uniform float sun_disk_scale : hint_range(0, 360) = 1.0;
uniform vec4 ground_color : source_color = vec4(0.1, 0.07, 0.034, 1.0);
uniform float exposure : hint_range(0, 128) = 1.0;
uniform sampler2D night_sky : filter_linear, source_color, hint_default_black;
const vec3 UP = vec3( 0.0, 1.0, 0.0 );
// Optical length at zenith for molecules.
const float rayleigh_zenith_size = 8.4e3;
const float mie_zenith_size = 1.25e3;
float henyey_greenstein(float cos_theta, float g) {
const float k = 0.0795774715459;
return k * (1.0 - g * g) / (pow(1.0 + g * g - 2.0 * g * cos_theta, 1.5));
}
void sky() {
if (LIGHT0_ENABLED) {
float zenith_angle = clamp( dot(UP, normalize(LIGHT0_DIRECTION)), -1.0, 1.0 );
float sun_energy = max(0.0, 1.0 - exp(-((PI * 0.5) - acos(zenith_angle)))) * LIGHT0_ENERGY;
float sun_fade = 1.0 - clamp(1.0 - exp(LIGHT0_DIRECTION.y), 0.0, 1.0);
// Rayleigh coefficients.
float rayleigh_coefficient = rayleigh - ( 1.0 * ( 1.0 - sun_fade ) );
vec3 rayleigh_beta = rayleigh_coefficient * rayleigh_color.rgb * 0.0001;
// mie coefficients from Preetham
vec3 mie_beta = turbidity * mie * mie_color.rgb * 0.000434;
// Optical length.
float zenith = acos(max(0.0, dot(UP, EYEDIR)));
float optical_mass = 1.0 / (cos(zenith) + 0.15 * pow(93.885 - degrees(zenith), -1.253));
float rayleigh_scatter = rayleigh_zenith_size * optical_mass;
float mie_scatter = mie_zenith_size * optical_mass;
// Light extinction based on thickness of atmosphere.
vec3 extinction = exp(-(rayleigh_beta * rayleigh_scatter + mie_beta * mie_scatter));
// In scattering.
float cos_theta = dot(EYEDIR, normalize(LIGHT0_DIRECTION));
float rayleigh_phase = (3.0 / (16.0 * PI)) * (1.0 + pow(cos_theta * 0.5 + 0.5, 2.0));
vec3 betaRTheta = rayleigh_beta * rayleigh_phase;
float mie_phase = henyey_greenstein(cos_theta, mie_eccentricity);
vec3 betaMTheta = mie_beta * mie_phase;
vec3 Lin = pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * (1.0 - extinction), vec3(1.5));
// Hack from https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Sky.js
Lin *= mix(vec3(1.0), pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * extinction, vec3(0.5)), clamp(pow(1.0 - zenith_angle, 5.0), 0.0, 1.0));
// Hack in the ground color.
Lin *= mix(ground_color.rgb, vec3(1.0), smoothstep(-0.1, 0.1, dot(UP, EYEDIR)));
// Solar disk and out-scattering.
float sunAngularDiameterCos = cos(LIGHT0_SIZE * sun_disk_scale);
float sunAngularDiameterCos2 = cos(LIGHT0_SIZE * sun_disk_scale*0.5);
float sundisk = smoothstep(sunAngularDiameterCos, sunAngularDiameterCos2, cos_theta);
vec3 L0 = (sun_energy * extinction) * sundisk * LIGHT0_COLOR;
L0 += texture(night_sky, SKY_COORDS).xyz * extinction;
vec3 color = Lin + L0;
COLOR = pow(color, vec3(1.0 / (1.2 + (1.2 * sun_fade))));
COLOR *= exposure;
} else {
// There is no sun, so display night_sky and nothing else.
COLOR = texture(night_sky, SKY_COORDS).xyz;
COLOR *= exposure;
}
}

View File

@ -0,0 +1,115 @@
shader_type spatial;
render_mode unshaded, shadows_disabled;
// Global Sun Light Variables
global uniform vec3 sun_light_direction;
global uniform float sun_light_energy;
global uniform vec3 sun_light_color;
// Sky Shader
uniform float rayleigh : hint_range(0, 64) = 2.0;
uniform vec4 rayleigh_color : source_color = vec4(0.3, 0.405, 0.6, 1.0);
uniform float mie : hint_range(0, 1) = 0.005;
uniform float mie_eccentricity : hint_range(-1, 1) = 0.8;
uniform vec4 mie_color : source_color = vec4(0.69, 0.729, 0.812, 1.0);
uniform float turbidity : hint_range(0, 1000) = 10.0;
uniform float sun_disk_scale : hint_range(0, 360) = 1.0;
uniform vec4 ground_color : source_color = vec4(0.1, 0.07, 0.034, 1.0);
uniform float exposure : hint_range(0, 128) = 1.0;
// Sun constants
const float light_size = 0.00872663806;
const float SUN_ENERGY = 1000.0; //OLD 1000.0
// optical length at zenith for molecules
const float rayleigh_zenith_size = 8.4e3;
const float mie_zenith_size = 1.25e3;
const vec3 UP = vec3( 0.0, 1.0, 0.0 );
vec2 dir_to_skybox_uv(vec3 dir) {
vec2 uv = vec2(atan(dir.x, -dir.z), acos(dir.y));
if (uv.x < 0.0) {
uv.x += PI * 2.0;
}
return (uv / vec2(PI * 2.0, PI));
}
vec3 skybox_uv_to_dir(vec2 uv) {
uv = (uv - 0.5) * vec2(-2.0, -1.0) * PI;
vec3 r_dir = normalize( vec3( sin(uv.x), tan(uv.y), cos(uv.x) ) * cos(uv.y) );
return r_dir;
}
// cheaper than smoothstep() linear version
float linearstepc(float a, float b, float value) {
return clamp((value - a) / (b-a),0.0,1.0);
}
float henyey_greenstein(float cos_theta, float g) {
const float k = 0.0795774715459;
return k * (1.0 - g * g) / (pow(1.0 + g * g - 2.0 * g * cos_theta, 1.5));
}
float cos_theta(vec3 r_dir, vec3 light_dir) {
return dot(r_dir, normalize(light_dir));
}
vec3 atmosphere_clouds(vec3 eye_dir) {
float zenith_angle = clamp( dot( UP, normalize(sun_light_direction)), -1.0, 1.0 );
float sun_energy = max(0.0, 1.0 - exp(-((PI * 0.5) - acos(zenith_angle)))) * sun_light_energy;
float sun_fade = 1.0 - clamp(1.0 - exp(normalize(sun_light_direction).y), 0.0, 1.0);
// Rayleigh coefficients.
float rayleigh_coefficient = rayleigh - ( 1.0 * ( 1.0 - sun_fade ) );
vec3 rayleigh_beta = rayleigh_coefficient * rayleigh_color.rgb * 0.0001;
// mie coefficients from Preetham
vec3 mie_beta = turbidity * mie * mie_color.rgb * 0.000434;
// optical length
float zenith = acos(max(0.0, dot( UP, eye_dir)));
float optical_mass = 1.0 / (cos(zenith) + 0.15 * pow(93.885 - degrees(zenith), -1.253));
float rayleigh_scatter = rayleigh_zenith_size * optical_mass;
float mie_scatter = mie_zenith_size * optical_mass;
// light extinction based on thickness of atmosphere
vec3 extinction = exp(-(rayleigh_beta * rayleigh_scatter + mie_beta * mie_scatter));
// in scattering
float cos_theta = dot(eye_dir, normalize(sun_light_direction));
float rayleigh_phase = (3.0 / (16.0 * PI)) * (1.0 + pow(cos_theta * 0.5 + 0.5, 2.0));
vec3 betaRTheta = rayleigh_beta * rayleigh_phase;
float mie_phase = henyey_greenstein(cos_theta, mie_eccentricity);
vec3 betaMTheta = mie_beta * mie_phase;
vec3 Lin = pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * (1.0 - extinction), vec3(1.5));
// Hack from https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Sky.js
Lin *= mix(vec3(1.0), pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * extinction, vec3(0.5)), clamp(pow(1.0 - zenith_angle, 5.0), 0.0, 1.0));
vec3 color;
// Hack in the ground color
//Lin *= mix(ground_color.rgb, vec3(1.0), smoothstep(-0.1, 0.1, dot(UP, EYEDIR)));
//Lin *= mix(ground_color.rgb, vec3(1.0), linearstepc(-0.1, 0.1, dot(UP, eye_dir)));
// Modified For Clouds
Lin *= mix(ground_color.rgb, vec3(1.0), linearstepc(-0.9, 0.1, dot(UP, eye_dir)) * 0.9 + 0.1 );
// Solar disk and out-scattering
float sunAngularDiameterCos = cos(light_size * sun_disk_scale);
float sunAngularDiameterCos2 = cos(light_size * sun_disk_scale * 0.5);
float sundisk = smoothstep(sunAngularDiameterCos, sunAngularDiameterCos2, cos_theta);
vec3 L0 = (sun_energy * extinction) * sundisk * sun_light_color.xyz;
//L0 += texture(night_sky, SKY_COORDS).xyz * extinction;
color = Lin + L0;
color = pow(color, vec3(1.0 / (1.2 + (1.2 * sun_fade) ) ) );
color *= exposure;
return color;
}
void fragment() {
vec3 sky_direction = skybox_uv_to_dir(SCREEN_UV);
ALBEDO = atmosphere_clouds(sky_direction);
}

View File

@ -0,0 +1,156 @@
// Global Wind Vector
global uniform vec2 wind_vector;
global uniform float wind_uplift;
// Global Cloud Textures
global uniform sampler3D cloud_base_texture : hint_anisotropy, filter_linear, repeat_enable;
global uniform sampler3D cloud_detail_texture : hint_anisotropy, filter_linear, repeat_enable;
global uniform sampler3D cloud_volume_texture : hint_anisotropy, filter_linear, repeat_enable;
// Global Sun Light Variables
global uniform vec3 sun_light_direction;
global uniform float sun_light_energy;
global uniform vec3 sun_light_color;
// Global Cloud Variables
// Base
global uniform float cloud_base_height;
global uniform float cloud_base_scale;
global uniform float cloud_base_squeeze;
// Detail
global uniform float cloud_detail_scale;
global uniform float cloud_detail_amount;
global uniform float cloud_detail_dist;
// Volume
global uniform float cloud_volume_scale;
global uniform float cloud_volume_density_low;
global uniform float cloud_volume_density_high;
float pow2(float x){
return x*x;
}
float pow3(float x){
return x*x*x;
}
float pow4(float x){
return pow2(pow2(x));
}
float hash13(vec3 p3) {
p3 = fract(p3 * .1031);
p3 += dot(p3, p3.zyx + 31.32);
return fract((p3.x + p3.y) * p3.z);
}
float hash14(vec4 p4) {
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
p4 += dot(p4, p4.wzxy+33.33);
return fract((p4.x + p4.y) * (p4.z + p4.w));
}
vec3 hash33(vec3 p3) {
p3 = fract(p3 * vec3(.1031, .1030, .0973));
p3 += dot(p3, p3.yxz+33.33);
return fract((p3.xxy + p3.yxx)*p3.zyx);
}
// linear version of smoothstep
float linearstepc(float a, float b, float value) {
return clamp((value - a) / (b-a),0.0,1.0);
}
vec3 saturation(vec3 rgb, float adjustment) {
const vec3 v = vec3(0.2125, 0.7154, 0.0721);
vec3 intensity = vec3(dot(rgb, v));
return mix(intensity, rgb, adjustment);
}
float lum(vec3 rgb) {
const vec3 w = vec3(0.2125, 0.7154, 0.0721);
return dot(rgb, w);
}
vec4 get_cloud_transform() {
vec4 cloud_transform = vec4(0.0, cloud_base_height, 0.0, cloud_base_scale);
cloud_transform.xz += vec2(TIME * wind_vector.x, TIME * wind_vector.y);
return cloud_transform;
}
/*
float get_cloud_density(in vec3 r_pos) {
vec2 tiling = 0.00002 * r_pos.xz;
return texture(cloud_density_texture, tiling * 1.37).x * texture(cloud_density_texture, tiling * 0.57).y;
}
float get_cloud_base(in vec4 r_ori, in vec4 r_dir, in vec4 transform) {
// Ray Position With Added Offset
vec3 r_pos = (r_ori.xyz - transform.xyz) + (r_dir.xyz * r_dir.w);
r_pos *= vec3(cloud_base_squeeze, 1.0, cloud_base_squeeze);
// Avoid Bleeding From Upper and Lower Texture Tile
//r_pos.y = clamp(r_pos.y, -0.5 * transform.w, 0.5 * transform.w);
float clamp_height = clamp( (0.5 * transform.w - abs(r_pos.y)), -1000.0, 0.0);
// Get Current Signed Distance At Position (Add Scaling)
//return texture(cloud_base_texture, (r_pos.xyz / transform.w + vec3(0.5, 0.5, 0.5) ) ) * transform.w - clamp_height;
vec2 dist_all = texture(cloud_base_texture, (r_pos.xyz / transform.w + vec3(0.5, 0.5, 0.5) ) ).xz * transform.w - clamp_height;
float dist_mask = get_cloud_density(r_pos);
float dist_out = mix( dist_all.x, dist_all.y, linearstepc(0.3, 0.6, dist_mask) );
return dist_out;
}
*/
float get_cloud_base(in vec4 r_ori, in vec4 r_dir, in vec4 transform) {
// Ray Position With Added Offset
vec3 r_pos = (r_ori.xyz - transform.xyz) + (r_dir.xyz * r_dir.w);
r_pos *= vec3(cloud_base_squeeze, 1.0, cloud_base_squeeze);
// Avoid Bleeding From Upper and Lower Texture Tile
//r_pos.y = clamp(r_pos.y, -0.5 * transform.w, 0.5 * transform.w);
float clamp_height = clamp( (0.5 * transform.w - abs(r_pos.y)), -1000.0, 0.0);
// Get Current Signed Distance At Position (Add Scaling)
//return texture(cloud_base_texture, (r_pos.xyz / transform.w + vec3(0.5, 0.5, 0.5) ) ) * transform.w - clamp_height;
float dist = texture(cloud_base_texture, (r_pos.xyz / transform.w + vec3(0.5, 0.5, 0.5) ) ).z * transform.w - clamp_height;
return dist;
}
float get_cloud_detail(in vec4 r_ori, in vec4 r_dir, in vec4 transform) {
// Ray Position With Added Offset
vec3 detail_transform = transform.xyz;
detail_transform.y += wind_uplift * r_ori.w;
vec3 r_pos = (r_ori.xyz - detail_transform) + (r_dir.xyz * r_dir.w);
// Get Current Signed Distance At Position (Add Scaling)E
return texture(cloud_detail_texture, (r_pos.xyz / transform.w ) ).x * transform.w;
}
float get_cloud_volume(in vec4 r_ori, in vec4 r_dir, in vec4 transform) {
// Ray Position With Added Offset
vec3 volume_transform = transform.xyz;
volume_transform.y += wind_uplift * r_ori.w * 2.0;
vec3 r_pos = (r_ori.xyz - volume_transform) + (r_dir.xyz * r_dir.w);
// Get Current Volume Texture At Position (Add Scaling)
return texture(cloud_volume_texture, r_pos.xyz / transform.w ).x;
}
vec2 dir_to_skybox_uv(vec3 dir) {
vec2 uv = vec2(atan(dir.x, -dir.z), acos(dir.y));
if (uv.x < 0.0) {
uv.x += PI * 2.0;
}
return (uv / vec2(PI * 2.0, PI));
}
vec3 skybox_uv_to_dir(vec2 uv) {
uv = (uv - 0.5) * vec2(-2.0, -1.0) * PI;
vec3 r_dir = normalize( vec3( sin(uv.x), tan(uv.y), cos(uv.x) ) * cos(uv.y) );
return r_dir;
}
float henyey_greenstein(float cos_theta, float g) {
const float k = 0.0795774715459;
return k * (1.0 - g * g) / (pow(1.0 + g * g - 2.0 * g * cos_theta, 1.5));
}
float cos_theta(vec3 r_dir, vec3 light_dir) {
return dot(r_dir, light_dir);
}

View File

@ -0,0 +1,269 @@
#define CAMERA_CLIP 20000.0
#define R_STEP_MAX 200
#define R_DIST_MIN 1.0
#define R_DIST_MAX 40000.0
#define R_DIST_START_OFFSET 16.0
#define V_STEP_SIZE 10.0
#define V_STEP_SIZE_DIST_MULTIPLIER 10.0
#define L_STEP_MAX 15.0
#define L_STEP_MIN 2.0
#define L_STEP_MIN_DIST 40000.0
shader_type spatial;
render_mode unshaded, shadows_disabled;
#include "res://shaders/cloud_functions.gdshaderinc"
uniform sampler2D buffer_sky : source_color, filter_linear, repeat_disable;
uniform float render_normal_offset = 7.0;
uniform float render_normal_blur = 7.0;
uniform float render_ao_amount = 2.0;
uniform float render_hg_base = 0.7;
uniform float render_hg_amount = 0.5;
uniform float render_hg_mask = 0.05;
uniform float render_hg_color_saturation = 1.0;
uniform float render_hg_color_power = 0.2;
uniform float render_sky_color_saturation = 1.0;
uniform float render_direct_shadow_ramp_dist = 1000.0;
uniform float render_direct_shadow_jitter = 0.05;
uniform float render_short_shadow_amount = 0.1;
uniform float render_short_shadow_dist = 70.0;
uniform float render_smooth_shadow_offset = 150.0;
uniform float render_smooth_shadow_bias = 100.0;
uniform float render_smooth_shadow_amount = 1.0;
void raymarch_cloud(in vec4 r_ori, in vec4 r_dir, in vec4 cloud_transform, inout vec3 cloud_out ) {
// Buffer Vars
float density = 0.0;
float ao = 1.0;
// Screen Noise
float noise = hash14(vec4(r_dir.xyz * 1000.0, r_ori.w)) - 0.5;
// Calculate Back Distance of BBox
float r_back_height = max( abs(r_ori.y - cloud_base_height) + cloud_base_scale * 0.5, 0.0);
float r_dist_back = r_back_height / abs(r_dir.y);
// Start Distance
float dist_ori = r_dir.w;
// Inside Clip
for(int r_step = 0; r_step < R_STEP_MAX; r_step++) {
float dist = get_cloud_base(r_ori, vec4(r_dir.xyz, dist_ori), cloud_transform);
if(dist <= cloud_detail_dist) {
dist = mix(dist, get_cloud_detail(r_ori, vec4(r_dir.xyz, dist_ori), vec4(cloud_transform.xyz, cloud_detail_scale) ), cloud_detail_amount );
}
// Cloud SDF Shape Min Reached
if(dist <= R_DIST_MIN) {
// Volume March Stop Condition
bool v_stop = false;
// Volume Marching
while(v_stop == false) {
// Get Dist From SDF Texture To Calculate Density
float v_dist = get_cloud_base(r_ori, vec4(r_dir.xyz, dist_ori), cloud_transform);
v_dist = mix(v_dist, get_cloud_detail(r_ori, vec4(r_dir.xyz, dist_ori), vec4(cloud_transform.xyz, cloud_detail_scale) ), cloud_detail_amount );
// Leave While-Loop When Not Inside Cloud Volume Shape (SDF < 0.0)
if(v_dist > R_DIST_MIN) {
v_stop = true;
}
// Inside Cloud Density
float v_density = max(-v_dist, 0.0);
// Adding Complexity as AO
ao *= (1.0 - v_density * render_ao_amount * 0.001);
// Current Density Of Volume
float v_tex_density = linearstepc( cloud_volume_density_low, cloud_volume_density_high, get_cloud_volume(r_ori, vec4(r_dir.xyz, dist_ori), vec4(cloud_transform.xyz, cloud_volume_scale) ) * v_density );
// Volume Step Size Adding To Distance To Origin
float dist_step_size = 1.0 + (dist_ori / R_DIST_MAX) * V_STEP_SIZE_DIST_MULTIPLIER;
// Add Current Density To Density Buffer (Use Hash for Correct Sorting)
//density += v_tex_density;
density += step( hash13( vec3(r_ori.xyz + r_dir.xyz * dist_ori) ), v_tex_density); // Noise For Pixel Perfect Mask
// Add Raymarched Distance To Distance To Origin
dist_ori += (V_STEP_SIZE + noise * V_STEP_SIZE) * dist_step_size;
//dist_ori += V_STEP_SIZE * dist_step_size;
if(density >= 1.0 || dist_ori > R_DIST_MAX) {
if(density >= 1.0) {
// Inside Clip ( Cloud SDF + Cloud Volume )
cloud_out = vec3(ao, dist_ori, 1.0);
}
else {
cloud_out = vec3(ao, R_DIST_MAX, density);
}
return;
}
}
}
else {
dist_ori += dist;
}
if( dist_ori > R_DIST_MAX || dist_ori > r_dist_back ) {
// Inside Clip (When Going Outside of BBox Or Further Than Max Ray-Dist)
cloud_out = vec3(ao, R_DIST_MAX, density);
return;
}
}
// Inside Clip (Max Ray-Steps Is Reached)
cloud_out = vec3(ao, dist_ori, density);
return;
}
void lightmarch_cloud(in vec4 r_ori, in vec4 r_dir, in vec4 cloud_transform, inout vec3 color_out ) {
float ao = color_out.x;
float dist_ori = color_out.y;
// Get World Position Based On Distance
vec3 world_pos = r_ori.xyz + r_dir.xyz * dist_ori;
// Cos-Theta Used for Scattering
float cos_theta = cos_theta(r_dir.xyz, sun_light_direction);
// Cloud Density At World Position
float cloud_density = get_cloud_base(r_ori, vec4(r_dir.xyz, dist_ori), cloud_transform);
cloud_density = mix(cloud_density, get_cloud_detail(r_ori, vec4(r_dir.xyz, dist_ori), vec4(cloud_transform.xyz, cloud_detail_scale) ), cloud_detail_amount );
// Cloud Density At Normal Offset (No Detail Pass)
float cloud_density_offset_forward = get_cloud_base(vec4(world_pos, r_ori.w), vec4(vec3(0.0, 0.0, render_normal_offset), render_normal_offset), cloud_transform);
float cloud_density_offset_up = get_cloud_base(vec4(world_pos, r_ori.w), vec4(vec3(0.0, render_normal_offset, 0.0), render_normal_offset), cloud_transform);
float cloud_density_offset_right = get_cloud_base(vec4(world_pos, r_ori.w), vec4(vec3(render_normal_offset, 0.0, 0.0), render_normal_offset), cloud_transform);
// Cloud Normal
vec3 cloud_normal;
cloud_normal.x = (cloud_density_offset_right - cloud_density);
cloud_normal.y = (cloud_density_offset_up - cloud_density);
cloud_normal.z = (cloud_density_offset_forward - cloud_density);
cloud_normal /= render_normal_offset;
cloud_normal = normalize(cloud_normal);
// Cloud Density At Upper Offset For Smooth Shadow
float cloud_density_smooth = get_cloud_base(vec4(world_pos, r_ori.w), vec4( vec3(0.0, 1.0, 0.0), render_smooth_shadow_offset), cloud_transform);
cloud_density_smooth = exp( max(-cloud_density_smooth + render_smooth_shadow_bias, 0.0) * -render_smooth_shadow_amount * 0.001);
// Cloud Density At Screen Space Offset (Used For Henyey Greenstein To Determine Density)
float cloud_density_offset_sss = get_cloud_base(vec4(world_pos, r_ori.w), vec4(r_dir.xyz, 50.0), cloud_transform);
cloud_density_offset_sss = mix(cloud_density_offset_sss, get_cloud_detail(vec4(world_pos, r_ori.w), vec4(r_dir.xyz, 50.0), vec4(cloud_transform.xyz, cloud_detail_scale) ), cloud_detail_amount );
// Cloud Inner Density
float cloud_inner_density = cloud_density;
cloud_inner_density = min(cloud_inner_density, cloud_density_offset_sss);
// Henhey Greenstein Function
float hg_mask = 1.0 - exp( cloud_inner_density * render_hg_mask );
float hg_luminance = henyey_greenstein(cos_theta, clamp(render_hg_base - hg_mask, -1.0, 1.0) ) * render_hg_amount;
// Color Lighting
vec3 hg_color = mix(vec3(hg_luminance), hg_luminance * sun_light_color, pow(cos_theta * 0.5 + 0.5, render_hg_color_power) * render_hg_color_saturation );
// Sky Sample Ray
// Maybe this can be optimized with less normalizations or less samples (but currently this gives best scattering quality)
vec3 noise_vector_c = normalize(hash33(world_pos) - 0.5);
vec3 noise_vector_1 = normalize(hash33(world_pos * 1.067) - 0.5);
vec3 noise_vector_2 = cross(noise_vector_1, noise_vector_c);
vec3 noise_vector_3 = cross(noise_vector_1, noise_vector_2);
vec3 noise_vector_4 = normalize(hash33(world_pos * 0.971) - 0.5);
vec3 noise_vector_5 = cross(noise_vector_4, noise_vector_c);
vec3 noise_vector_6 = cross(noise_vector_4, noise_vector_5);
noise_vector_1 *= render_normal_blur;
noise_vector_2 *= render_normal_blur;
noise_vector_3 *= render_normal_blur;
noise_vector_4 *= render_normal_blur;
noise_vector_5 *= render_normal_blur;
noise_vector_6 *= render_normal_blur;
vec3 sky_ray1 = normalize(cloud_normal + noise_vector_1);
vec3 sky_ray2 = normalize(cloud_normal - noise_vector_1);
vec3 sky_ray3 = normalize(cloud_normal + noise_vector_2);
vec3 sky_ray4 = normalize(cloud_normal - noise_vector_2);
vec3 sky_ray5 = normalize(cloud_normal + noise_vector_3);
vec3 sky_ray6 = normalize(cloud_normal - noise_vector_3);
vec3 sky_ray7 = normalize(cloud_normal + noise_vector_4);
vec3 sky_ray8 = normalize(cloud_normal - noise_vector_4);
vec3 sky_ray9 = normalize(cloud_normal + noise_vector_5);
vec3 sky_ray10 = normalize(cloud_normal - noise_vector_5);
vec3 sky_ray11 = normalize(cloud_normal + noise_vector_6);
vec3 sky_ray12 = normalize(cloud_normal - noise_vector_6);
vec3 sky_tex = texture(buffer_sky, dir_to_skybox_uv(sky_ray1) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray2) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray3) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray4) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray5) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray6) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray7) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray8) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray9) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray10) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray11) ).xyz;
sky_tex += texture(buffer_sky, dir_to_skybox_uv(sky_ray12) ).xyz;
sky_tex *= 0.08333333333333333333333333333; // 1.0 / 12.0 - 12 samples
sky_tex = saturation(sky_tex, render_sky_color_saturation);
// Calculate Back Distance of BBox For Light Ray Start Point
float light_back_height = max( abs(world_pos.y - cloud_base_height - cloud_base_scale * 0.5) , 0.0);
float light_dist_back = light_back_height / abs(sun_light_direction.y);
// Light March Stop Condition
float dist_light = 0.0;
// Light Iterations Based On Distance
int l_step_max = int(L_STEP_MIN + pow4(1.0 - dist_ori / L_STEP_MIN_DIST) * L_STEP_MAX);
for(int l_step = 0; l_step < l_step_max; l_step++) {
vec3 l_step_pos = world_pos + sun_light_direction * light_dist_back;
vec3 l_step_noise = (hash33(l_step_pos) - 0.5) * render_direct_shadow_jitter;
float l_dist = get_cloud_base(vec4(l_step_pos, r_ori.w), vec4(-sun_light_direction.xyz + l_step_noise, dist_light), cloud_transform);
if(l_dist < cloud_detail_dist) {
l_dist = mix(l_dist, get_cloud_detail(vec4(l_step_pos, r_ori.w), vec4(-sun_light_direction.xyz + l_step_noise, dist_light), cloud_transform), cloud_detail_amount );
if(l_dist < 1.0) {
break;
}
}
dist_light += l_dist;
}
// Short Distance Shadow
float short_shadow_mask = get_cloud_base(vec4(world_pos, r_ori.w), vec4(sun_light_direction, render_short_shadow_dist), cloud_transform);
short_shadow_mask = mix(short_shadow_mask, get_cloud_detail(vec4(world_pos, r_ori.w), vec4(sun_light_direction, render_short_shadow_dist), vec4(cloud_transform.xyz, cloud_detail_scale) ), cloud_detail_amount );
short_shadow_mask = exp( max(-short_shadow_mask, 0.0) * -render_short_shadow_amount);
// Directional Shadow Mask Based On Distance To Raymarched Light Ray Hit
float dir_shadow_mask = min( pow4( linearstepc(render_direct_shadow_ramp_dist, 0.0, light_dist_back - dist_light) ), short_shadow_mask);
// Combined Color Output (Shadow as Mask)
color_out = vec3( mix(sky_tex * ao * cloud_density_smooth, sky_tex + hg_color, dir_shadow_mask) );
}
void fragment() {
// Ray Direction & Ray Origin by Engine
vec3 r_dir = normalize(-VIEW * mat3(VIEW_MATRIX));
vec3 r_ori = CAMERA_POSITION_WORLD;
// Start Distance For Ray Marcher To Save Performance (Calculating BBox)
float r_start_height = max( abs(r_ori.y - cloud_base_height) - cloud_base_scale * 0.5 + R_DIST_START_OFFSET, 0.0);
float r_dist_start = r_start_height / abs(r_dir.y);
// Getting Cloud Values Via Raymarch Loop
if(r_dist_start < R_DIST_MAX) {
// Cloud Transform + Wind (vec4 = X,Y,Z,Scale)
vec4 cloud_transform = get_cloud_transform();
// Buffer Vars (cloud_out, color_out)
vec3 cloud_out; // vec3(ao, dist, alpha)
raymarch_cloud(vec4(r_ori, TIME), vec4(r_dir, r_dist_start), cloud_transform, cloud_out );
//cloud_out.z = step(hash13(r_dir * 1370.0), cloud_out.z);
// Defer Lights To Get More Performance (its not physically correct but significiantly reduces alus)
if(cloud_out.z > 0.0) {
vec3 color_out = cloud_out;
lightmarch_cloud(vec4(r_ori, TIME), vec4(r_dir, r_dist_start), cloud_transform, color_out );
ALBEDO = max(color_out, 0.0);
ALPHA = cloud_out.z * pow3(linearstepc(R_DIST_MAX, 3000.0, cloud_out.y));
// This Clamp Is Due To Max Depth Being Reached By The Current Camera, But Are Still Supposed To Be Rendered In The Background (this clamps the depth-range)
vec3 depth_pos = r_ori + r_dir * clamp(cloud_out.y, -CAMERA_CLIP, CAMERA_CLIP);
// Converting Z-Depth Back To Depth (Thanks to Zylann & Detox for helping out)
vec4 sdf_ndc = PROJECTION_MATRIX * VIEW_MATRIX * vec4(depth_pos, 1.0);
DEPTH = sdf_ndc.z / sdf_ndc.w;
}
else {
discard;
}
}
else {
discard;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://do7hse6mjnckx"
path="res://.godot/imported/cloud_density_a.png-b2ce35c306a954e6c2786c9f25430e0e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/clouds/cloud_density_a.png"
dest_files=["res://.godot/imported/cloud_density_a.png-b2ce35c306a954e6c2786c9f25430e0e.ctex"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
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

View File

@ -0,0 +1,26 @@
[remap]
importer="3d_texture"
type="CompressedTexture3D"
uid="uid://bwvwaoihjy78g"
path="res://.godot/imported/cloud_sdf_base.exr-55c0343c3e5f7225fe88952fa3413723.ctex3d"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/clouds/cloud_sdf_base.exr"
dest_files=["res://.godot/imported/cloud_sdf_base.exr-55c0343c3e5f7225fe88952fa3413723.ctex3d"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=8
slices/vertical=8

View File

@ -0,0 +1,26 @@
[remap]
importer="3d_texture"
type="CompressedTexture3D"
uid="uid://437feiv1oerc"
path="res://.godot/imported/cloud_sdf_detail.exr-bd2c9d8e460afae8772a319789981f09.ctex3d"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/clouds/cloud_sdf_detail.exr"
dest_files=["res://.godot/imported/cloud_sdf_detail.exr-bd2c9d8e460afae8772a319789981f09.ctex3d"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=8
slices/vertical=8

View File

@ -0,0 +1,26 @@
[remap]
importer="3d_texture"
type="CompressedTexture3D"
uid="uid://c4opy6v8qffa3"
path="res://.godot/imported/cloud_sdf_detail_b.exr-13df1744e57ce408e090d34f39cc5cd4.ctex3d"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/clouds/cloud_sdf_detail_b.exr"
dest_files=["res://.godot/imported/cloud_sdf_detail_b.exr-13df1744e57ce408e090d34f39cc5cd4.ctex3d"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=8
slices/vertical=8

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 KiB

View File

@ -0,0 +1,27 @@
[remap]
importer="3d_texture"
type="CompressedTexture3D"
uid="uid://4ncscg8jgec0"
path.s3tc="res://.godot/imported/cloud_volume_a.png-959db9024b9de0bc5ca5257ba1c2736d.s3tc.ctex3d"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://textures/clouds/cloud_volume_a.png"
dest_files=["res://.godot/imported/cloud_volume_a.png-959db9024b9de0bc5ca5257ba1c2736d.s3tc.ctex3d"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=8
slices/vertical=8

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cmg6gbkvjx8vq"
path="res://.godot/imported/blue.png-36d07cf579474ce69eeafec9f44e985e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/default/blue.png"
dest_files=["res://.godot/imported/blue.png-36d07cf579474ce69eeafec9f44e985e.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
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=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://fb815f7h0pns"
path="res://.godot/imported/green.png-83e89201777570c08fb0d74113aa7d95.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/default/green.png"
dest_files=["res://.godot/imported/green.png-83e89201777570c08fb0d74113aa7d95.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
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=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://pe1fh6gx30s1"
path="res://.godot/imported/grey_128.png-8444cfd68fff6b46d5cdd7a71827aa0e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/default/grey_128.png"
dest_files=["res://.godot/imported/grey_128.png-8444cfd68fff6b46d5cdd7a71827aa0e.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
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=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://chtdv2en1f1mj"
path="res://.godot/imported/red.png-e1710c3474896c83349ba6597f1d9683.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/default/red.png"
dest_files=["res://.godot/imported/red.png-e1710c3474896c83349ba6597f1d9683.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
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=1

View File

@ -0,0 +1,5 @@
[gd_resource type="Gradient" format=3 uid="uid://cwiiu5dy83cai"]
[resource]
offsets = PackedFloat32Array(0, 0.462366, 0.74552, 0.845878, 0.917563, 0.964158, 1)
colors = PackedColorArray(0, 0, 0, 1, 0.190374, 0.218589, 0.25, 1, 0.544241, 0.544241, 0.544241, 1, 0.780357, 0.600883, 0.52394, 1, 0.908482, 0.750369, 0.526467, 1, 0.96021, 0.923893, 0.693084, 1, 1, 1, 1, 1)

View File

@ -0,0 +1,5 @@
[gd_resource type="Gradient" format=3 uid="uid://dd0aqwo4wa8yj"]
[resource]
offsets = PackedFloat32Array(0, 0.53405, 0.741935, 0.792115, 0.867384, 0.917563, 0.960573, 0.983687, 1)
colors = PackedColorArray(0, 0, 0, 1, 0.53405, 0.53405, 0.53405, 1, 0.741935, 0.741935, 0.741935, 1, 0.79, 0.740493, 0.7268, 1, 0.87, 0.740515, 0.7047, 1, 0.92, 0.824933, 0.736, 1, 0.96, 0.86256, 0.6816, 1, 0.98, 0.89082, 0.5684, 1, 1, 1, 1, 1)

View File

@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://c2754duv8pcgd"]
[node name="Clouds" type="Node3D"]

View File

@ -0,0 +1,86 @@
extends WorldEnvironment
# Node references
@onready var sun_moon_line: Node3D = $SunMoonLine
@onready var world_envi: WorldEnvironment = $"."
@onready var sun_directional_light_3d: DirectionalLight3D = $SunMoonLine/SunNodes/SunDirectionalLight3D
@onready var moon_directional_light_3d: DirectionalLight3D = $SunMoonLine/MoonNodes/MoonDirectionalLight3D
# Exported time control settings
@export_category("Time Controls")
@export_range(0.0, 2400.0, 0.01) var timeOfDay : float = 1200.0
@export_range(1.0, 86400, 1.0) var rateOfTime : float = 0.1
@export var simulatingTime : bool = false
# Exported sky control settings
@export_category("Sky Controls")
@export_range(0, 360, 0.1) var skyRotation : float = 0.0
@export var fog : bool = false
@export_range(0.0, 1.0, 0.001) var fogDensity : float = 0.0
# Exported sky color settings
@export_category("Sky/Light Colors")
@export var sky_base_color_gradient: GradientTexture1D = preload("res://assets/core/enviroment/custom-skies/sky-asset/sky_base_color_gradient.tres")
@export var sun_light_color_gradient: GradientTexture1D = preload("res://assets/core/enviroment/custom-skies/sky-asset/sun_light_color_gradient.tres")
@export var sky_sun_set_rise_color_gradient: GradientTexture1D = preload("res://assets/core/enviroment/custom-skies/sky-asset/sky_sun_set_rise_color_gradient.tres")
# MISC Variables
var sunPosition : float = 0.0
var moonPosition : float = 0.0
var star_alpha
var start_time : float = 0.0
func _physics_process(delta: float) -> void:
_updateRotation()
_updateSky()
_updateLight()
_simulateTime(delta)
_updateFog()
_updateStars(delta)
func _simulateTime(delta):
if simulatingTime:
timeOfDay += (rateOfTime / 36) * delta
timeOfDay = wrapf(timeOfDay, 0.0, 2400.0)
func _updateLight():
sunPosition = sun_directional_light_3d.global_position.y + 0.5
moonPosition = sun_directional_light_3d.global_position.y + 0.5
sun_directional_light_3d.light_color = sun_light_color_gradient.gradient.sample(sunPosition)
func _updateRotation():
var hourMapped = remap(timeOfDay, 0.0, 2400.0, 0.0, 1.0)
sun_moon_line.rotation_degrees.y = skyRotation
sun_moon_line.rotation_degrees.x = hourMapped * 360 + 90
func _updateFog():
if fog == true:
environment.volumetric_fog_density = fogDensity * 0.1
else:
environment.volumetric_fog_density = 0
func _updateStars(delta):
var skyMaterial = self.environment.sky.get_material() # get sky material
if timeOfDay >= 0.0 and timeOfDay <= 585.0: #BETWEEN MIDNIGHT AND MORNING
star_alpha = skyMaterial.sky_cover_modulate.a # gets the current alpha of the stars
star_alpha = lerpf(star_alpha, 1.0, (1 * delta)) # smoothly lerps the current alpha to the new one
skyMaterial.sky_cover_modulate.a = star_alpha # sets the alpha of the stars
elif timeOfDay >= 585.0 and timeOfDay <= 1820.0: #BETWEEN MORNING AND NOON
star_alpha = skyMaterial.sky_cover_modulate.a # gets the current alpha of the stars
star_alpha = lerpf(star_alpha, 0.0, (1 * delta)) # smoothly lerps the current alpha to the new one
skyMaterial.sky_cover_modulate.a = star_alpha # sets the alpha of the stars
elif timeOfDay >= 1820.0 and timeOfDay <= 2400.0: #BETWEEN NOON AND MIDNIGHT
star_alpha = skyMaterial.sky_cover_modulate.a # gets the current alpha of the stars
star_alpha = lerpf(star_alpha, 1.0, (1 * delta)) # smoothly lerps the current alpha to the new one
skyMaterial.sky_cover_modulate.a = star_alpha # sets the alpha of the stars
func _updateSky():
var skyMaterial = self.environment.sky.get_material() # get sky material
# Match sky to gradient color
skyMaterial.sky_top_color = sky_base_color_gradient.gradient.sample(sunPosition) # sample gradient and set sky top color to match based on the time of day
skyMaterial.sky_horizon_color = sky_sun_set_rise_color_gradient.gradient.sample(sunPosition) # sample gradient and set sky horizon color to match based on the time of day
# Match ground to gradient color
skyMaterial.ground_bottom_color = sky_base_color_gradient.gradient.sample(sunPosition) # sample gradient and set ground top color to match based on the time of day
skyMaterial.ground_horizon_color = sky_sun_set_rise_color_gradient.gradient.sample(sunPosition) # sample gradient and set ground horizon color to match based on the time of day

View File

@ -0,0 +1,56 @@
[gd_scene load_steps=6 format=3 uid="uid://ciak2pkm2kom6"]
[ext_resource type="Texture2D" uid="uid://cx7i0fi1jin6q" path="res://assets/core/enviroment/custom-skies/sky-asset/star-texture.png" id="1_qrqqh"]
[ext_resource type="Script" path="res://assets/core/enviroment/custom-skies/sky-asset/custom_skies.gd" id="2_unvmv"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_tcxa4"]
sky_top_color = Color(0.345098, 0.45098, 0.588235, 1)
sky_horizon_color = Color(0.345098, 0.45098, 0.588235, 1)
sky_cover = ExtResource("1_qrqqh")
sky_cover_modulate = Color(1, 1, 1, 7.93862e-39)
ground_bottom_color = Color(0.345098, 0.45098, 0.588235, 1)
ground_horizon_color = Color(0.345098, 0.45098, 0.588235, 1)
ground_curve = 0.0273208
sun_angle_max = 3.0
sun_curve = 0.439227
[sub_resource type="Sky" id="Sky_aggj1"]
sky_material = SubResource("ProceduralSkyMaterial_tcxa4")
[sub_resource type="Environment" id="Environment_8p04f"]
background_mode = 2
sky = SubResource("Sky_aggj1")
reflected_light_source = 2
tonemap_mode = 3
ssr_enabled = true
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
sdfgi_use_occlusion = true
fog_density = 0.0
volumetric_fog_enabled = true
volumetric_fog_density = 0.0
[node name="CustomSkies" type="WorldEnvironment"]
environment = SubResource("Environment_8p04f")
script = ExtResource("2_unvmv")
rateOfTime = 500.0
skyRotation = 18.5
[node name="SunMoonLine" type="Node3D" parent="."]
transform = Transform3D(0.948324, -0.317304, 3.78381e-09, 0, 1.19248e-08, 0.999998, -0.317305, -0.948321, 1.13086e-08, 0, 0, 0)
[node name="SunNodes" type="Node3D" parent="SunMoonLine"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5)
[node name="SunDirectionalLight3D" type="DirectionalLight3D" parent="SunMoonLine/SunNodes"]
light_bake_mode = 1
shadow_enabled = true
[node name="MoonNodes" type="Node3D" parent="SunMoonLine"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5)
[node name="MoonDirectionalLight3D" type="DirectionalLight3D" parent="SunMoonLine/MoonNodes"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
light_energy = 0.01
shadow_enabled = true

View File

@ -0,0 +1,9 @@
[gd_resource type="GradientTexture1D" load_steps=2 format=3 uid="uid://3e2k7wllekm8"]
[sub_resource type="Gradient" id="Gradient_fqghg"]
interpolation_mode = 2
offsets = PackedFloat32Array(0.245161, 0.767742)
colors = PackedColorArray(0.0196078, 0.00784314, 0.0980392, 1, 0.345098, 0.45098, 0.588235, 1)
[resource]
gradient = SubResource("Gradient_fqghg")

View File

@ -0,0 +1,9 @@
[gd_resource type="GradientTexture1D" load_steps=2 format=3 uid="uid://df17po01nhu3c"]
[sub_resource type="Gradient" id="Gradient_mw8hp"]
interpolation_mode = 2
offsets = PackedFloat32Array(0.167742, 0.458065, 0.645161, 0.780645)
colors = PackedColorArray(0, 0, 0, 1, 0.756863, 0.356863, 0.321569, 1, 0.831373, 0.592157, 0.388235, 1, 0.345098, 0.45098, 0.588235, 1)
[resource]
gradient = SubResource("Gradient_mw8hp")

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 MiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cx7i0fi1jin6q"
path.s3tc="res://.godot/imported/star-texture.png-56b0ece7656164ea391a5522d028ae23.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://assets/core/enviroment/custom-skies/sky-asset/star-texture.png"
dest_files=["res://.godot/imported/star-texture.png-56b0ece7656164ea391a5522d028ae23.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

View File

@ -0,0 +1,9 @@
[gd_resource type="GradientTexture1D" load_steps=2 format=3 uid="uid://bosyl6tsy1wpf"]
[sub_resource type="Gradient" id="Gradient_o6r7l"]
interpolation_mode = 2
offsets = PackedFloat32Array(0.167742, 0.48, 0.748387, 1)
colors = PackedColorArray(0, 0, 0, 1, 0.756863, 0.356863, 0.321569, 1, 0.831373, 0.592157, 0.388235, 1, 1, 1, 1, 1)
[resource]
gradient = SubResource("Gradient_o6r7l")

View File

@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://dlv4cwhskx8dr"]
[ext_resource type="PackedScene" uid="uid://ciak2pkm2kom6" path="res://assets/core/enviroment/custom-skies/sky-asset/custom_skies.tscn" id="1_g8g48"]
[ext_resource type="PackedScene" uid="uid://c2754duv8pcgd" path="res://assets/core/enviroment/custom-skies/clouds/clouds.tscn" id="2_iqdk5"]
[node name="Sky" type="Node"]
[node name="CustomSkies" parent="." instance=ExtResource("1_g8g48")]
simulatingTime = true
[node name="Clouds" parent="." instance=ExtResource("2_iqdk5")]
[editable path="CustomSkies"]

View File

@ -1,32 +1,19 @@
[gd_scene load_steps=6 format=3 uid="uid://ewovs6ns5y3k"] [gd_scene load_steps=5 format=3 uid="uid://ewovs6ns5y3k"]
[ext_resource type="PackedScene" uid="uid://c6w0ivy4hetrl" path="res://assets/core/player-controller/scenes/player.tscn" id="2_q510b"] [ext_resource type="PackedScene" uid="uid://c6w0ivy4hetrl" path="res://assets/core/player-controller/scenes/player.tscn" id="2_q510b"]
[ext_resource type="PackedScene" uid="uid://y0xb2vktsr1k" path="res://assets/core/ships/shuttle-class/shuttle-class.tscn" id="3_lsckv"]
[ext_resource type="PackedScene" uid="uid://dqymnaouq1mu2" path="res://assets/core/enviroment/dev-level/terrain.tscn" id="3_vcq2f"] [ext_resource type="PackedScene" uid="uid://dqymnaouq1mu2" path="res://assets/core/enviroment/dev-level/terrain.tscn" id="3_vcq2f"]
[ext_resource type="PackedScene" uid="uid://dlv4cwhskx8dr" path="res://assets/core/enviroment/custom-skies/sky.tscn" id="4_uss2e"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_yg2er"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_roqfl"]
sky_material = SubResource("ProceduralSkyMaterial_yg2er")
[sub_resource type="Environment" id="Environment_nyust"]
background_mode = 2
sky = SubResource("Sky_roqfl")
tonemap_mode = 2
glow_enabled = true
[node name="DevLevel" type="Node3D"] [node name="DevLevel" type="Node3D"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_nyust")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0)
shadow_enabled = true
[node name="Player" parent="." instance=ExtResource("2_q510b")] [node name="Player" parent="." instance=ExtResource("2_q510b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.02866, 27.0719, 0.35519) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.46532, 9.08969, 5.43659)
joystick_camera_sens_multiplier = 5.0 joystick_camera_sens_multiplier = 5.0
[node name="level" parent="." instance=ExtResource("3_vcq2f")] [node name="level" parent="." instance=ExtResource("3_vcq2f")]
[node name="ShuttleClass" parent="." instance=ExtResource("3_lsckv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8.4922, 0)
[node name="Sky" parent="." instance=ExtResource("4_uss2e")]

View File

@ -12,7 +12,7 @@ shader_parameter/WallTexScale = 1.0
shader_parameter/WallColor = Color(0.662452, 0.662452, 0.662452, 1) shader_parameter/WallColor = Color(0.662452, 0.662452, 0.662452, 1)
shader_parameter/TopTexScale = 1.005 shader_parameter/TopTexScale = 1.005
shader_parameter/TopColor = Color(0.466181, 0.466181, 0.466181, 1) shader_parameter/TopColor = Color(0.466181, 0.466181, 0.466181, 1)
shader_parameter/BlendValues = Vector4(3.12, -1.96, 0, 1.115) shader_parameter/BlendValues = Vector4(3.495, -2.27, 0, 1.19)
shader_parameter/WallTex = ExtResource("4_c1a6l") shader_parameter/WallTex = ExtResource("4_c1a6l")
shader_parameter/TopTex = ExtResource("3_u3eue") shader_parameter/TopTex = ExtResource("3_u3eue")

View File

@ -1,16 +1,36 @@
[gd_scene load_steps=4 format=3 uid="uid://dm31ddavxv5gt"] [gd_scene load_steps=7 format=3 uid="uid://dm31ddavxv5gt"]
[ext_resource type="Script" path="res://assets/core/interactables/ship-helm/ship_helm.gd" id="1_lsarv"] [ext_resource type="Script" path="res://assets/core/interactables/ship-helm/ship_helm.gd" id="1_lsarv"]
[ext_resource type="PackedScene" uid="uid://d2e3plio1db16" path="res://assets/core/interactables/ship-helm/ship_helm.blend" id="2_n3ctg"] [ext_resource type="PackedScene" uid="uid://d2e3plio1db16" path="res://assets/core/interactables/ship-helm/ship_helm.blend" id="2_n3ctg"]
[ext_resource type="Texture2D" uid="uid://becx0d2aass76" path="res://addons/kennysprototypetextures/Purple/texture_purple (1).png" id="3_sgyh6"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vj8ph"]
albedo_texture = ExtResource("3_sgyh6")
uv1_triplanar = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_mtdgj"]
albedo_texture = ExtResource("3_sgyh6")
uv1_triplanar = true
[sub_resource type="BoxShape3D" id="BoxShape3D_u6a0w"] [sub_resource type="BoxShape3D" id="BoxShape3D_u6a0w"]
size = Vector3(1, 1.23828, 0.332275) size = Vector3(1, 1.23828, 0.332275)
[node name="ShipHelm" type="StaticBody3D"] [node name="ShipHelm" type="StaticBody3D"]
collision_layer = 256
collision_mask = 7
script = ExtResource("1_lsarv") script = ExtResource("1_lsarv")
[node name="ship_helm" parent="." instance=ExtResource("2_n3ctg")] [node name="ship_helm" parent="." instance=ExtResource("2_n3ctg")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.681346, 0)
[node name="Cube" parent="ship_helm" index="0"]
material_override = SubResource("StandardMaterial3D_vj8ph")
[node name="Torus" parent="ship_helm" index="1"]
material_override = SubResource("StandardMaterial3D_mtdgj")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.220532, 0.0608378) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.901878, 0.0608378)
shape = SubResource("BoxShape3D_u6a0w") shape = SubResource("BoxShape3D_u6a0w")
[editable path="ship_helm"]

View File

@ -2,21 +2,21 @@ class_name ShipHelm
extends Interactable extends Interactable
@export var parent_ship: Ship var parent_ship: Ship
@export var helm_lock_pos: Marker3D
var is_being_piloted: bool = false
func _ready():
parent_ship = get_parent() #sets the parent ship to the ship that the helm is placed on
func interact(): func interact():
if !is_being_piloted: if !parent_ship.ship_is_piloted:
player_reference.set_is_piloting(true) player_reference.set_is_piloting(true)
print("set player to piloting") print("set player to piloting")
is_being_piloted = true
parent_ship.ship_is_piloted = true parent_ship.ship_is_piloted = true
elif is_being_piloted:
elif parent_ship.ship_is_piloted:
player_reference.set_is_piloting(false) player_reference.set_is_piloting(false)
print("set player to NOT piloting") print("set player to NOT piloting")
is_being_piloted = false
parent_ship.ship_is_piloted = false parent_ship.ship_is_piloted = false
GameConsole.log_debug("helm pilot state - " + str(is_being_piloted)) GameConsole.log_debug("helm pilot state - " + str(parent_ship.ship_is_piloted))

View File

@ -1,51 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://cje1q2piwu0ri"
path="res://.godot/imported/ship_helm.blend-ea3ce672878a6c3516ac3fa7aae30891.scn"
[deps]
source_file="res://assets/core/placeable-objects/ship_helm.blend"
dest_files=["res://.godot/imported/ship_helm.blend-ea3ce672878a6c3516ac3fa7aae30891.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={}
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c3lblkyavjtol"
path="res://.godot/imported/2d_crosshair_dot.png-61f11b68155f3e5bb55efff33412dc26.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/core/player-controller/2d_crosshair_dot.png"
dest_files=["res://.godot/imported/2d_crosshair_dot.png-61f11b68155f3e5bb55efff33412dc26.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
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=1

View File

@ -0,0 +1,8 @@
shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
void fragment(){
vec4 color = vec4(texture(SCREEN_TEXTURE, SCREEN_UV).rgb, texture(TEXTURE, UV).a);
COLOR = vec4(1.0 - color.rgb, color.a);
}

View File

@ -1,7 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://c6w0ivy4hetrl"] [gd_scene load_steps=11 format=3 uid="uid://c6w0ivy4hetrl"]
[ext_resource type="Script" path="res://assets/core/player-controller/scripts/player.gd" id="1_bv7t4"] [ext_resource type="Script" path="res://assets/core/player-controller/scripts/player.gd" id="1_bv7t4"]
[ext_resource type="Script" path="res://assets/core/player-controller/scripts/player_interacter.gd" id="2_wvu3d"] [ext_resource type="Script" path="res://assets/core/player-controller/scripts/player_interacter.gd" id="2_wvu3d"]
[ext_resource type="Script" path="res://assets/core/player-controller/scripts/player_hud.gd" id="3_02ne1"]
[ext_resource type="Shader" path="res://assets/core/player-controller/scenes/inverted_crosshair.gdshader" id="3_rakxt"]
[ext_resource type="Texture2D" uid="uid://c3lblkyavjtol" path="res://assets/core/player-controller/2d_crosshair_dot.png" id="4_3uwxe"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_v7b3h"] [sub_resource type="CapsuleMesh" id="CapsuleMesh_v7b3h"]
radius = 0.35 radius = 0.35
@ -9,8 +12,18 @@ radius = 0.35
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_qlkab"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_qlkab"]
radius = 0.35 radius = 0.35
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_fqbrh"]
auto_exposure_enabled = true
auto_exposure_max_sensitivity = 700.0
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wmxrr"]
shader = ExtResource("3_rakxt")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0n7pd"]
shader = ExtResource("3_rakxt")
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("camera")] [node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("camera")]
collision_mask = 243 collision_mask = 242
script = ExtResource("1_bv7t4") script = ExtResource("1_bv7t4")
camera = NodePath("Neck/Camera3D") camera = NodePath("Neck/Camera3D")
@ -31,8 +44,70 @@ shape = SubResource("CapsuleShape3D_qlkab")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.65, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.65, 0)
[node name="Camera3D" type="Camera3D" parent="Neck"] [node name="Camera3D" type="Camera3D" parent="Neck"]
attributes = SubResource("CameraAttributesPractical_fqbrh")
[node name="RayCast3D" type="RayCast3D" parent="Neck/Camera3D" node_paths=PackedStringArray("player")] [node name="RayCast3D" type="RayCast3D" parent="Neck/Camera3D" node_paths=PackedStringArray("player")]
target_position = Vector3(0, 0, -2.5) target_position = Vector3(0, 0, -2.5)
collision_mask = 256
script = ExtResource("2_wvu3d") script = ExtResource("2_wvu3d")
player = NodePath("../../..") player = NodePath("../../..")
[node name="PlayerHUD" type="CanvasLayer" parent="." node_paths=PackedStringArray("fps_label")]
script = ExtResource("3_02ne1")
fps_label = NodePath("Debug/HBoxContainer/VBoxContainer/MarginContainer/FPSLabel")
[node name="Overlay" type="Control" parent="PlayerHUD"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
[node name="CenterContainer" type="CenterContainer" parent="PlayerHUD/Overlay"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="TextureRect" type="TextureRect" parent="PlayerHUD/Overlay/CenterContainer"]
material = SubResource("ShaderMaterial_wmxrr")
layout_mode = 2
texture = ExtResource("4_3uwxe")
[node name="Debug" type="Control" parent="PlayerHUD"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
[node name="HBoxContainer" type="HBoxContainer" parent="PlayerHUD/Debug"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
alignment = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PlayerHUD/Debug/HBoxContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="PlayerHUD/Debug/HBoxContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
[node name="FPSLabel" type="Label" parent="PlayerHUD/Debug/HBoxContainer/VBoxContainer/MarginContainer"]
material = SubResource("ShaderMaterial_0n7pd")
layout_mode = 2
theme_override_font_sizes/font_size = 35
text = "999 FPS"
horizontal_alignment = 2
vertical_alignment = 1

View File

@ -52,11 +52,12 @@ func _input(event):
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
if current_ship != null: if current_ship != null:
if !is_piloting: if is_piloting: #if we are piloting a ship
velocity = walk(delta) + _gravity(delta) + _jump(delta) global_transform.basis = current_ship.global_transform.basis
global_basis = current_ship.global_basis
else:
global_rotation.y = current_ship.global_rotation.y global_rotation.y = current_ship.global_rotation.y
else: #if we are NOT piloting a ship
velocity = walk(delta) + _gravity(delta) + _jump(delta)
global_rotation.y = current_ship.global_rotation.y global_rotation.y = current_ship.global_rotation.y

View File

@ -0,0 +1,7 @@
extends CanvasLayer
@export var fps_label: Label
func _process(delta):
fps_label.text = str(Engine.get_frames_per_second()) + " FPS"

View File

@ -0,0 +1,56 @@
class_name Ship
extends RigidBody3D
@export var player_detection_area: Area3D
var ship_helm_scene: PackedScene = load("res://assets/core/interactables/ship-helm/ship-helm.tscn")
var ship_helm: ShipHelm
var piloting_player: Player = null
var ship_id: int = 0
var ship_is_piloted: bool = false
var turn_speed: float = 10.0
var lift_speed: float = 10.0
var top_speed: float = 10.0
var move_speed: float = 10.0
var acceleration: float = 10.0
var deceleration: float = 20.0
func _ready():
#connect signals
player_detection_area.body_entered.connect(_on_area_3d_body_entered)
player_detection_area.body_exited.connect(_on_area_3d_body_exited)
_add_ship_helm(ship_helm_scene) #TEMPORARY TEST
ship_id = randi_range(1000, 9999) #assign a random id to the ship as a unique identifier
GameConsole.log_debug("Ship ID: " + str(ship_id))
func _physics_process(delta):
if ship_is_piloted:
pass
func _on_area_3d_body_entered(body):
if body is Player:
body.player_entered_ship(global_position, self)
piloting_player = body
print(self.name)
func _on_area_3d_body_exited(body):
if body is Player:
body.player_exited_ship(global_position, self)
ship_is_piloted = false
piloting_player = null
func _add_ship_helm(_ship_helm_scene: PackedScene):
var ship_helm = _ship_helm_scene.instantiate()
add_child(ship_helm)
ship_helm = get_node("ShipHelm")

View File

@ -0,0 +1,46 @@
[gd_scene load_steps=7 format=3 uid="uid://y0xb2vktsr1k"]
[ext_resource type="Script" path="res://assets/core/ships/ship_script.gd" id="1_ghft7"]
[ext_resource type="Texture2D" uid="uid://gymb0tju4y67" path="res://addons/kennysprototypetextures/Dark/texture_black (1).png" id="2_3koq8"]
[sub_resource type="BoxShape3D" id="BoxShape3D_6gbwt"]
size = Vector3(5, 0.15, 20)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_g0mto"]
albedo_texture = ExtResource("2_3koq8")
uv1_triplanar = true
[sub_resource type="BoxMesh" id="BoxMesh_d2exa"]
size = Vector3(5, 0.15, 20)
[sub_resource type="BoxShape3D" id="BoxShape3D_7o08p"]
size = Vector3(4.99609, 2.95453, 20.0022)
[node name="ShuttleClass" type="RigidBody3D" node_paths=PackedStringArray("player_detection_area")]
collision_layer = 8
collision_mask = 200
mass = 700.0
gravity_scale = 0.0
script = ExtResource("1_ghft7")
player_detection_area = NodePath("PlayerDetectionArea")
[node name="ShipToShipCol" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_6gbwt")
[node name="PlayerShipShape" type="StaticBody3D" parent="."]
collision_layer = 16
collision_mask = 5
[node name="ShipMesh" type="MeshInstance3D" parent="PlayerShipShape"]
material_override = SubResource("StandardMaterial3D_g0mto")
mesh = SubResource("BoxMesh_d2exa")
skeleton = NodePath("../..")
[node name="ShipToShipCol" type="CollisionShape3D" parent="PlayerShipShape"]
shape = SubResource("BoxShape3D_6gbwt")
[node name="PlayerDetectionArea" type="Area3D" parent="."]
[node name="PlayerDetectionAreaCol" type="CollisionShape3D" parent="PlayerDetectionArea"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.55551, 0)
shape = SubResource("BoxShape3D_7o08p")

View File

@ -1,4 +1,4 @@
class_name Ship
extends RigidBody3D extends RigidBody3D
@export var ship_area: Area3D @export var ship_area: Area3D

View File

@ -28,6 +28,7 @@ file_logging/enable_file_logging=true
window/size/viewport_width=1280 window/size/viewport_width=1280
window/size/viewport_height=720 window/size/viewport_height=720
window/vsync/vsync_mode=0
[dotnet] [dotnet]