Skip to content

Commit

Permalink
Solar bodies cause weird shadows and bridges are too dark (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
TitanNano authored Aug 28, 2024
1 parent ad77282 commit 9a29559
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 557 deletions.
29 changes: 29 additions & 0 deletions native/src/scripts/world/solar_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct SolarSetup {
#[export]
pub moon: Option<Gd<DirectionalLight3D>>,

cached_moon_brightness: f32,

// duration from sun rise to sun set in minutes
#[export(range(min = 1.0, max = 120.0, step = 1.0))]
pub day_length: u64,
Expand All @@ -25,6 +27,16 @@ struct SolarSetup {

#[godot_script_impl]
impl SolarSetup {
pub fn _ready(&mut self) {
let Some(ref mut moon) = self.moon else {
logger::error!("no moon is assinged to solar setup!");
logger::error!("node path: {}", self.base.get_path());
return;
};

self.cached_moon_brightness = moon.get_param(light_3d::Param::ENERGY);
}

pub fn _physics_process(&mut self, _delta: f64) {
let day_length = self.day_length * 60 * 1000;
let time = Time::singleton().get_ticks_msec() % (day_length * 2);
Expand All @@ -38,12 +50,29 @@ impl SolarSetup {
return;
};

let Some(ref mut moon) = self.moon else {
logger::error!("no moon is assinged to solar setup!");
logger::error!("node path: {}", self.base.get_path());
return;
};

self.base
.set_rotation_degrees(Vector3::new(sun_pos, 0.0, 0.0));

sun.set_param(
light_3d::Param::ENERGY,
if sun_pos > 190.0 { 0.0 } else { 1.0 },
);
sun.set_shadow(sun_pos < 190.0);

moon.set_param(
light_3d::Param::ENERGY,
if sun_pos > 180.0 {
self.cached_moon_brightness
} else {
0.0
},
);
moon.set_shadow(sun_pos > 180.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dest_files=["res://.godot/imported/raising_tower_top_bottom.glb-e059634e7e52b919

[params]

nodes/root_type="Node3D"
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
Expand All @@ -29,6 +29,12 @@ animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"nodes": {
"PATH:Maxis-3d2-mesh-67": {
"generate/occluder": 1
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
Binary file modified resources/Meshes/Networks/Bridge/suspension_center.glb
Binary file not shown.
10 changes: 8 additions & 2 deletions resources/Meshes/Networks/Bridge/suspension_center.glb.import
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dest_files=["res://.godot/imported/suspension_center.glb-79e1b1e994a4b8382f874c3

[params]

nodes/root_type="Node3D"
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
Expand All @@ -29,6 +29,12 @@ animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"nodes": {
"PATH:Maxis-3d2-mesh-62-BR83": {
"generate/occluder": 1
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
10 changes: 8 additions & 2 deletions resources/Meshes/Networks/Bridge/suspension_end_top.glb.import
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dest_files=["res://.godot/imported/suspension_end_top.glb-ab41fef8303586c6945b5a

[params]

nodes/root_type="Node3D"
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
Expand All @@ -29,6 +29,12 @@ animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"nodes": {
"PATH:Maxis-3d2-mesh-66-BR81": {
"generate/occluder": 1
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dest_files=["res://.godot/imported/suspension_middle_bottom.glb-49e18609fca4e60a

[params]

nodes/root_type="Node3D"
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
Expand All @@ -29,6 +29,12 @@ animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"nodes": {
"PATH:Maxis-3d2-mesh-60-BR01": {
"generate/occluder": 1
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dest_files=["res://.godot/imported/suspension_middle_top.glb-c6909b014884010b420

[params]

nodes/root_type="Node3D"
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
Expand All @@ -29,6 +29,12 @@ animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"nodes": {
"PATH:Maxis-3d2-mesh-64-BR01": {
"generate/occluder": 1
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dest_files=["res://.godot/imported/suspension_start_bottom.glb-8ab64fe4b0dde3fda

[params]

nodes/root_type="Node3D"
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
Expand All @@ -29,6 +29,12 @@ animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"nodes": {
"PATH:Maxis-3d2-mesh-58-BR81": {
"generate/occluder": 1
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
10 changes: 8 additions & 2 deletions resources/Meshes/Networks/Bridge/top_bottom.glb.import
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dest_files=["res://.godot/imported/top_bottom.glb-db413727c8e1adcbdc531d837bd03d

[params]

nodes/root_type="Node3D"
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
Expand All @@ -29,6 +29,12 @@ animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"nodes": {
"PATH:Maxis-3d2-mesh-55": {
"generate/occluder": 1
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1

Large diffs are not rendered by default.

Loading

0 comments on commit 9a29559

Please sign in to comment.