mirror of
https://codeberg.org/sunder/sunder.git
synced 2026-07-12 04:24:36 +00:00
upgrade sky_3d
This commit is contained in:
parent
82aeebfd35
commit
721d3f0716
27 changed files with 561 additions and 655 deletions
|
|
@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/SkyIcon.png-7b3cbfa68354965cdbfdba8b95dacf67.
|
|||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
|
|
@ -25,6 +27,10 @@ mipmaps/generate=false
|
|||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ dest_files=["res://.godot/imported/noise.jpg-b47d5d36d9abfdaec2a09c140a78ba24.s3
|
|||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
|
|
@ -26,6 +28,10 @@ mipmaps/generate=true
|
|||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ dest_files=["res://.godot/imported/noise2.png-37a5cbd5451b4b9c2c18ab32099e6965.s
|
|||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
|
|
@ -26,6 +28,10 @@ mipmaps/generate=false
|
|||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ dest_files=["res://.godot/imported/noiseClouds.png-07511094ef8b72a49cc860b35c60d
|
|||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
|
|
@ -26,6 +28,10 @@ mipmaps/generate=true
|
|||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ dest_files=["res://.godot/imported/Milkyway.jpg-a06044e407cf6953ab6e46a2f0f17f3a
|
|||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
|
|
@ -26,6 +28,10 @@ mipmaps/generate=true
|
|||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ dest_files=["res://.godot/imported/StarField.jpg-9d224e20fcbe8fdc7ff5028dae26983
|
|||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
|
|
@ -26,6 +28,10 @@ mipmaps/generate=true
|
|||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ dest_files=["res://.godot/imported/MoonMap.png-81d542c3fafff4e5b235a177af6f3221.
|
|||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
|
|
@ -26,6 +28,10 @@ mipmaps/generate=true
|
|||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://bw2jsmvl58av6
|
||||
uid://dloe2lwoavad0
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ uniform float _clouds_noise_freq;
|
|||
uniform float _clouds_sky_tint_fade;
|
||||
uniform float _clouds_intensity;
|
||||
uniform float _clouds_size;
|
||||
uniform float _clouds_speed;
|
||||
uniform vec3 _clouds_direction;
|
||||
uniform float _clouds_offset_speed;
|
||||
uniform vec3 _clouds_offset;
|
||||
uniform sampler2D _clouds_texture;
|
||||
|
||||
uniform vec4 _clouds_day_color: source_color;
|
||||
|
|
@ -88,7 +88,7 @@ float remap(float value, float fromMin, float fromMax, float toMin, float toMax)
|
|||
}
|
||||
|
||||
float cloudsDensity(vec3 p, vec3 offset, float t){
|
||||
vec3 pos = p * 0.0212242 - offset;
|
||||
vec3 pos = p * 0.0212242 + offset;
|
||||
float dens = noiseCloudsFBM(pos, _clouds_noise_freq);
|
||||
dens += dens;
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ float miePhase(float mu, vec3 partial){
|
|||
|
||||
vec4 renderClouds2(vec3 ro, vec3 rd, float tm, float am){
|
||||
vec4 ret = vec4(0, 0, 0, 0);
|
||||
vec3 wind = _clouds_direction * (tm * _clouds_speed);
|
||||
vec3 wind = _clouds_offset * (tm * _clouds_offset_speed);
|
||||
float a = 0.0;
|
||||
|
||||
// n and tt doesnt need to be initialized since it would be set by IntersectSphere
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://cpurajoc7on7d
|
||||
uid://bfhgghs02klx1
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ uniform float _clouds_sky_tint_fade;
|
|||
uniform float _clouds_intensity;
|
||||
uniform float _clouds_size;
|
||||
uniform vec2 _clouds_uv;
|
||||
uniform float _clouds_speed;
|
||||
uniform vec2 _clouds_direction;
|
||||
uniform float _clouds_offset_speed;
|
||||
uniform vec2 _clouds_offset;
|
||||
uniform vec4 _clouds_day_color: source_color;
|
||||
uniform vec4 _clouds_horizon_light_color: source_color;
|
||||
uniform vec4 _clouds_night_color: source_color;
|
||||
|
|
@ -186,11 +186,8 @@ vec3 atmosphericScattering(float sr, float sm, vec2 mu, vec3 mult){
|
|||
// Clouds
|
||||
//------------------------------------------------------------------------------
|
||||
float noiseClouds(vec2 coords, vec2 offset){
|
||||
float speed = TIME * _clouds_speed * .5; // .5 matches cumulus clouds
|
||||
vec2 wind = offset * speed;
|
||||
vec2 wind2 = (offset + offset) * speed;
|
||||
float a = textureLod(_clouds_texture, coords.xy * _clouds_uv - wind, 0.0).r;
|
||||
float b = textureLod(_clouds_texture, coords.xy * _clouds_uv - wind2, 0.0).r;
|
||||
float a = textureLod(_clouds_texture, coords.xy * _clouds_uv + offset.x, 0.0).r;
|
||||
float b = textureLod(_clouds_texture, coords.xy * _clouds_uv + offset.y, 0.0).r;
|
||||
return ((a + b) * 0.5);
|
||||
}
|
||||
|
||||
|
|
@ -201,10 +198,11 @@ float cloudsDensity(vec2 p, vec2 offset){
|
|||
return saturate(d);
|
||||
}
|
||||
|
||||
vec4 renderClouds(vec3 pos){
|
||||
vec4 renderClouds(vec3 pos, float tm){
|
||||
pos.xy = pos.xz / pos.y;
|
||||
pos *= _clouds_size;
|
||||
float density = cloudsDensity(pos.xy, _clouds_direction);
|
||||
vec2 wind = _clouds_offset.xy * (tm * _clouds_offset_speed);
|
||||
float density = cloudsDensity(pos.xy, wind);
|
||||
float sh = saturate(exp(-_clouds_absorption * density));
|
||||
float a = saturate(density * _clouds_thickness);
|
||||
return vec4(vec3(density*sh) * _clouds_intensity, a);
|
||||
|
|
@ -284,7 +282,7 @@ void fragment(){
|
|||
col.rgb += deepSpace.rgb * horizonBlend;
|
||||
|
||||
// Clouds
|
||||
vec4 clouds = renderClouds(cloudsPos);
|
||||
vec4 clouds = renderClouds(cloudsPos, TIME);
|
||||
clouds.a = saturate(clouds.a);
|
||||
clouds.rgb *= mix(mix(_clouds_day_color.rgb, _clouds_horizon_light_color.rgb, angle_mult.x),
|
||||
_clouds_night_color.rgb, angle_mult.w);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://byx8tkkv3yf4f
|
||||
uid://dmdpvegai5hc5
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://beedso8sc7lef
|
||||
uid://cnea1xaudqctw
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ uniform float _clouds_sky_tint_fade;
|
|||
uniform float _clouds_intensity;
|
||||
uniform float _clouds_size;
|
||||
uniform vec2 _clouds_uv;
|
||||
uniform float _clouds_speed;
|
||||
uniform vec2 _clouds_direction;
|
||||
uniform float _clouds_offset_speed;
|
||||
uniform vec2 _clouds_offset;
|
||||
uniform vec4 _clouds_day_color: source_color;
|
||||
uniform vec4 _clouds_horizon_light_color: source_color;
|
||||
uniform vec4 _clouds_night_color: source_color;
|
||||
|
|
@ -149,11 +149,11 @@ void simpleOpticalDepth(float y, out float sr, out float sm){
|
|||
void opticalDepth(float y, out float sr, out float sm){
|
||||
y = max(0.0, y);
|
||||
y = saturate(y * _atm_level_params.x);
|
||||
|
||||
|
||||
float zenith = acos(y);
|
||||
zenith = cos(zenith) + 0.15 * pow(93.885 - ((zenith * 180.0) / kPI), -1.253);
|
||||
zenith = 1.0 / (zenith + _atm_level_params.y);
|
||||
|
||||
|
||||
sr = zenith * RAYLEIGH_ZENITH_LENGTH;
|
||||
sm = zenith * MIE_ZENITH_LENGTH;
|
||||
}
|
||||
|
|
@ -161,36 +161,33 @@ void opticalDepth(float y, out float sr, out float sm){
|
|||
vec3 atmosphericScattering(float sr, float sm, vec2 mu, vec3 mult){
|
||||
vec3 betaMie = _atm_beta_mie;
|
||||
vec3 betaRay = _atm_beta_ray * _atm_thickness;
|
||||
|
||||
|
||||
vec3 extcFactor = saturateRGB(exp(-(betaRay * sr + betaMie * sm)));
|
||||
|
||||
|
||||
float extcFF = mix(saturate(_atm_thickness * 0.5), 1.0, mult.x);
|
||||
vec3 finalExtcFactor = mix(1.0 - extcFactor, (1.0 - extcFactor) * extcFactor, extcFF);
|
||||
float rayleighPhase = rayleighPhase(mu.x);
|
||||
vec3 BRT = betaRay * rayleighPhase;
|
||||
vec3 BMT = betaMie * miePhase(mu.x, _atm_sun_partial_mie_phase);
|
||||
BMT *= _atm_sun_mie_intensity * _atm_sun_mie_tint.rgb;
|
||||
|
||||
|
||||
vec3 BRMT = (BRT + BMT) / (betaRay + betaMie);
|
||||
vec3 scatter = _atm_sun_intensity * (BRMT * finalExtcFactor) * _atm_day_tint.rgb * mult.y;
|
||||
scatter = mix(scatter, scatter * (1.0 - extcFactor), _atm_darkness);
|
||||
|
||||
|
||||
vec3 lcol = mix(_atm_day_tint.rgb, _atm_horizon_light_tint.rgb, mult.x);
|
||||
vec3 nscatter = (1.0 - extcFactor) * _atm_night_tint.rgb;
|
||||
nscatter += miePhase(mu.y, _atm_moon_partial_mie_phase) *
|
||||
nscatter += miePhase(mu.y, _atm_moon_partial_mie_phase) *
|
||||
_atm_moon_mie_tint.rgb * _atm_moon_mie_intensity * 0.005;
|
||||
|
||||
|
||||
return (scatter * lcol) + nscatter;
|
||||
}
|
||||
|
||||
// Clouds
|
||||
//------------------------------------------------------------------------------
|
||||
float noiseClouds(vec2 coords, vec2 offset){
|
||||
float speed = TIME * _clouds_speed * .5; // .5 matches cumulus clouds
|
||||
vec2 wind = offset * speed;
|
||||
vec2 wind2 = (offset + offset) * speed;
|
||||
float a = textureLod(_clouds_texture, coords.xy * _clouds_uv - wind, 0.0).r;
|
||||
float b = textureLod(_clouds_texture, coords.xy * _clouds_uv - wind2, 0.0).r;
|
||||
float a = textureLod(_clouds_texture, coords.xy * _clouds_uv + offset.x, 0.0).r;
|
||||
float b = textureLod(_clouds_texture, coords.xy * _clouds_uv + offset.y, 0.0).r;
|
||||
return ((a + b) * 0.5);
|
||||
}
|
||||
|
||||
|
|
@ -202,10 +199,11 @@ float cloudsDensity(vec2 p, vec2 offset){
|
|||
return saturate(d);
|
||||
}
|
||||
|
||||
vec4 renderClouds(vec3 pos){
|
||||
vec4 renderClouds(vec3 pos, float tm){
|
||||
pos.xy = pos.xz / pos.y;
|
||||
pos *= _clouds_size;
|
||||
float density = cloudsDensity(pos.xy, _clouds_direction);
|
||||
vec2 wind = _clouds_offset.xy * (tm * _clouds_offset_speed);
|
||||
float density = cloudsDensity(pos.xy, wind);
|
||||
float sh = saturate(exp(-_clouds_absorption * density));
|
||||
float a = saturate(density * _clouds_thickness);
|
||||
return vec4(vec3(density*sh) * _clouds_intensity, a);
|
||||
|
|
@ -222,12 +220,12 @@ void vertex(){
|
|||
vec4 vert = vec4(VERTEX, 0.0);
|
||||
POSITION = PROJECTION_MATRIX * MODELVIEW_MATRIX * vert;
|
||||
POSITION.z = 0.00000001;
|
||||
|
||||
|
||||
world_pos = MODEL_MATRIX * vert;
|
||||
moon_coords.xyz = (_moon_matrix * VERTEX) / _moon_size + 0.5;
|
||||
moon_coords.w = dot(world_pos.xyz, _moon_direction.xyz);
|
||||
deep_space_coords.xyz = (_deep_space_matrix * VERTEX).xyz;
|
||||
|
||||
|
||||
angle_mult.x = saturate(1.0 - _sun_direction.y);
|
||||
angle_mult.y = saturate(_sun_direction.y + 0.45);
|
||||
angle_mult.z = saturate(-_sun_direction.y + 0.30);
|
||||
|
|
@ -238,7 +236,7 @@ void fragment(){
|
|||
vec3 col = vec3(0.0);
|
||||
vec3 worldPos = normalize(world_pos).xyz;
|
||||
vec3 cloudsPos = worldPos;
|
||||
|
||||
|
||||
// Atmosphere
|
||||
vec2 mu = vec2(dot(_sun_direction, worldPos), dot(_moon_direction, worldPos));
|
||||
float sr, sm;
|
||||
|
|
@ -246,16 +244,16 @@ void fragment(){
|
|||
|
||||
worldPos.y += _horizon_level;
|
||||
float horizonBlend = saturate((worldPos.y - 0.03) * 3.0);
|
||||
|
||||
|
||||
vec3 scatter = atmosphericScattering(sr, sm, mu.xy, angle_mult.xyz);
|
||||
col.rgb += scatter.rgb;
|
||||
|
||||
|
||||
// Near Space
|
||||
vec3 nearSpace = vec3(0.0);
|
||||
vec3 sunDisk = disk(worldPos, _sun_direction, _sun_disk_size) *
|
||||
vec3 sunDisk = disk(worldPos, _sun_direction, _sun_disk_size) *
|
||||
_sun_disk_color.rgb * scatter.rgb;
|
||||
sunDisk *= _sun_disk_intensity;
|
||||
|
||||
|
||||
// Moon
|
||||
vec4 moon = texture(_moon_texture, vec2(-moon_coords.x+1.0, moon_coords.y));
|
||||
moon.rgb = contrastLevel(moon.rgb * _moon_color.rgb, _moon_color.a);
|
||||
|
|
@ -263,37 +261,37 @@ void fragment(){
|
|||
float moonMask = saturate(1.0 - moon.a);
|
||||
nearSpace = moon.rgb + (sunDisk.rgb * moonMask);
|
||||
col.rgb += nearSpace;
|
||||
|
||||
|
||||
vec3 deepSpace = vec3(0.0);
|
||||
vec2 deepSpaceUV = equirectUV(normalize(deep_space_coords));
|
||||
|
||||
|
||||
// Background
|
||||
vec3 deepSpaceBackground = textureLod(_background_texture, deepSpaceUV, 0.0).rgb;
|
||||
deepSpaceBackground *= _background_color.rgb;
|
||||
deepSpaceBackground = contrastLevel(deepSpaceBackground, _background_color.a);
|
||||
deepSpace.rgb += deepSpaceBackground.rgb * moonMask;
|
||||
|
||||
|
||||
// Stars Field
|
||||
float starsScintillation = textureLod(_noise_tex, UV + (TIME * _stars_scintillation_speed), 0.0).r;
|
||||
starsScintillation = mix(1.0, starsScintillation * 1.5, _stars_scintillation);
|
||||
|
||||
|
||||
vec3 starsField = textureLod(_stars_field_texture, deepSpaceUV, 0.0).rgb * _stars_field_color.rgb;
|
||||
starsField = saturateRGB(mix(starsField.rgb, starsField.rgb * starsScintillation, _stars_scintillation));
|
||||
//deepSpace.rgb -= saturate(starsField.r*10.0);
|
||||
deepSpace.rgb += starsField.rgb * moonMask;
|
||||
deepSpace.rgb *= angle_mult.z;
|
||||
col.rgb += deepSpace.rgb * horizonBlend;
|
||||
|
||||
|
||||
// Clouds
|
||||
vec4 clouds = renderClouds(cloudsPos);
|
||||
vec4 clouds = renderClouds(cloudsPos, TIME);
|
||||
clouds.a = saturate(clouds.a);
|
||||
clouds.rgb *= mix(mix(_clouds_day_color.rgb, _clouds_horizon_light_color.rgb, angle_mult.x),
|
||||
clouds.rgb *= mix(mix(_clouds_day_color.rgb, _clouds_horizon_light_color.rgb, angle_mult.x),
|
||||
_clouds_night_color.rgb, angle_mult.w);
|
||||
|
||||
|
||||
clouds.a = mix(0.0, clouds.a, horizonBlend);
|
||||
col.rgb = mix(col.rgb, clouds.rgb + mix(vec3(0.0), scatter, _clouds_sky_tint_fade), clouds.a);
|
||||
col.rgb = mix(col.rgb, _ground_color.rgb * scatter, saturate((-worldPos.y - _atm_level_params.z)*100.0));
|
||||
|
||||
|
||||
col.rgb = tonemapPhoto(col.rgb, _color_correction_params.y, _color_correction_params.x);
|
||||
ALBEDO = col.rgb;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://bfkqn51cwum1e
|
||||
uid://dhalpj5qcbhqv
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://bnhhva7vjswff
|
||||
uid://c6rq15l1wbln
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://d12q65vakvuiy
|
||||
uid://gfdyln804ke1
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://dt7ysnnp1ni0s
|
||||
uid://ctqkwsldd7mof
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://belj7tgs6u7yl
|
||||
uid://dp024lqmrvjwu
|
||||
|
|
|
|||
|
|
@ -1,63 +1,69 @@
|
|||
# Copyright (c) 2023-2025 Cory Petkovsek and Contributors
|
||||
# Copyright (c) 2021 J. Cuellar
|
||||
|
||||
## Sky3D is an Atmosphereic Day/Night Cycle for Godot 4.
|
||||
##
|
||||
## It manages time, moving the sun, moon, and stars, and consolidates environmental lighting controls.
|
||||
## To use it, remove any WorldEnvironment node from you scene, then add a new Sky3D node.
|
||||
## Explore and configure the settings in the Sky3D, SunLight, MoonLight, TimeOfDay, and Skydome nodes.
|
||||
|
||||
@tool
|
||||
class_name Sky3D
|
||||
extends WorldEnvironment
|
||||
|
||||
## Emitted when the environment variable has changed.
|
||||
signal environment_changed
|
||||
|
||||
## The Sun DirectionalLight.
|
||||
var sun: DirectionalLight3D
|
||||
## The Moon DirectionalLight.
|
||||
var moon: DirectionalLight3D
|
||||
## The TimeOfDay node.
|
||||
var tod: TimeOfDay
|
||||
## The Skydome node.
|
||||
var sky: Skydome
|
||||
|
||||
|
||||
## Enables all rendering and time tracking.
|
||||
func _enter_tree() -> void:
|
||||
initialize()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Reapply current settings once attached to the tree
|
||||
sky_enabled = sky_enabled
|
||||
lights_enabled = lights_enabled
|
||||
fog_enabled = fog_enabled
|
||||
clouds_enabled = clouds_enabled
|
||||
show_physical_sky = show_physical_sky
|
||||
current_time = current_time
|
||||
|
||||
tod.time_changed.connect(_on_timeofday_updated)
|
||||
|
||||
|
||||
## Visibility
|
||||
|
||||
@export var sky3d_enabled: bool = true : set = set_sky3d_enabled
|
||||
|
||||
@export_group("Visibility")
|
||||
@export var sky_enabled: bool = true : set = set_sky_enabled
|
||||
@export var lights_enabled: bool = true : set = set_lights_enabled
|
||||
@export var fog_enabled: bool = true : set = set_fog_enabled
|
||||
@export var clouds_enabled: bool = true : set = set_clouds_enabled
|
||||
@export var show_physical_sky: bool = false : set = set_show_physical_sky
|
||||
var _default_sun_energy: float
|
||||
var _default_moon_energy: float
|
||||
|
||||
|
||||
func set_sky3d_enabled(value: bool) -> void:
|
||||
sky3d_enabled = value
|
||||
sky_enabled = value
|
||||
fog_enabled = value
|
||||
clouds_enabled = value
|
||||
if value:
|
||||
show_sky()
|
||||
resume()
|
||||
else:
|
||||
hide_sky()
|
||||
pause()
|
||||
|
||||
|
||||
#####################
|
||||
## Visibility
|
||||
#####################
|
||||
|
||||
@export_group("Visibility")
|
||||
|
||||
|
||||
## Enables the sky shader. Disable sky, lights, fog for a black sky or call hide_sky().
|
||||
@export var sky_enabled: bool = true : set = set_sky_enabled
|
||||
|
||||
func set_sky_enabled(value: bool) -> void:
|
||||
sky_enabled = value
|
||||
if not sky:
|
||||
return
|
||||
sky.sky_visible = value
|
||||
sky.clouds_cumulus_visible = clouds_enabled and value
|
||||
sky.clouds_cumulus_visible = value
|
||||
sky.sun_light_energy = _default_sun_energy if value else 0
|
||||
sky.moon_light_energy = _default_moon_energy if value else 0
|
||||
|
||||
|
||||
## Enables the Sun and Moon DirectionalLights.
|
||||
@export var lights_enabled: bool = true : set = set_lights_enabled
|
||||
|
||||
func set_lights_enabled(value: bool) -> void:
|
||||
lights_enabled = value
|
||||
if not sky:
|
||||
|
|
@ -65,342 +71,207 @@ func set_lights_enabled(value: bool) -> void:
|
|||
sky.sun_light_enable = value
|
||||
sky.moon_light_enable = value
|
||||
sky.__sun_light_node.visible = value && sky.__sun_light_node.light_energy > 0
|
||||
sky.__moon_light_node.visible = value && sky.__moon_light_node.light_energy > 0
|
||||
sky.__moon_light_node.visible = ! value && sky.__moon_light_node.light_energy > 0
|
||||
|
||||
|
||||
## Enables the screen space fog shader.
|
||||
@export var fog_enabled: bool = true : set = set_fog_enabled
|
||||
|
||||
func set_fog_enabled(value: bool) -> void:
|
||||
fog_enabled = value
|
||||
if sky:
|
||||
sky.fog_visible = value
|
||||
|
||||
|
||||
## Enables the 2D and cumulus cloud layers.
|
||||
@export var clouds_enabled: bool = true : set = set_clouds_enabled
|
||||
|
||||
func set_clouds_enabled(value: bool) -> void:
|
||||
clouds_enabled = value
|
||||
if not sky:
|
||||
return
|
||||
sky.clouds_cumulus_visible = value
|
||||
sky.clouds_thickness = float(value) * 1.7
|
||||
# TODO should create an on/off in skydome so disabling this doesn't change the enabled value
|
||||
|
||||
|
||||
## Disables rendering of sky, fog, and lights
|
||||
func hide_sky() -> void:
|
||||
sky_enabled = false
|
||||
lights_enabled = false
|
||||
fog_enabled = false
|
||||
func set_show_physical_sky(value: bool) -> void:
|
||||
show_physical_sky = value
|
||||
if not sky:
|
||||
return
|
||||
sky.sky_visible = !value
|
||||
|
||||
|
||||
## Enables rendering of sky, fog, and lights
|
||||
func show_sky() -> void:
|
||||
sky_enabled = true
|
||||
lights_enabled = true
|
||||
fog_enabled = true
|
||||
|
||||
|
||||
#####################
|
||||
## Time
|
||||
#####################
|
||||
|
||||
@export_group("Time")
|
||||
|
||||
|
||||
## Move time forward in the editor.
|
||||
@export var enable_editor_time: bool = true : set = set_editor_time_enabled
|
||||
@export var enable_game_time: bool = true : set = set_game_time_enabled
|
||||
@export_range(0.0, 24.0) var current_time: float = 8.0 : set = set_current_time
|
||||
@export_range(-1440,1440,1) var minutes_per_day: float = 15.0 : set = set_minutes_per_day
|
||||
@export_range(0.016, 10.0) var update_interval: float = 0.1 : set = set_update_interval
|
||||
var _is_day: bool = true
|
||||
|
||||
func set_editor_time_enabled(value: bool) -> void:
|
||||
|
||||
func pause() -> void:
|
||||
$TimeOfDay.pause()
|
||||
|
||||
|
||||
func resume() -> void:
|
||||
$TimeOfDay.resume()
|
||||
|
||||
|
||||
func is_day() -> bool:
|
||||
return _is_day
|
||||
|
||||
|
||||
func is_night() -> bool:
|
||||
return not _is_day
|
||||
|
||||
|
||||
func set_editor_time_enabled(value:bool) -> void:
|
||||
enable_editor_time = value
|
||||
if tod:
|
||||
tod.update_in_editor = value
|
||||
|
||||
|
||||
## Move time forward in game.
|
||||
@export var enable_game_time: bool = true : set = set_game_time_enabled
|
||||
|
||||
func set_game_time_enabled(value: bool) -> void:
|
||||
func set_game_time_enabled(value:bool) -> void:
|
||||
enable_game_time = value
|
||||
if tod:
|
||||
tod.update_in_game = value
|
||||
|
||||
|
||||
## The time right now in hours, 0-23.99. Larger and smaller values will wrap
|
||||
@export_range(0.0, 23.99, .01, "or_greater", "or_less") var current_time: float = 8.0 : set = set_current_time
|
||||
|
||||
func set_current_time(value: float) -> void:
|
||||
func set_current_time(value:float) -> void:
|
||||
current_time = value
|
||||
if tod and tod.total_hours != current_time:
|
||||
tod.total_hours = value
|
||||
|
||||
|
||||
## The length of a full day in real minutes. +/-1440 (24 hours), forward or backwards.
|
||||
@export_range(-1440,1440,.1) var minutes_per_day: float = 15.0 : set = set_minutes_per_day
|
||||
|
||||
func set_minutes_per_day(value):
|
||||
minutes_per_day = value
|
||||
if tod:
|
||||
tod.total_cycle_in_minutes = value
|
||||
|
||||
|
||||
## Frequency of updates. Set to 0.016 for 60fps.
|
||||
@export_range(0.016, 10.0) var update_interval: float = 0.1 : set = set_update_interval
|
||||
|
||||
func set_update_interval(value: float) -> void:
|
||||
func set_update_interval(value:float) -> void:
|
||||
update_interval = value
|
||||
if tod:
|
||||
tod.update_interval = value
|
||||
|
||||
|
||||
## Tracks if the sun is above the horizon.
|
||||
var _is_day: bool = true
|
||||
|
||||
|
||||
## Returns true if the sun is above the horizon.
|
||||
func is_day() -> bool:
|
||||
return _is_day
|
||||
|
||||
|
||||
## Returns true if the sun is below the horizon.
|
||||
func is_night() -> bool:
|
||||
return not _is_day
|
||||
|
||||
|
||||
## Pauses time calculation.
|
||||
func pause() -> void:
|
||||
if tod:
|
||||
tod.pause()
|
||||
|
||||
|
||||
## Resumes time calculation.
|
||||
func resume() -> void:
|
||||
if tod:
|
||||
tod.resume()
|
||||
|
||||
|
||||
func _on_timeofday_updated(time: float) -> void:
|
||||
if tod:
|
||||
if tod and Engine.is_editor_hint():
|
||||
minutes_per_day = tod.total_cycle_in_minutes
|
||||
current_time = tod.total_hours
|
||||
update_interval = tod.update_interval
|
||||
update_day_night()
|
||||
|
||||
if night_ambient:
|
||||
if abs(sky.sun_altitude) > 87 and _is_day:
|
||||
_is_day = false
|
||||
var tween: Tween = get_tree().create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_property(environment, "ambient_light_sky_contribution", minf(night_ambient_min, sky_contribution), 3)
|
||||
tween.tween_property(environment.sky.sky_material, "energy_multiplier", 1., 3)
|
||||
elif abs(sky.sun_altitude) <= 87 and not _is_day:
|
||||
_is_day = true
|
||||
var tween: Tween = get_tree().create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_property(environment, "ambient_light_sky_contribution", sky_contribution, 3)
|
||||
tween.tween_property(environment.sky.sky_material, "energy_multiplier", reflected_energy, 3)
|
||||
|
||||
|
||||
## Recalculates if it's currently day or night. Adjusts night ambient light if changing state or forced.
|
||||
func update_day_night(force: bool = false) -> void:
|
||||
if not (sky and environment):
|
||||
return
|
||||
## Exposure
|
||||
|
||||
# If day transitioning to night
|
||||
if abs(sky.sun_altitude) > 87 and (_is_day or force):
|
||||
_is_day = false
|
||||
var tween: Tween = get_tree().create_tween()
|
||||
tween.set_parallel(true)
|
||||
var contrib: float = minf(night_ambient_min, sky_contribution) if night_ambient else sky_contribution
|
||||
tween.tween_property(environment, "ambient_light_sky_contribution", contrib, ambient_tween_time)
|
||||
tween.tween_property(environment.sky.sky_material, "energy_multiplier", 1., ambient_tween_time)
|
||||
|
||||
# Else if night transitioning to day
|
||||
elif abs(sky.sun_altitude) <= 87 and (not _is_day or force):
|
||||
_is_day = true
|
||||
var tween: Tween = get_tree().create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_property(environment, "ambient_light_sky_contribution", sky_contribution, ambient_tween_time)
|
||||
tween.tween_property(environment.sky.sky_material, "energy_multiplier", reflected_energy, ambient_tween_time)
|
||||
|
||||
|
||||
#####################
|
||||
## Lighting
|
||||
#####################
|
||||
|
||||
@export_group("Lighting")
|
||||
|
||||
|
||||
## Exposure used for the tonemapper. See Evironment.tonemap_exposure
|
||||
@export_range(0,16,.005) var tonemap_exposure: float = 1.0: set = set_tonemap_exposure
|
||||
|
||||
func set_tonemap_exposure(value: float) -> void:
|
||||
if environment:
|
||||
tonemap_exposure = value
|
||||
environment.tonemap_exposure = value
|
||||
|
||||
|
||||
## Strength of skydome and fog.
|
||||
@export_group("Exposure")
|
||||
@export_range(0,1,.005) var sky_contribution: float = 1.0: set = set_sky_contribution
|
||||
@export_range(0,16,.005) var ambient_energy: float = 1.0: set = set_ambient_energy
|
||||
@export var night_ambient: bool = true: set = set_night_ambient
|
||||
@export_range(0,1,.005) var night_ambient_min: float = .7
|
||||
@export_range(0,128,.005) var reflected_energy: float = 1.0: set = set_reflected_energy
|
||||
@export_range(0,16,.005) var skydome_energy: float = 1.3: set = set_skydome_energy
|
||||
|
||||
func set_skydome_energy(value: float) -> void:
|
||||
if sky:
|
||||
skydome_energy = value
|
||||
sky.exposure = value
|
||||
sky.clouds_cumulus_intensity = value * .769 # (1/1.3 default sun energy)
|
||||
|
||||
|
||||
## Exposure of camera connected to Environment.camera_attributes.
|
||||
@export_range(0,16,.005) var tonemap_exposure: float = 1.0: set = set_tonemap_exposure
|
||||
@export_range(0,16,.005) var camera_exposure: float = 1.0: set = set_camera_exposure
|
||||
|
||||
func set_camera_exposure(value: float) -> void:
|
||||
if camera_attributes:
|
||||
camera_exposure = value
|
||||
camera_attributes.exposure_multiplier = value
|
||||
@export_subgroup("Auto Exposure")
|
||||
@export var auto_exposure: bool = false: set = set_auto_exposure_enabled
|
||||
@export_range(0.01,16,.005) var auto_exposure_scale: float = 0.2: set = set_auto_exposure_scale
|
||||
@export_range(0,1600,.5) var auto_exposure_min: float = 0.0: set = set_auto_exposure_min
|
||||
@export_range(30,64000,.5) var auto_exposure_max: float = 800.0: set = set_auto_exposure_max
|
||||
@export_range(0.1,64,.1) var auto_exposure_speed: float = 0.5: set = set_auto_exposure_speed
|
||||
|
||||
|
||||
## Maximum strength of Sun DirectionalLight, visible during the day.
|
||||
@export_range(0,16,.005) var sun_energy: float = 1.0: set = set_sun_energy
|
||||
|
||||
func set_sun_energy(value: float) -> void:
|
||||
sun_energy = value
|
||||
if sky:
|
||||
sky.sun_light_energy = value
|
||||
func set_sky_contribution(value:float) -> void:
|
||||
if environment:
|
||||
sky_contribution = value
|
||||
environment.ambient_light_sky_contribution = value
|
||||
|
||||
|
||||
## Opacity of Sun DirectionalLight shadow.
|
||||
@export_range(0,1,.005) var sun_shadow_opacity: float = 1.0: set = set_sun_shadow_opacity
|
||||
func set_ambient_energy(value:float) -> void:
|
||||
if environment:
|
||||
ambient_energy = value
|
||||
environment.ambient_light_energy = value
|
||||
|
||||
func set_sun_shadow_opacity(value: float) -> void:
|
||||
sun_shadow_opacity = value
|
||||
if sun:
|
||||
sun.shadow_opacity = value
|
||||
|
||||
|
||||
## Strength of refelcted light from the PhysicalSky. See PhysicalSkyMaterial.energy_multiplier
|
||||
@export_range(0,128,.005) var reflected_energy: float = 1.0: set = set_reflected_energy
|
||||
func set_night_ambient(value: bool) -> void:
|
||||
night_ambient = value
|
||||
if night_ambient:
|
||||
_on_timeofday_updated(tod.total_hours)
|
||||
else:
|
||||
set_sky_contribution(sky_contribution)
|
||||
|
||||
func set_reflected_energy(value: float) -> void:
|
||||
|
||||
func set_reflected_energy(value:float) -> void:
|
||||
if environment:
|
||||
reflected_energy = value
|
||||
if environment.sky:
|
||||
environment.sky.sky_material.energy_multiplier = value
|
||||
|
||||
|
||||
## Ratio of ambient light to sky light. See Environment.ambient_light_sky_contribution.
|
||||
@export_range(0,1,.005) var sky_contribution: float = 1.0: set = set_sky_contribution
|
||||
|
||||
func set_sky_contribution(value: float) -> void:
|
||||
func set_skydome_energy(value:float) -> void:
|
||||
if sky:
|
||||
skydome_energy = value
|
||||
sky.exposure = value
|
||||
|
||||
|
||||
func set_tonemap_exposure(value:float) -> void:
|
||||
if environment:
|
||||
sky_contribution = value
|
||||
environment.ambient_light_sky_contribution = value
|
||||
update_day_night(true)
|
||||
tonemap_exposure = value
|
||||
environment.tonemap_exposure = value
|
||||
|
||||
|
||||
## Strength of ambient light. Works outside of Reflection Probe / GI volumes and sky_contribution < 1.
|
||||
## See Environment.ambient_light_energy.
|
||||
@export_range(0,16,.005) var ambient_energy: float = 1.0: set = set_ambient_energy
|
||||
|
||||
func set_ambient_energy(value: float) -> void:
|
||||
if environment:
|
||||
ambient_energy = value
|
||||
environment.ambient_light_energy = value
|
||||
update_day_night(true)
|
||||
func set_camera_exposure(value:float) -> void:
|
||||
if camera_attributes:
|
||||
camera_exposure = value
|
||||
camera_attributes.exposure_multiplier = value
|
||||
|
||||
|
||||
@export_subgroup("Auto Exposure")
|
||||
|
||||
|
||||
## Enables CameraAttributes.auto_exposure_enabled.
|
||||
@export var auto_exposure: bool = false: set = set_auto_exposure_enabled
|
||||
|
||||
func set_auto_exposure_enabled(value: bool) -> void:
|
||||
func set_auto_exposure_enabled(value:bool) -> void:
|
||||
if camera_attributes:
|
||||
auto_exposure = value
|
||||
camera_attributes.auto_exposure_enabled = value
|
||||
|
||||
|
||||
## Sets CameraAttributes.auto_exposure_scale.
|
||||
@export_range(0.01,16,.005) var auto_exposure_scale: float = 0.2: set = set_auto_exposure_scale
|
||||
|
||||
func set_auto_exposure_scale(value: float) -> void:
|
||||
func set_auto_exposure_scale(value:float) -> void:
|
||||
if camera_attributes:
|
||||
auto_exposure_scale = value
|
||||
camera_attributes.auto_exposure_scale = value
|
||||
|
||||
|
||||
## Sets CameraAttributesPractical.auto_exposure_min_sensitivity.
|
||||
@export_range(0,1600,.5) var auto_exposure_min: float = 0.0: set = set_auto_exposure_min
|
||||
|
||||
func set_auto_exposure_min(value: float) -> void:
|
||||
func set_auto_exposure_min(value:float) -> void:
|
||||
if camera_attributes:
|
||||
auto_exposure_min = value
|
||||
camera_attributes.auto_exposure_min_sensitivity = value
|
||||
|
||||
|
||||
## Sets CameraAttributesPractical.auto_exposure_max_sensitivity.
|
||||
@export_range(30,64000,.5) var auto_exposure_max: float = 800.0: set = set_auto_exposure_max
|
||||
|
||||
func set_auto_exposure_max(value: float) -> void:
|
||||
func set_auto_exposure_max(value:float) -> void:
|
||||
if camera_attributes:
|
||||
auto_exposure_max = value
|
||||
camera_attributes.auto_exposure_max_sensitivity = value
|
||||
|
||||
|
||||
## Sets CameraAttributes.auto_exposure_speed.
|
||||
@export_range(0.1,64,.1) var auto_exposure_speed: float = 0.5: set = set_auto_exposure_speed
|
||||
|
||||
func set_auto_exposure_speed(value: float) -> void:
|
||||
func set_auto_exposure_speed(value:float) -> void:
|
||||
if camera_attributes:
|
||||
auto_exposure_speed = value
|
||||
camera_attributes.auto_exposure_speed = value
|
||||
|
||||
|
||||
@export_subgroup("Night")
|
||||
|
||||
|
||||
## Maximum strength of Moon DirectionalLight, visible at night.
|
||||
@export_range(0,16,.005) var moon_energy: float = .3: set = set_moon_energy
|
||||
|
||||
func set_moon_energy(value: float) -> void:
|
||||
moon_energy = value
|
||||
if moon:
|
||||
sky.moon_light_energy = value
|
||||
|
||||
|
||||
## Opacity of Moon DirectionalLight shadow.
|
||||
@export_range(0,1,.005) var moon_shadow_opacity: float = 1.0: set = set_moon_shadow_opacity
|
||||
|
||||
func set_moon_shadow_opacity(value: float) -> void:
|
||||
moon_shadow_opacity = value
|
||||
if moon:
|
||||
moon.shadow_opacity = value
|
||||
|
||||
|
||||
## Enables a different ambient light setting at night.
|
||||
@export var night_ambient: bool = true: set = set_night_ambient
|
||||
|
||||
func set_night_ambient(value: bool) -> void:
|
||||
night_ambient = value
|
||||
update_day_night(true)
|
||||
|
||||
|
||||
## Strength of ambient light at night. Sky_contribution must be < 1. See Environment.ambient_light_energy.
|
||||
@export_range(0,1,.005) var night_ambient_min: float = .7: set = set_night_ambient_min
|
||||
|
||||
func set_night_ambient_min(value: float) -> void:
|
||||
night_ambient_min = value
|
||||
if night_ambient:
|
||||
update_day_night(true)
|
||||
|
||||
|
||||
## Transition time for ambient light change, typically transitioning between day and night.
|
||||
@export_range(0,30,.05) var ambient_tween_time: float = 3.: set = set_ambient_tween_time
|
||||
|
||||
func set_ambient_tween_time(value: float) -> void:
|
||||
ambient_tween_time = value
|
||||
|
||||
|
||||
#####################
|
||||
## Setup
|
||||
#####################
|
||||
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
# Must be after _init and before _enter_tree to properly set vars like 'sky' for setters
|
||||
if what in [ NOTIFICATION_SCENE_INSTANTIATED, NOTIFICATION_ENTER_TREE ]:
|
||||
_initialize()
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
func initialize() -> void:
|
||||
# Create default environment
|
||||
if environment == null:
|
||||
environment = Environment.new()
|
||||
|
|
@ -415,35 +286,37 @@ func _initialize() -> void:
|
|||
environment.tonemap_mode = Environment.TONE_MAPPER_ACES
|
||||
environment.tonemap_white = 6
|
||||
emit_signal("environment_changed", environment)
|
||||
|
||||
|
||||
# Create default camera attributes
|
||||
if camera_attributes == null:
|
||||
camera_attributes = CameraAttributesPractical.new()
|
||||
|
||||
# Assign children nodes
|
||||
|
||||
if has_node("SunLight"):
|
||||
# Create children nodes
|
||||
if get_child_count() > 0:
|
||||
tod = $TimeOfDay
|
||||
sky = $Skydome
|
||||
sky.environment = environment
|
||||
sun = $SunLight
|
||||
elif is_inside_tree():
|
||||
moon = $MoonLight
|
||||
else:
|
||||
sun = DirectionalLight3D.new()
|
||||
sun.name = "SunLight"
|
||||
add_child(sun, true)
|
||||
sun.owner = get_tree().edited_scene_root
|
||||
sun.shadow_enabled = true
|
||||
|
||||
if has_node("MoonLight"):
|
||||
moon = $MoonLight
|
||||
elif is_inside_tree():
|
||||
|
||||
moon = DirectionalLight3D.new()
|
||||
moon.name = "MoonLight"
|
||||
add_child(moon, true)
|
||||
moon.owner = get_tree().edited_scene_root
|
||||
moon.shadow_enabled = true
|
||||
|
||||
if has_node("Skydome"):
|
||||
sky = $Skydome
|
||||
sky.environment = environment
|
||||
elif is_inside_tree():
|
||||
tod = TimeOfDay.new()
|
||||
tod.name = "TimeOfDay"
|
||||
add_child(tod, true)
|
||||
tod.owner = get_tree().edited_scene_root
|
||||
tod.dome_path = "../Skydome"
|
||||
|
||||
sky = Skydome.new()
|
||||
sky.name = "Skydome"
|
||||
add_child(sky, true)
|
||||
|
|
@ -452,20 +325,8 @@ func _initialize() -> void:
|
|||
sky.moon_light_path = "../MoonLight"
|
||||
sky.environment = environment
|
||||
|
||||
if has_node("TimeOfDay"):
|
||||
tod = $TimeOfDay
|
||||
elif is_inside_tree():
|
||||
tod = TimeOfDay.new()
|
||||
tod.name = "TimeOfDay"
|
||||
add_child(tod, true)
|
||||
tod.owner = get_tree().edited_scene_root
|
||||
tod.dome_path = "../Skydome"
|
||||
if tod and not tod.time_changed.is_connected(_on_timeofday_updated):
|
||||
tod.time_changed.connect(_on_timeofday_updated)
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
update_day_night(true)
|
||||
_default_sun_energy = $Skydome.sun_light_energy
|
||||
_default_moon_energy = $Skydome.moon_light_energy
|
||||
|
||||
|
||||
func _set(property: StringName, value: Variant) -> bool:
|
||||
|
|
@ -478,9 +339,7 @@ func _set(property: StringName, value: Variant) -> bool:
|
|||
return false
|
||||
|
||||
|
||||
#####################
|
||||
## Constants
|
||||
#####################
|
||||
|
||||
# Node names
|
||||
const SKY_INSTANCE:= "_SkyMeshI"
|
||||
|
|
@ -507,6 +366,7 @@ const _clouds_texture: Texture2D = preload("res://addons/sky_3d/assets/resources
|
|||
const _clouds_cumulus_texture: Texture2D = preload("res://addons/sky_3d/assets/textures/noiseClouds.png")
|
||||
|
||||
# Skydome
|
||||
const MAX_EXTRA_CULL_MARGIN: float = 16384.0
|
||||
const DEFAULT_POSITION:= Vector3(0.0000001, 0.0000001, 0.0000001)
|
||||
|
||||
# Coords
|
||||
|
|
@ -576,8 +436,8 @@ const CLOUDS_SIZE:= "_clouds_size"
|
|||
const CLOUDS_NOISE_FREQ:= "_clouds_noise_freq"
|
||||
|
||||
const CLOUDS_UV:= "_clouds_uv"
|
||||
const CLOUDS_DIRECTION:= "_clouds_direction"
|
||||
const CLOUDS_SPEED:= "_clouds_speed"
|
||||
const CLOUDS_OFFSET:= "_clouds_offset"
|
||||
const CLOUDS_OFFSET_SPEED:= "_clouds_offset_speed"
|
||||
const CLOUDS_TEXTURE:= "_clouds_texture"
|
||||
|
||||
const CLOUDS_DAY_COLOR:= "_clouds_day_color"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://dwixjbv25mxyj
|
||||
uid://f17ekdbdmfty
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ var moon_render: Node
|
|||
var clouds_cumulus_mesh: MeshInstance3D
|
||||
var fog_mesh: MeshInstance3D
|
||||
|
||||
@export var sky_material: Material
|
||||
var sky_material: Material
|
||||
var moon_material: Material
|
||||
var clouds_cumulus_material: Material
|
||||
var fog_material: Material
|
||||
|
|
@ -39,7 +39,7 @@ var fog_material: Material
|
|||
func _ready() -> void:
|
||||
build_scene()
|
||||
|
||||
# Update properties
|
||||
# Update properties
|
||||
# General
|
||||
update_sky_visible()
|
||||
update_dome_radius()
|
||||
|
|
@ -48,11 +48,11 @@ func _ready() -> void:
|
|||
update_sky_layers()
|
||||
update_sky_render_priority()
|
||||
update_horizon_level()
|
||||
|
||||
|
||||
# Coords
|
||||
update_sun_coords()
|
||||
update_moon_coords()
|
||||
|
||||
|
||||
# Atmosphere
|
||||
update_atm_quality()
|
||||
update_beta_ray()
|
||||
|
|
@ -70,7 +70,7 @@ func _ready() -> void:
|
|||
update_atm_moon_mie_tint()
|
||||
update_atm_moon_mie_intensity()
|
||||
update_atm_moon_mie_anisotropy()
|
||||
|
||||
|
||||
# Fog
|
||||
update_fog_visible()
|
||||
update_fog_atm_level_params_offset()
|
||||
|
|
@ -82,7 +82,7 @@ func _ready() -> void:
|
|||
update_fog_falloff()
|
||||
update_fog_layers()
|
||||
update_fog_render_priority()
|
||||
|
||||
|
||||
# Near space
|
||||
update_sun_light_path()
|
||||
update_sun_disk_color()
|
||||
|
|
@ -100,7 +100,7 @@ func _ready() -> void:
|
|||
update_sun_light_energy()
|
||||
update_moon_light_color()
|
||||
update_moon_light_energy()
|
||||
|
||||
|
||||
# Deep space
|
||||
update_deep_space_basis()
|
||||
set_set_background_texture(set_background_texture)
|
||||
|
|
@ -111,7 +111,7 @@ func _ready() -> void:
|
|||
update_stars_field_texture()
|
||||
update_stars_scintillation()
|
||||
update_stars_scintillation_speed()
|
||||
|
||||
|
||||
# Clouds
|
||||
update_clouds_thickness()
|
||||
update_clouds_coverage()
|
||||
|
|
@ -120,11 +120,11 @@ func _ready() -> void:
|
|||
update_clouds_intensity()
|
||||
update_clouds_size()
|
||||
update_clouds_uv()
|
||||
update_clouds_direction()
|
||||
update_clouds_speed()
|
||||
update_clouds_offset()
|
||||
update_clouds_offset_speed()
|
||||
set_set_clouds_texture(set_clouds_texture)
|
||||
update_clouds_texture()
|
||||
|
||||
|
||||
# Clouds cumulus
|
||||
update_clouds_cumulus_visible()
|
||||
update_clouds_cumulus_day_color()
|
||||
|
|
@ -138,11 +138,11 @@ func _ready() -> void:
|
|||
update_clouds_cumulus_mie_intensity()
|
||||
update_clouds_cumulus_mie_anisotropy()
|
||||
update_clouds_cumulus_size()
|
||||
update_clouds_cumulus_direction()
|
||||
update_clouds_cumulus_speed()
|
||||
update_clouds_cumulus_offset()
|
||||
update_clouds_cumulus_offset_speed()
|
||||
set_set_clouds_cumulus_texture(set_clouds_cumulus_texture)
|
||||
update_clouds_cumulus_texture()
|
||||
|
||||
|
||||
# Environment
|
||||
__update_environment()
|
||||
|
||||
|
|
@ -162,14 +162,14 @@ func build_scene() -> void:
|
|||
sky_mesh.material_override = sky_material
|
||||
__setup_mesh_instance(sky_mesh, Sky3D.DEFAULT_POSITION)
|
||||
add_child(sky_mesh)
|
||||
|
||||
|
||||
# Moon Render
|
||||
moon_render = Sky3D._moon_render.instantiate()
|
||||
moon_render.name = Sky3D.MOON_INSTANCE
|
||||
var moon_mesh = moon_render.get_node("MoonTransform/Camera3D/Mesh") as MeshInstance3D
|
||||
moon_material = moon_mesh.material_override
|
||||
add_child(moon_render)
|
||||
|
||||
|
||||
# Clouds Cumulus Mesh
|
||||
clouds_cumulus_mesh = MeshInstance3D.new()
|
||||
clouds_cumulus_mesh.name = Sky3D.CLOUDS_C_INSTANCE
|
||||
|
|
@ -182,7 +182,7 @@ func build_scene() -> void:
|
|||
clouds_cumulus_mesh.material_override = clouds_cumulus_material
|
||||
__setup_mesh_instance(clouds_cumulus_mesh, Sky3D.DEFAULT_POSITION)
|
||||
add_child(clouds_cumulus_mesh)
|
||||
|
||||
|
||||
fog_mesh = MeshInstance3D.new()
|
||||
fog_mesh.name = Sky3D.FOG_INSTANCE
|
||||
var fog_screen_quad = QuadMesh.new()
|
||||
|
|
@ -199,12 +199,12 @@ func build_scene() -> void:
|
|||
add_child(fog_mesh)
|
||||
|
||||
is_scene_built = true
|
||||
|
||||
|
||||
|
||||
func __setup_mesh_instance(target: MeshInstance3D, origin: Vector3) -> void:
|
||||
target.transform.origin = origin
|
||||
target.extra_cull_margin = Sky3D.MAX_EXTRA_CULL_MARGIN
|
||||
target.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
target.custom_aabb = AABB(Vector3(-1e31, -1e31, -1e31), Vector3(2e31, 2e31, 2e31))
|
||||
|
||||
|
||||
#####################
|
||||
|
|
@ -220,14 +220,14 @@ var sky_layers: int = 4: set = set_sky_layers
|
|||
var sky_render_priority: int = -128: set = set_sky_render_priority
|
||||
var horizon_level: float = 0.0: set = set_horizon_level
|
||||
|
||||
|
||||
|
||||
func set_sky_visible(value: bool) -> void:
|
||||
if value == sky_visible:
|
||||
return
|
||||
sky_visible = value
|
||||
sky_visible = value
|
||||
update_sky_visible()
|
||||
|
||||
|
||||
|
||||
func update_sky_visible() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -239,14 +239,14 @@ func set_dome_radius(value: float) -> void:
|
|||
return
|
||||
dome_radius = value
|
||||
update_dome_radius()
|
||||
|
||||
|
||||
|
||||
func update_dome_radius() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
sky_mesh.scale = dome_radius * Vector3.ONE
|
||||
clouds_cumulus_mesh.scale = dome_radius * Vector3.ONE
|
||||
|
||||
|
||||
|
||||
func set_tonemap_level(value: float) -> void:
|
||||
if value == tonemap_level:
|
||||
|
|
@ -254,14 +254,14 @@ func set_tonemap_level(value: float) -> void:
|
|||
tonemap_level = value
|
||||
update_color_correction_params()
|
||||
|
||||
|
||||
|
||||
func set_exposure(value: float) -> void:
|
||||
if value == exposure:
|
||||
return
|
||||
exposure = value
|
||||
update_color_correction_params()
|
||||
|
||||
|
||||
|
||||
|
||||
func update_color_correction_params() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -284,7 +284,7 @@ func update_ground_color() -> void:
|
|||
if !is_scene_built:
|
||||
return
|
||||
sky_material.set_shader_parameter(Sky3D.GROUND_COLOR_P, ground_color)
|
||||
|
||||
|
||||
|
||||
func set_sky_layers(value: int) -> void:
|
||||
if sky_layers == value:
|
||||
|
|
@ -298,21 +298,21 @@ func update_sky_layers() -> void:
|
|||
return
|
||||
sky_mesh.layers = sky_layers
|
||||
clouds_cumulus_mesh.layers = sky_layers
|
||||
|
||||
|
||||
|
||||
func set_sky_render_priority(value: int) -> void:
|
||||
if value == sky_render_priority:
|
||||
return
|
||||
sky_render_priority = value
|
||||
update_sky_render_priority()
|
||||
|
||||
|
||||
|
||||
func update_sky_render_priority() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
sky_material.render_priority = sky_render_priority
|
||||
clouds_cumulus_material.render_priority = sky_render_priority + 1
|
||||
|
||||
|
||||
|
||||
func set_horizon_level(value: float) -> void:
|
||||
if value == horizon_level:
|
||||
|
|
@ -342,7 +342,7 @@ func set_sun_azimuth(value: float) -> void:
|
|||
return
|
||||
sun_azimuth = value
|
||||
update_sun_coords()
|
||||
|
||||
|
||||
|
||||
func set_sun_altitude(value: float) -> void:
|
||||
if value == sun_altitude:
|
||||
|
|
@ -362,32 +362,32 @@ func sun_direction() -> Vector3:
|
|||
func update_sun_coords() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
||||
|
||||
var azimuth: float = sun_azimuth * TOD_Math.DEG_TO_RAD
|
||||
var altitude: float = sun_altitude * TOD_Math.DEG_TO_RAD
|
||||
|
||||
|
||||
__finish_set_sun_pos = false
|
||||
if not __finish_set_sun_pos:
|
||||
__sun_transform.origin = TOD_Math.to_orbit(altitude, azimuth)
|
||||
__finish_set_sun_pos = true
|
||||
|
||||
|
||||
if __finish_set_sun_pos:
|
||||
__sun_transform = __sun_transform.looking_at(Sky3D.DEFAULT_POSITION, Vector3.LEFT)
|
||||
|
||||
|
||||
__set_day_state(altitude)
|
||||
emit_signal("sun_transform_changed", __sun_transform)
|
||||
emit_signal("sun_transform_changed", sun_direction())
|
||||
|
||||
|
||||
sky_material.set_shader_parameter(Sky3D.SUN_DIR_P, sun_direction())
|
||||
fog_material.set_shader_parameter(Sky3D.SUN_DIR_P, sun_direction())
|
||||
moon_material.set_shader_parameter(Sky3D.SUN_DIR_P, sun_direction())
|
||||
clouds_cumulus_material.set_shader_parameter(Sky3D.SUN_DIR_P, sun_direction())
|
||||
|
||||
|
||||
if __sun_light_node != null:
|
||||
#if __sun_light_node.light_energy > 0.0 && (abs(sun_altitude) < 90.0
|
||||
if __sun_light_node.light_energy > 0.0:
|
||||
__sun_light_node.transform = __sun_transform
|
||||
|
||||
|
||||
update_night_intensity()
|
||||
update_sun_light_color()
|
||||
update_sun_light_energy()
|
||||
|
|
@ -410,14 +410,14 @@ func set_moon_azimuth(value: float) -> void:
|
|||
return
|
||||
moon_azimuth = value
|
||||
update_moon_coords()
|
||||
|
||||
|
||||
|
||||
func set_moon_altitude(value: float) -> void:
|
||||
if value == moon_altitude:
|
||||
return
|
||||
moon_altitude = value
|
||||
update_moon_coords()
|
||||
|
||||
|
||||
|
||||
func get_moon_transform() -> Transform3D:
|
||||
return __moon_transform
|
||||
|
|
@ -430,37 +430,37 @@ func moon_direction() -> Vector3:
|
|||
func update_moon_coords() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
||||
|
||||
var azimuth: float = moon_azimuth * TOD_Math.DEG_TO_RAD
|
||||
var altitude: float = moon_altitude * TOD_Math.DEG_TO_RAD
|
||||
|
||||
|
||||
__finish_set_moon_pos = false
|
||||
if not __finish_set_moon_pos:
|
||||
__moon_transform.origin = TOD_Math.to_orbit(altitude, azimuth)
|
||||
__finish_set_moon_pos = true
|
||||
|
||||
|
||||
if __finish_set_moon_pos:
|
||||
__moon_transform = __moon_transform.looking_at(Sky3D.DEFAULT_POSITION, Vector3.LEFT)
|
||||
|
||||
|
||||
emit_signal("moon_transform_changed", __moon_transform)
|
||||
emit_signal("moon_direction_changed", moon_direction())
|
||||
|
||||
|
||||
sky_material.set_shader_parameter(Sky3D.MOON_DIR_P, moon_direction())
|
||||
fog_material.set_shader_parameter(Sky3D.MOON_DIR_P, moon_direction())
|
||||
moon_material.set_shader_parameter(Sky3D.MOON_DIR_P, moon_direction())
|
||||
clouds_cumulus_material.set_shader_parameter(Sky3D.MOON_DIR_P, moon_direction())
|
||||
sky_material.set_shader_parameter(Sky3D.MOON_MATRIX, __moon_transform.basis.inverse())
|
||||
|
||||
|
||||
var moon_instance_transform = moon_render.get_node("MoonTransform") as Node3D
|
||||
moon_instance_transform.transform = __moon_transform
|
||||
|
||||
|
||||
if __moon_light_node != null:
|
||||
#if __moon_light_node.light_energy > 0.0 && (abs(moon_altitude) < 90.0):
|
||||
if __moon_light_node.light_energy > 0.0:
|
||||
__moon_light_node.transform = __moon_transform
|
||||
|
||||
|
||||
__moon_light_altitude_mult = TOD_Math.saturate(moon_direction().y)
|
||||
|
||||
|
||||
update_night_intensity()
|
||||
set_moon_light_color(moon_light_color)
|
||||
update_moon_light_energy()
|
||||
|
|
@ -516,7 +516,7 @@ func set_atm_wavelenghts(value : Vector3) -> void:
|
|||
return
|
||||
atm_wavelenghts = value
|
||||
update_beta_ray()
|
||||
|
||||
|
||||
|
||||
func update_beta_ray() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -528,14 +528,14 @@ func update_beta_ray() -> void:
|
|||
sky_material.set_shader_parameter(Sky3D.ATM_BETA_RAY_P, betaRay)
|
||||
fog_material.set_shader_parameter(Sky3D.ATM_BETA_RAY_P, betaRay)
|
||||
|
||||
|
||||
|
||||
func set_atm_darkness(value: float) -> void:
|
||||
if value == atm_darkness:
|
||||
return
|
||||
atm_darkness = value
|
||||
update_atm_darkness()
|
||||
|
||||
|
||||
|
||||
func update_atm_darkness() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -549,7 +549,7 @@ func set_atm_sun_intensity(value: float) -> void:
|
|||
atm_sun_intensity = value
|
||||
update_atm_sun_intensity()
|
||||
|
||||
|
||||
|
||||
func update_atm_sun_intensity() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -563,7 +563,7 @@ func set_atm_day_tint(value: Color) -> void:
|
|||
atm_day_tint = value
|
||||
update_atm_day_tint()
|
||||
|
||||
|
||||
|
||||
func update_atm_day_tint() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -606,7 +606,7 @@ func update_night_intensity() -> void:
|
|||
var tint: Color = atm_night_tint * atm_night_intensity()
|
||||
sky_material.set_shader_parameter(Sky3D.ATM_NIGHT_TINT_P, tint)
|
||||
fog_material.set_shader_parameter(Sky3D.ATM_NIGHT_TINT_P, atm_night_tint * fog_atm_night_intensity())
|
||||
|
||||
|
||||
set_atm_moon_mie_intensity(atm_moon_mie_intensity)
|
||||
|
||||
|
||||
|
|
@ -616,7 +616,7 @@ func set_atm_level_params(value: Vector3) -> void:
|
|||
atm_level_params = value
|
||||
update_atm_level_params()
|
||||
|
||||
|
||||
|
||||
func update_atm_level_params() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -696,7 +696,7 @@ func set_atm_sun_mie_anisotropy(value: float) -> void:
|
|||
atm_sun_mie_anisotropy = value
|
||||
update_atm_sun_mie_anisotropy()
|
||||
|
||||
|
||||
|
||||
func update_atm_sun_mie_anisotropy() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -711,7 +711,7 @@ func set_atm_moon_mie_tint(value: Color) -> void:
|
|||
atm_moon_mie_tint = value
|
||||
update_atm_moon_mie_tint()
|
||||
|
||||
|
||||
|
||||
func update_atm_moon_mie_tint() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -726,7 +726,7 @@ func set_atm_moon_mie_intensity(value: float) -> void:
|
|||
atm_moon_mie_intensity = value
|
||||
update_atm_sun_mie_intensity()
|
||||
|
||||
|
||||
|
||||
func update_atm_moon_mie_intensity() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -739,7 +739,7 @@ func set_atm_moon_mie_anisotropy(value: float) -> void:
|
|||
return
|
||||
atm_moon_mie_anisotropy = value
|
||||
update_atm_moon_mie_anisotropy()
|
||||
|
||||
|
||||
|
||||
func update_atm_moon_mie_anisotropy() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -795,13 +795,13 @@ func update_fog_visible() -> void:
|
|||
return
|
||||
fog_mesh.visible = fog_visible
|
||||
|
||||
|
||||
|
||||
func set_fog_atm_level_params_offset(value: Vector3) -> void:
|
||||
if value == fog_atm_level_params_offset:
|
||||
return
|
||||
fog_atm_level_params_offset = value
|
||||
update_fog_atm_level_params_offset()
|
||||
|
||||
|
||||
|
||||
func update_fog_atm_level_params_offset() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -814,7 +814,7 @@ func set_fog_density(value: float) -> void:
|
|||
return
|
||||
fog_density = value
|
||||
update_fog_density()
|
||||
|
||||
|
||||
|
||||
func update_fog_density() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -833,14 +833,14 @@ func update_fog_start() -> void:
|
|||
if !is_scene_built:
|
||||
return
|
||||
fog_material.set_shader_parameter(Sky3D.ATM_FOG_START, fog_start)
|
||||
|
||||
|
||||
|
||||
func set_fog_end(value: float) -> void:
|
||||
if value == fog_end:
|
||||
return
|
||||
fog_end = value
|
||||
update_fog_end()
|
||||
|
||||
|
||||
|
||||
func update_fog_end() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -853,7 +853,7 @@ func set_fog_rayleigh_depth(value: float) -> void:
|
|||
return
|
||||
fog_rayleigh_depth = value
|
||||
update_fog_rayleigh_depth()
|
||||
|
||||
|
||||
|
||||
func update_fog_rayleigh_depth() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -866,7 +866,7 @@ func set_fog_mie_depth(value: float) -> void:
|
|||
return
|
||||
fog_mie_depth = value
|
||||
update_fog_mie_depth()
|
||||
|
||||
|
||||
|
||||
func update_fog_mie_depth() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -879,7 +879,7 @@ func set_fog_falloff(value: float) -> void:
|
|||
return
|
||||
fog_falloff = value
|
||||
update_fog_falloff()
|
||||
|
||||
|
||||
|
||||
func update_fog_falloff() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -892,7 +892,7 @@ func set_fog_layers(value: int) -> void:
|
|||
return
|
||||
fog_layers = value
|
||||
update_fog_layers()
|
||||
|
||||
|
||||
|
||||
func update_fog_layers() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -905,7 +905,7 @@ func set_fog_render_priority(value: int) -> void:
|
|||
return
|
||||
fog_render_priority = value
|
||||
update_fog_render_priority()
|
||||
|
||||
|
||||
|
||||
func update_fog_render_priority() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -932,7 +932,7 @@ func set_sun_disk_color(value: Color) -> void:
|
|||
return
|
||||
sun_disk_color = value
|
||||
update_sun_disk_color()
|
||||
|
||||
|
||||
|
||||
func update_sun_disk_color() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -945,7 +945,7 @@ func set_sun_disk_intensity(value: float) -> void:
|
|||
return
|
||||
sun_disk_intensity = value
|
||||
update_sun_disk_intensity()
|
||||
|
||||
|
||||
|
||||
func update_sun_disk_intensity() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -958,7 +958,7 @@ func set_sun_disk_size(value: float) -> void:
|
|||
return
|
||||
sun_disk_size = value
|
||||
update_sun_disk_size()
|
||||
|
||||
|
||||
|
||||
func update_sun_disk_size() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -971,7 +971,7 @@ func set_moon_color(value: Color) -> void:
|
|||
return
|
||||
moon_color = value
|
||||
update_moon_color()
|
||||
|
||||
|
||||
|
||||
func update_moon_color() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -984,8 +984,8 @@ func set_moon_size(value: float) -> void:
|
|||
return
|
||||
moon_size = value
|
||||
update_moon_size()
|
||||
|
||||
|
||||
|
||||
|
||||
func update_moon_size() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
|
|
@ -997,14 +997,14 @@ func set_enable_set_moon_texture(value: bool) -> void:
|
|||
if not value:
|
||||
set_moon_texture(Sky3D._moon_texture)
|
||||
notify_property_list_changed()
|
||||
|
||||
|
||||
|
||||
func set_moon_texture(value: Texture2D) -> void:
|
||||
if value == moon_texture:
|
||||
return
|
||||
moon_texture = value
|
||||
update_moon_texture()
|
||||
|
||||
|
||||
|
||||
func update_moon_texture() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1030,7 +1030,7 @@ func update_moon_resolution() -> void:
|
|||
MoonResolution.R1024: moon_render.size = Vector2.ONE * 1024
|
||||
sky_material.set_shader_parameter(Sky3D.MOON_TEXTURE_P, moon_render.get_texture())
|
||||
|
||||
|
||||
|
||||
#####################
|
||||
## Sun
|
||||
#####################
|
||||
|
|
@ -1039,7 +1039,7 @@ func update_moon_resolution() -> void:
|
|||
# Original sun horizon (1.0, 0.384314, 0.243137, 1.0)
|
||||
|
||||
@export var sun_light_enable: bool = true
|
||||
var sun_light_color:= Color.WHITE : set = set_sun_light_color
|
||||
var sun_light_color:= Color.WHITE : set = set_sun_light_color
|
||||
var sun_horizon_light_color:= Color(.98, 0.523, 0.294, 1.0): set = set_sun_horizon_light_color
|
||||
var sun_light_energy: float = 1.0: set = set_sun_light_energy
|
||||
var __sun_light_node: DirectionalLight3D = null
|
||||
|
|
@ -1051,7 +1051,7 @@ func set_sun_light_color(value: Color) -> void:
|
|||
return
|
||||
sun_light_color = value
|
||||
update_sun_light_color()
|
||||
|
||||
|
||||
|
||||
func update_sun_light_color() -> void:
|
||||
if __sun_light_node == null:
|
||||
|
|
@ -1065,14 +1065,14 @@ func set_sun_horizon_light_color(value: Color) -> void:
|
|||
return
|
||||
sun_horizon_light_color = value
|
||||
update_sun_light_color()
|
||||
|
||||
|
||||
|
||||
func set_sun_light_energy(value: float) -> void:
|
||||
if value == sun_light_energy:
|
||||
return
|
||||
sun_light_energy = value
|
||||
update_sun_light_energy()
|
||||
|
||||
|
||||
|
||||
func update_sun_light_energy() -> void:
|
||||
if __sun_light_node != null:
|
||||
|
|
@ -1087,7 +1087,7 @@ func set_sun_light_path(value: NodePath) -> void:
|
|||
update_sun_light_path()
|
||||
update_sun_coords()
|
||||
|
||||
|
||||
|
||||
func update_sun_light_path() -> void:
|
||||
if sun_light_path != null:
|
||||
__sun_light_node = get_node_or_null(sun_light_path) as DirectionalLight3D
|
||||
|
|
@ -1112,13 +1112,13 @@ func set_moon_light_color(value: Color) -> void:
|
|||
return
|
||||
moon_light_color = value
|
||||
update_moon_light_color()
|
||||
|
||||
|
||||
|
||||
func update_moon_light_color() -> void:
|
||||
if __moon_light_node == null:
|
||||
return
|
||||
__moon_light_node.light_color = moon_light_color
|
||||
|
||||
|
||||
|
||||
func set_moon_light_energy(value: float) -> void:
|
||||
moon_light_energy = value
|
||||
|
|
@ -1128,10 +1128,10 @@ func set_moon_light_energy(value: float) -> void:
|
|||
func update_moon_light_energy() -> void:
|
||||
if __moon_light_node == null:
|
||||
return
|
||||
|
||||
|
||||
var l: float = TOD_Math.lerp_f(0.0, moon_light_energy, __moon_light_altitude_mult)
|
||||
l*= atm_moon_phases_mult()
|
||||
|
||||
|
||||
var fade = (1.0 - sun_direction().y) * 0.5
|
||||
__moon_light_node.light_energy = l * Sky3D._sun_moon_curve_fade.sample_baked(fade)
|
||||
|
||||
|
|
@ -1207,7 +1207,7 @@ func set_set_background_texture(value: bool) -> void:
|
|||
if not value:
|
||||
_set_background_texture(Sky3D._background_texture)
|
||||
notify_property_list_changed()
|
||||
|
||||
|
||||
|
||||
func update_background_texture() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1220,7 +1220,7 @@ func _set_background_texture(value: Texture2D) -> void:
|
|||
return
|
||||
background_texture = value
|
||||
update_background_texture()
|
||||
|
||||
|
||||
|
||||
func update_stars_field_color() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1233,14 +1233,14 @@ func set_stars_field_color(value: Color) -> void:
|
|||
return
|
||||
stars_field_color = value
|
||||
update_stars_field_color()
|
||||
|
||||
|
||||
|
||||
func set_set_stars_field_texture(value: bool) -> void:
|
||||
set_stars_field_texture = value
|
||||
if not value:
|
||||
_set_stars_field_texture(Sky3D._stars_field_texture)
|
||||
notify_property_list_changed()
|
||||
|
||||
|
||||
|
||||
func update_stars_field_texture() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1295,8 +1295,8 @@ var clouds_sky_tint_fade: float = 0.5: set = set_clouds_sky_tint_fade
|
|||
var clouds_intensity: float = 10.0: set = set_clouds_intensity
|
||||
var clouds_size: float = 2.0: set = set_clouds_size
|
||||
var clouds_uv:= Vector2(0.16, 0.11): set = set_clouds_uv
|
||||
var clouds_direction:= Vector2(0.25, 0.25): set = set_clouds_direction
|
||||
var clouds_speed: float = 0.07: set = set_clouds_speed
|
||||
var clouds_offset:= Vector2(0.21, 0.175): set = set_clouds_offset
|
||||
var clouds_offset_speed: float = 0.01: set = set_clouds_offset_speed
|
||||
var set_clouds_texture: bool = false: set = set_set_clouds_texture
|
||||
var clouds_texture: Texture2D = null: set = _set_clouds_texture
|
||||
|
||||
|
|
@ -1358,7 +1358,7 @@ func set_clouds_intensity(value: float) -> void:
|
|||
return
|
||||
clouds_intensity = value
|
||||
update_clouds_intensity()
|
||||
|
||||
|
||||
|
||||
func update_clouds_intensity() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1371,7 +1371,7 @@ func set_clouds_size(value: float) -> void:
|
|||
return
|
||||
clouds_size = value
|
||||
update_clouds_size()
|
||||
|
||||
|
||||
|
||||
func update_clouds_size() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1392,30 +1392,30 @@ func update_clouds_uv() -> void:
|
|||
sky_material.set_shader_parameter(Sky3D.CLOUDS_UV, clouds_uv)
|
||||
|
||||
|
||||
func set_clouds_direction(value: Vector2) -> void:
|
||||
if value == clouds_direction:
|
||||
func set_clouds_offset(value: Vector2) -> void:
|
||||
if value == clouds_offset:
|
||||
return
|
||||
clouds_direction = value
|
||||
update_clouds_direction()
|
||||
clouds_offset = value
|
||||
update_clouds_offset()
|
||||
|
||||
|
||||
|
||||
func update_clouds_direction() -> void:
|
||||
func update_clouds_offset() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
sky_material.set_shader_parameter(Sky3D.CLOUDS_DIRECTION, clouds_direction)
|
||||
sky_material.set_shader_parameter(Sky3D.CLOUDS_OFFSET, clouds_offset)
|
||||
|
||||
|
||||
func set_clouds_speed(value: float) -> void:
|
||||
if value == clouds_speed:
|
||||
func set_clouds_offset_speed(value: float) -> void:
|
||||
if value == clouds_offset_speed:
|
||||
return
|
||||
clouds_speed = value
|
||||
update_clouds_speed()
|
||||
clouds_offset_speed = value
|
||||
update_clouds_offset_speed()
|
||||
|
||||
|
||||
|
||||
func update_clouds_speed() -> void:
|
||||
func update_clouds_offset_speed() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
sky_material.set_shader_parameter(Sky3D.CLOUDS_SPEED, clouds_speed)
|
||||
sky_material.set_shader_parameter(Sky3D.CLOUDS_OFFSET_SPEED, clouds_offset_speed)
|
||||
|
||||
|
||||
func set_set_clouds_texture(value: bool) -> void:
|
||||
|
|
@ -1423,7 +1423,7 @@ func set_set_clouds_texture(value: bool) -> void:
|
|||
if not value:
|
||||
_set_clouds_texture(Sky3D._clouds_texture)
|
||||
notify_property_list_changed()
|
||||
|
||||
|
||||
|
||||
func _set_clouds_texture(value: Texture2D) -> void:
|
||||
if value == clouds_texture:
|
||||
|
|
@ -1454,8 +1454,8 @@ var clouds_cumulus_intensity: float = 1.0: set = set_clouds_cumulus_intensity
|
|||
var clouds_cumulus_mie_intensity: float = 1.0: set = set_clouds_cumulus_mie_intensity
|
||||
var clouds_cumulus_mie_anisotropy: float = 0.206: set = set_clouds_cumulus_mie_anisotropy
|
||||
var clouds_cumulus_size: float = 0.5: set = set_clouds_cumulus_size
|
||||
var clouds_cumulus_direction:= Vector3(0.25, 0.1, 0.25): set = set_clouds_cumulus_direction
|
||||
var clouds_cumulus_speed: float = 0.05: set = set_clouds_cumulus_speed
|
||||
var clouds_cumulus_offset:= Vector3(0.64, 0.522, 0.128): set = set_clouds_cumulus_offset
|
||||
var clouds_cumulus_offset_speed: float = 0.005: set = set_clouds_cumulus_offset_speed
|
||||
var set_clouds_cumulus_texture: bool = false: set = set_set_clouds_cumulus_texture
|
||||
var clouds_cumulus_texture: Texture2D = null: set = _set_clouds_cumulus_texture
|
||||
|
||||
|
|
@ -1465,7 +1465,7 @@ func set_clouds_cumulus_visible(value: bool) -> void:
|
|||
return
|
||||
clouds_cumulus_visible = value
|
||||
update_clouds_cumulus_visible()
|
||||
|
||||
|
||||
|
||||
func update_clouds_cumulus_visible() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1478,7 +1478,7 @@ func set_clouds_cumulus_day_color(value: Color) -> void:
|
|||
return
|
||||
clouds_cumulus_day_color = value
|
||||
update_clouds_cumulus_day_color()
|
||||
|
||||
|
||||
|
||||
func update_clouds_cumulus_day_color() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1620,30 +1620,30 @@ func update_clouds_cumulus_size() -> void:
|
|||
clouds_cumulus_material.set_shader_parameter(Sky3D.CLOUDS_SIZE, clouds_cumulus_size)
|
||||
|
||||
|
||||
func set_clouds_cumulus_direction(value: Vector3) -> void:
|
||||
if value == clouds_cumulus_direction:
|
||||
func set_clouds_cumulus_offset(value: Vector3) -> void:
|
||||
if value == clouds_cumulus_offset:
|
||||
return
|
||||
clouds_cumulus_direction = value
|
||||
update_clouds_cumulus_direction()
|
||||
clouds_cumulus_offset = value
|
||||
update_clouds_cumulus_offset()
|
||||
|
||||
|
||||
func update_clouds_cumulus_direction() -> void:
|
||||
func update_clouds_cumulus_offset() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
clouds_cumulus_material.set_shader_parameter(Sky3D.CLOUDS_DIRECTION, clouds_cumulus_direction)
|
||||
clouds_cumulus_material.set_shader_parameter(Sky3D.CLOUDS_OFFSET, clouds_cumulus_offset)
|
||||
|
||||
|
||||
func set_clouds_cumulus_speed(value: float) -> void:
|
||||
if value == clouds_cumulus_speed:
|
||||
func set_clouds_cumulus_offset_speed(value: float) -> void:
|
||||
if value == clouds_cumulus_offset_speed:
|
||||
return
|
||||
clouds_cumulus_speed = value
|
||||
update_clouds_cumulus_speed()
|
||||
clouds_cumulus_offset_speed = value
|
||||
update_clouds_cumulus_offset_speed()
|
||||
|
||||
|
||||
func update_clouds_cumulus_speed() -> void:
|
||||
func update_clouds_cumulus_offset_speed() -> void:
|
||||
if !is_scene_built:
|
||||
return
|
||||
clouds_cumulus_material.set_shader_parameter(Sky3D.CLOUDS_SPEED, clouds_cumulus_speed)
|
||||
clouds_cumulus_material.set_shader_parameter(Sky3D.CLOUDS_OFFSET_SPEED, clouds_cumulus_offset_speed)
|
||||
|
||||
|
||||
func set_set_clouds_cumulus_texture(value: bool) -> void:
|
||||
|
|
@ -1651,14 +1651,14 @@ func set_set_clouds_cumulus_texture(value: bool) -> void:
|
|||
if not value:
|
||||
_set_clouds_cumulus_texture(Sky3D._clouds_cumulus_texture)
|
||||
notify_property_list_changed()
|
||||
|
||||
|
||||
|
||||
func _set_clouds_cumulus_texture(value: Texture2D) -> void:
|
||||
if value == clouds_cumulus_texture:
|
||||
return
|
||||
clouds_cumulus_texture = value
|
||||
update_clouds_cumulus_texture()
|
||||
|
||||
|
||||
|
||||
func update_clouds_cumulus_texture() -> void:
|
||||
if !is_scene_built:
|
||||
|
|
@ -1689,7 +1689,7 @@ func __update_environment() -> void:
|
|||
col.a = 1.
|
||||
col.v = clamp(col.v, .35, 1.)
|
||||
environment.ambient_light_color = col
|
||||
|
||||
|
||||
|
||||
|
||||
#####################
|
||||
|
|
@ -1711,7 +1711,7 @@ func __set_day_state(v: float, threshold: float = 1.80) -> void:
|
|||
elif __day == false and abs(v) <= threshold:
|
||||
__day = true
|
||||
emit_signal("day_night_changed", __day)
|
||||
|
||||
|
||||
# Adjust lights and signal. Happens at a different time from "day time" above
|
||||
if __sun_light_node and __moon_light_node:
|
||||
if sun_light_enable and not __sun_light_node.visible and __sun_light_node.light_energy > 0.0:
|
||||
|
|
@ -1725,9 +1725,9 @@ func __set_day_state(v: float, threshold: float = 1.80) -> void:
|
|||
|
||||
|
||||
func _get_property_list() -> Array:
|
||||
var ret:= Array()
|
||||
var ret:= Array()
|
||||
ret.push_back({name = "Skydome", type = TYPE_NIL, usage = PROPERTY_USAGE_CATEGORY})
|
||||
|
||||
|
||||
# Global
|
||||
ret.push_back({name = "Global", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "sky_visible", type = TYPE_BOOL})
|
||||
|
|
@ -1738,19 +1738,19 @@ func _get_property_list() -> Array:
|
|||
ret.push_back({name = "sky_layers", type = TYPE_INT, hint = PROPERTY_HINT_LAYERS_3D_RENDER})
|
||||
ret.push_back({name = "sky_render_priority", type = TYPE_INT, hint = PROPERTY_HINT_RANGE, hint_string = "-128, 127"})
|
||||
ret.push_back({name = "horizon_level", type = TYPE_FLOAT})
|
||||
|
||||
|
||||
# Sun
|
||||
ret.push_back({name = "Sun", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "sun_altitude", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "-180.0, 180.0"})
|
||||
ret.push_back({name = "sun_azimuth", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "-180.0, 180.0"})
|
||||
ret.push_back({name = "sun_disk_color", type = TYPE_COLOR})
|
||||
ret.push_back({name = "sun_disk_intensity", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "0.0, 100.0"})
|
||||
ret.push_back({name = "sun_disk_intensity", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "0.0, 2.0"}) # Clamped 2.0 for prevent reflection probe artifacts.
|
||||
ret.push_back({name = "sun_disk_size", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "0.0, 0.5"})
|
||||
ret.push_back({name = "sun_light_path", type = TYPE_NODE_PATH})
|
||||
ret.push_back({name = "sun_light_color", type = TYPE_COLOR})
|
||||
ret.push_back({name = "sun_horizon_light_color", type = TYPE_COLOR})
|
||||
ret.push_back({name = "sun_light_energy", type = TYPE_FLOAT})
|
||||
|
||||
|
||||
# Moon
|
||||
ret.push_back({name = "Moon", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "moon_altitude", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "-180.0, 180.0"})
|
||||
|
|
@ -1758,34 +1758,34 @@ func _get_property_list() -> Array:
|
|||
ret.push_back({name = "moon_color", type = TYPE_COLOR})
|
||||
ret.push_back({name = "moon_size", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "enable_set_moon_texture", type = TYPE_BOOL})
|
||||
|
||||
|
||||
if enable_set_moon_texture:
|
||||
ret.push_back({name = "moon_texture", type = TYPE_OBJECT, hint = PROPERTY_HINT_FILE, hint_string = "Texture2D"})
|
||||
|
||||
|
||||
ret.push_back({name = "moon_resolution", type = TYPE_INT, hint = PROPERTY_HINT_ENUM, hint_string = "64, 128, 256, 512, 1024"})
|
||||
ret.push_back({name = "moon_light_path", type = TYPE_NODE_PATH})
|
||||
|
||||
|
||||
ret.push_back({name = "moon_light_color", type = TYPE_COLOR})
|
||||
ret.push_back({name = "moon_light_energy", type = TYPE_FLOAT})
|
||||
|
||||
|
||||
# Deep space
|
||||
ret.push_back({name = "DeepSpace", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "deep_space_euler", type = TYPE_VECTOR3})
|
||||
ret.push_back({name = "background_color", type = TYPE_COLOR})
|
||||
ret.push_back({name = "set_background_texture", type = TYPE_BOOL})
|
||||
|
||||
|
||||
if set_background_texture:
|
||||
ret.push_back({name = "background_texture", type = TYPE_OBJECT, hint = PROPERTY_HINT_GLOBAL_FILE, hint_string = "Texture2D"})
|
||||
|
||||
|
||||
ret.push_back({name = "stars_field_color", type = TYPE_COLOR})
|
||||
ret.push_back({name = "set_stars_field_texture", type = TYPE_BOOL})
|
||||
|
||||
|
||||
if set_stars_field_texture:
|
||||
ret.push_back({name = "stats_field_texture", type = TYPE_OBJECT, hint = PROPERTY_HINT_FILE, hint_string = "Texture2D"})
|
||||
|
||||
|
||||
ret.push_back({name = "stars_scintillation", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "0.0, 1.0"})
|
||||
ret.push_back({name = "stars_scintillation_speed", type = TYPE_FLOAT})
|
||||
|
||||
|
||||
# Atmosphere
|
||||
ret.push_back({name = "Atmosphere", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP, hint_string = "atm_"})
|
||||
ret.push_back({name = "atm_quality", type = TYPE_INT, hint = PROPERTY_HINT_ENUM, hint_string = "PerPixel,PerVertex"})
|
||||
|
|
@ -1803,11 +1803,11 @@ func _get_property_list() -> Array:
|
|||
ret.push_back({name = "atm_sun_mie_tint", type = TYPE_COLOR})
|
||||
ret.push_back({name = "atm_sun_mie_intensity", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "atm_sun_mie_anisotropy", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "0.0, 0.9999999"})
|
||||
|
||||
|
||||
ret.push_back({name = "atm_moon_mie_tint", type = TYPE_COLOR})
|
||||
ret.push_back({name = "atm_moon_mie_intensity", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "atm_moon_mie_anisotropy", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "0.0, 0.9999999"})
|
||||
|
||||
|
||||
# Fog
|
||||
ret.push_back({name = "Fog", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP, hint_string = "fog_"})
|
||||
ret.push_back({name = "fog_visible", type = TYPE_BOOL})
|
||||
|
|
@ -1820,7 +1820,7 @@ func _get_property_list() -> Array:
|
|||
ret.push_back({name = "fog_end", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "0.0, 5000.0"})
|
||||
ret.push_back({name = "fog_layers", type = TYPE_INT, hint = PROPERTY_HINT_LAYERS_3D_RENDER})
|
||||
ret.push_back({name = "fog_render_priority", type = TYPE_INT})
|
||||
|
||||
|
||||
# 2D Clouds
|
||||
ret.push_back({name = "2D Clouds", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "clouds_thickness", type = TYPE_FLOAT})
|
||||
|
|
@ -1830,13 +1830,13 @@ func _get_property_list() -> Array:
|
|||
ret.push_back({name = "clouds_intensity", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "clouds_size", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "clouds_uv", type = TYPE_VECTOR2})
|
||||
ret.push_back({name = "clouds_direction", type = TYPE_VECTOR2})
|
||||
ret.push_back({name = "clouds_speed", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "clouds_offset", type = TYPE_VECTOR2})
|
||||
ret.push_back({name = "clouds_offset_speed", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "set_clouds_texture", type = TYPE_BOOL})
|
||||
|
||||
|
||||
if set_clouds_texture:
|
||||
ret.push_back({name = "clouds_texture", type = TYPE_OBJECT, hint = PROPERTY_HINT_FILE, hint_string = "Texture2D"})
|
||||
|
||||
|
||||
# Clouds cumulus
|
||||
ret.push_back({name = "Clouds Cumulus", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "clouds_cumulus_visible", type = TYPE_BOOL})
|
||||
|
|
@ -1851,15 +1851,15 @@ func _get_property_list() -> Array:
|
|||
ret.push_back({name = "clouds_cumulus_mie_intensity", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "clouds_cumulus_mie_anisotropy", type = TYPE_FLOAT, hint = PROPERTY_HINT_RANGE, hint_string = "0.0, 0.999999"})
|
||||
ret.push_back({name = "clouds_cumulus_size", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "clouds_cumulus_direction", type = TYPE_VECTOR3})
|
||||
ret.push_back({name = "clouds_cumulus_speed", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "clouds_cumulus_offset", type = TYPE_VECTOR3})
|
||||
ret.push_back({name = "clouds_cumulus_offset_speed", type = TYPE_FLOAT})
|
||||
ret.push_back({name = "set_clouds_cumulus_texture", type = TYPE_BOOL})
|
||||
|
||||
|
||||
if set_clouds_cumulus_texture:
|
||||
ret.push_back({name = "clouds_cumulus_texture", type = TYPE_OBJECT, hint = PROPERTY_HINT_FILE, hint_string = "Texture2D"})
|
||||
|
||||
|
||||
# Lighting
|
||||
ret.push_back({name = "Lighting", type = TYPE_NIL, usage = PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "environment", type = TYPE_OBJECT, hint = PROPERTY_HINT_RESOURCE_TYPE, hint_string = "Resource"})
|
||||
|
||||
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://dlome35s3xvcj
|
||||
uid://cosn35lbnkhme
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static func plerp_vec3(from: Vector3, to: Vector3, t: float) -> Vector3:
|
|||
static func plerp_color(from: Color, to: Color, t: float) -> Color:
|
||||
var ret: Color
|
||||
ret.r = (1 - t) * from.r + t * to.r
|
||||
ret.g = (1 - t) * from.g + t * to.g
|
||||
ret.g = (1 - t) * from.g + t * to.b
|
||||
ret.b = (1 - t) * from.b + t * to.b
|
||||
ret.a = (1 - t) * from.a + t * to.a
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://qhe8d8o4yhda
|
||||
uid://c6hxtcwmtbhij
|
||||
|
|
|
|||
|
|
@ -65,14 +65,22 @@ func _ready() -> void:
|
|||
|
||||
|
||||
func _on_timeout() -> void:
|
||||
if system_sync:
|
||||
__get_date_time_os()
|
||||
else:
|
||||
var delta: float = .001 * (Time.get_ticks_msec() - _last_update)
|
||||
__progress_time(delta)
|
||||
__update_celestial_coords()
|
||||
_last_update = Time.get_ticks_msec()
|
||||
var delta: float = .001 * (Time.get_ticks_msec() - _last_update)
|
||||
|
||||
if not system_sync:
|
||||
__time_process(delta)
|
||||
__repeat_full_cycle()
|
||||
__check_cycle()
|
||||
else:
|
||||
__get_date_time_os()
|
||||
|
||||
__celestials_update_timer += delta;
|
||||
if __celestials_update_timer > celestials_update_time:
|
||||
__set_celestial_coords()
|
||||
__celestials_update_timer = 0.0
|
||||
|
||||
_last_update = Time.get_ticks_msec()
|
||||
|
||||
|
||||
func pause() -> void:
|
||||
if is_instance_valid(_update_timer):
|
||||
|
|
@ -101,9 +109,9 @@ func set_dome_path(value: NodePath) -> void:
|
|||
dome_path = value
|
||||
if value != null:
|
||||
__dome = get_node_or_null(value) as Skydome
|
||||
|
||||
|
||||
__dome_found = false if __dome == null else true
|
||||
__update_celestial_coords()
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
#####################
|
||||
|
|
@ -120,49 +128,31 @@ var year: int = 2025: set = set_year
|
|||
|
||||
|
||||
func set_total_hours(value: float) -> void:
|
||||
if total_hours != value:
|
||||
total_hours = value
|
||||
while total_hours > 23.9999:
|
||||
total_hours -= 24
|
||||
day += 1
|
||||
while total_hours < 0.0000:
|
||||
total_hours += 24
|
||||
day -= 1
|
||||
emit_signal("time_changed", total_hours)
|
||||
__update_celestial_coords()
|
||||
total_hours = value
|
||||
emit_signal("time_changed", value)
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func set_day(value: int) -> void:
|
||||
if day != value:
|
||||
day = value
|
||||
while day > max_days_per_month():
|
||||
day -= max_days_per_month()
|
||||
month += 1
|
||||
while day < 1:
|
||||
month -= 1
|
||||
day += max_days_per_month()
|
||||
emit_signal("day_changed", day)
|
||||
__update_celestial_coords()
|
||||
day = value
|
||||
emit_signal("day_changed", value)
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func set_month(value: int) -> void:
|
||||
if month != value:
|
||||
month = value
|
||||
while month > 12:
|
||||
month -= 12
|
||||
year += 1
|
||||
while month < 1:
|
||||
month += 12
|
||||
year -= 1
|
||||
emit_signal("month_changed", month)
|
||||
__update_celestial_coords()
|
||||
month = value
|
||||
emit_signal("month_changed", value)
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func set_year(value: int) -> void:
|
||||
if year != value:
|
||||
year = value
|
||||
emit_signal("year_changed", year)
|
||||
__update_celestial_coords()
|
||||
year = value
|
||||
emit_signal("year_changed", value)
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func is_learp_year() -> bool:
|
||||
|
|
@ -176,7 +166,7 @@ func max_days_per_month() -> int:
|
|||
2:
|
||||
return 29 if is_learp_year() else 28
|
||||
return 30
|
||||
|
||||
|
||||
|
||||
func time_cycle_duration() -> float:
|
||||
return total_cycle_in_minutes * 60.0
|
||||
|
|
@ -203,13 +193,15 @@ var celestials_calculations: int = 1: set = set_celestials_calculations
|
|||
var latitude: float = 16.0: set = set_latitude
|
||||
var longitude: float = 108.0: set = set_longitude
|
||||
var utc: float = 7.0: set = set_utc
|
||||
var celestials_update_time: float = 0.0
|
||||
var __celestials_update_timer: float = 0.0
|
||||
var compute_moon_coords: bool = true: set = set_compute_moon_coords
|
||||
var compute_deep_space_coords: bool = true: set = set_compute_deep_space_coords
|
||||
var moon_coords_offset := Vector2(0.0, 0.0): set = set_moon_coords_offset
|
||||
var __sun_coords := Vector2.ZERO
|
||||
var __moon_coords := Vector2.ZERO
|
||||
var __sun_distance: float
|
||||
var __true_sun_longitude: float
|
||||
var __true_sun_longitude: float
|
||||
var __mean_sun_longitude: float
|
||||
var __sideral_time: float
|
||||
var __local_sideral_time: float
|
||||
|
|
@ -219,39 +211,46 @@ var __moon_orbital_elements := OrbitalElements.new()
|
|||
|
||||
func set_celestials_calculations(value: int) -> void:
|
||||
celestials_calculations = value
|
||||
__update_celestial_coords()
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
notify_property_list_changed()
|
||||
|
||||
|
||||
|
||||
func set_latitude(value: float) -> void:
|
||||
latitude = value
|
||||
__update_celestial_coords()
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func set_longitude(value: float) -> void:
|
||||
longitude = value
|
||||
__update_celestial_coords()
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func set_utc(value: float) -> void:
|
||||
utc = value
|
||||
__update_celestial_coords()
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func set_compute_moon_coords(value: bool) -> void:
|
||||
compute_moon_coords = value
|
||||
__update_celestial_coords()
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
notify_property_list_changed()
|
||||
|
||||
|
||||
|
||||
func set_compute_deep_space_coords(value: bool) -> void:
|
||||
compute_deep_space_coords = value
|
||||
__update_celestial_coords()
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func set_moon_coords_offset(value: Vector2) -> void:
|
||||
moon_coords_offset = value
|
||||
__update_celestial_coords()
|
||||
if Engine.is_editor_hint():
|
||||
__set_celestial_coords()
|
||||
|
||||
|
||||
func __get_latitude_rad() -> float:
|
||||
|
|
@ -280,35 +279,8 @@ func set_time(hour: int, minute: int, second: int) -> void:
|
|||
set_total_hours(DateTimeUtil.hours_to_total_hours(hour, minute, second))
|
||||
|
||||
|
||||
func set_from_datetime_dict(datetime_dict: Dictionary) -> void:
|
||||
set_year(datetime_dict.year)
|
||||
set_month(datetime_dict.month)
|
||||
set_day(datetime_dict.day)
|
||||
set_time(datetime_dict.hour, datetime_dict.minute, datetime_dict.second)
|
||||
|
||||
|
||||
func get_datetime_dict() -> Dictionary:
|
||||
var datetime_dict := {
|
||||
"year": year,
|
||||
"month": month,
|
||||
"day": day,
|
||||
"hour": floor(total_hours),
|
||||
"minute": floor(fmod(total_hours, 1.0) * 60.0),
|
||||
"second": floor(fmod(total_hours * 60.0, 1.0) * 60.0)
|
||||
}
|
||||
return datetime_dict
|
||||
|
||||
|
||||
func set_from_unix_timestamp(timestamp: int) -> void:
|
||||
set_from_datetime_dict(Time.get_datetime_dict_from_unix_time(timestamp))
|
||||
|
||||
|
||||
func get_unix_timestamp() -> int:
|
||||
return Time.get_unix_time_from_datetime_dict(get_datetime_dict())
|
||||
|
||||
|
||||
func __progress_time(delta: float) -> void:
|
||||
if not is_zero_approx(time_cycle_duration()):
|
||||
func __time_process(delta: float) -> void:
|
||||
if time_cycle_duration() != 0.0:
|
||||
set_total_hours(total_hours + delta / time_cycle_duration() * DateTimeUtil.TOTAL_HOURS)
|
||||
|
||||
|
||||
|
|
@ -320,12 +292,47 @@ func __get_date_time_os() -> void:
|
|||
set_year(date_time_os.year)
|
||||
|
||||
|
||||
func __repeat_full_cycle() -> void:
|
||||
if is_end_of_time() && total_hours >= 23.9999:
|
||||
set_year(1); set_month(1); set_day(1)
|
||||
set_total_hours(0.0)
|
||||
|
||||
if is_begin_of_time() && total_hours < 0.0:
|
||||
set_year(9999); set_month(12); set_day(31)
|
||||
set_total_hours(23.9999)
|
||||
|
||||
|
||||
func __check_cycle() -> void:
|
||||
if total_hours > 23.9999:
|
||||
set_day(day + 1)
|
||||
set_total_hours(0.0)
|
||||
if total_hours < 0.0000:
|
||||
set_day(day - 1)
|
||||
set_total_hours(23.9999)
|
||||
|
||||
if day > max_days_per_month():
|
||||
set_month(month + 1)
|
||||
set_day(1)
|
||||
|
||||
if day < 1:
|
||||
set_month(month - 1)
|
||||
set_day(31)
|
||||
|
||||
if month > 12:
|
||||
set_year(year + 1)
|
||||
set_month(1)
|
||||
|
||||
if month < 1:
|
||||
set_year(year - 1)
|
||||
set_month(12)
|
||||
|
||||
|
||||
#####################
|
||||
## Planetary
|
||||
#####################
|
||||
|
||||
|
||||
func __update_celestial_coords() -> void:
|
||||
func __set_celestial_coords() -> void:
|
||||
if not __dome_found:
|
||||
return
|
||||
|
||||
|
|
@ -338,24 +345,24 @@ func __update_celestial_coords() -> void:
|
|||
__compute_simple_moon_coords()
|
||||
__dome.moon_altitude = __moon_coords.y
|
||||
__dome.moon_azimuth = __moon_coords.x
|
||||
|
||||
|
||||
if compute_deep_space_coords:
|
||||
var x = Quaternion.from_euler(Vector3( (90 + latitude) * TOD_Math.DEG_TO_RAD, 0.0, 0.0))
|
||||
var y = Quaternion.from_euler(Vector3(0.0, 0.0, __sun_coords.y * TOD_Math.DEG_TO_RAD))
|
||||
__dome.deep_space_quat = x * y
|
||||
|
||||
|
||||
CelestialCalculationsMode.Realistic:
|
||||
__compute_realistic_sun_coords()
|
||||
__dome.sun_altitude = -__sun_coords.y * TOD_Math.RAD_TO_DEG
|
||||
__dome.sun_azimuth = -__sun_coords.x * TOD_Math.RAD_TO_DEG
|
||||
__dome.sun_altitude = __sun_coords.y * TOD_Math.RAD_TO_DEG
|
||||
__dome.sun_azimuth = __sun_coords.x * TOD_Math.RAD_TO_DEG
|
||||
if compute_moon_coords:
|
||||
__compute_realistic_moon_coords()
|
||||
__dome.moon_altitude = -__moon_coords.y * TOD_Math.RAD_TO_DEG
|
||||
__dome.moon_azimuth = -__moon_coords.x * TOD_Math.RAD_TO_DEG
|
||||
|
||||
__dome.moon_altitude = __moon_coords.y * TOD_Math.RAD_TO_DEG
|
||||
__dome.moon_azimuth = __moon_coords.x * TOD_Math.RAD_TO_DEG
|
||||
|
||||
if compute_deep_space_coords:
|
||||
var x = Quaternion.from_euler(Vector3( (90 + latitude) * TOD_Math.DEG_TO_RAD, 0.0, 0.0) )
|
||||
var y = Quaternion.from_euler(Vector3(0.0, 0.0, (180.0 - __local_sideral_time * TOD_Math.RAD_TO_DEG) * TOD_Math.DEG_TO_RAD))
|
||||
var y = Quaternion.from_euler(Vector3(0.0, 0.0, (180.0 - __local_sideral_time * TOD_Math.RAD_TO_DEG) * TOD_Math.DEG_TO_RAD))
|
||||
__dome.deep_space_quat = x * y
|
||||
|
||||
|
||||
|
|
@ -374,83 +381,83 @@ func __compute_realistic_sun_coords() -> void:
|
|||
# Orbital Elements
|
||||
__sun_orbital_elements.get_orbital_elements(0, __get_time_scale())
|
||||
__sun_orbital_elements.M = TOD_Math.rev(__sun_orbital_elements.M)
|
||||
|
||||
|
||||
# Mean anomaly in radians
|
||||
var MRad: float = TOD_Math.DEG_TO_RAD * __sun_orbital_elements.M
|
||||
|
||||
|
||||
# Eccentric Anomaly
|
||||
var E: float = __sun_orbital_elements.M + TOD_Math.RAD_TO_DEG * __sun_orbital_elements.e *\
|
||||
sin(MRad) * (1 + __sun_orbital_elements.e * cos(MRad))
|
||||
|
||||
|
||||
var ERad: float = E * TOD_Math.DEG_TO_RAD
|
||||
|
||||
|
||||
# Rectangular coordinates of the sun in the plane of the ecliptic
|
||||
var xv: float = cos(ERad) - __sun_orbital_elements.e
|
||||
var yv: float = sin(ERad) * sqrt(1 - __sun_orbital_elements.e * __sun_orbital_elements.e)
|
||||
|
||||
|
||||
# Distance and true anomaly
|
||||
# Convert to distance and true anomaly(r = radians, v = degrees)
|
||||
var r: float = sqrt(xv * xv + yv * yv)
|
||||
var v: float = TOD_Math.RAD_TO_DEG * atan2(yv, xv)
|
||||
__sun_distance = r
|
||||
|
||||
|
||||
# True longitude
|
||||
var lonSun: float = v + __sun_orbital_elements.w
|
||||
lonSun = TOD_Math.rev(lonSun)
|
||||
|
||||
|
||||
var lonSunRad = TOD_Math.DEG_TO_RAD * lonSun
|
||||
__true_sun_longitude = lonSunRad
|
||||
|
||||
|
||||
## Ecliptic and ecuatorial coords
|
||||
|
||||
|
||||
# Ecliptic rectangular coords
|
||||
var xs: float = r * cos(lonSunRad)
|
||||
var ys: float = r * sin(lonSunRad)
|
||||
|
||||
|
||||
# Ecliptic rectangular coordinates rotate these to equatorial coordinates
|
||||
var obleclCos: float = cos(__get_oblecl())
|
||||
var obleclSin: float = sin(__get_oblecl())
|
||||
|
||||
var xe: float = xs
|
||||
|
||||
var xe: float = xs
|
||||
var ye: float = ys * obleclCos - 0.0 * obleclSin
|
||||
var ze: float = ys * obleclSin + 0.0 * obleclCos
|
||||
|
||||
|
||||
# Ascencion and declination
|
||||
var RA: float = TOD_Math.RAD_TO_DEG * atan2(ye, xe) / 15 # right ascension.
|
||||
var decl: float = atan2(ze, sqrt(xe * xe + ye * ye)) # declination
|
||||
|
||||
|
||||
# Mean longitude
|
||||
var L: float = __sun_orbital_elements.w + __sun_orbital_elements.M
|
||||
L = TOD_Math.rev(L)
|
||||
|
||||
|
||||
__mean_sun_longitude = L
|
||||
|
||||
|
||||
# Sideral time and hour angle
|
||||
var GMST0: float = ((L/15) + 12)
|
||||
__sideral_time = GMST0 + __get_total_hours_utc() + longitude / 15 # +15/15
|
||||
__local_sideral_time = TOD_Math.DEG_TO_RAD * __sideral_time * 15
|
||||
|
||||
|
||||
var HA: float = (__sideral_time - RA) * 15
|
||||
var HARAD: float = TOD_Math.DEG_TO_RAD * HA
|
||||
|
||||
|
||||
# Hour angle and declination in rectangular coords
|
||||
# HA and Decl in rectangular coords
|
||||
var declCos: float = cos(decl)
|
||||
var x = cos(HARAD) * declCos # X Axis points to the celestial equator in the south.
|
||||
var y = sin(HARAD) * declCos # Y axis points to the horizon in the west.
|
||||
var z = sin(decl) # Z axis points to the north celestial pole.
|
||||
|
||||
|
||||
# Rotate the rectangualar coordinates system along of the Y axis
|
||||
var sinLat: float = sin(latitude * TOD_Math.DEG_TO_RAD)
|
||||
var cosLat: float = cos(latitude * TOD_Math.DEG_TO_RAD)
|
||||
var xhor: float = x * sinLat - z * cosLat
|
||||
var yhor: float = y
|
||||
var yhor: float = y
|
||||
var zhor: float = x * cosLat + z * sinLat
|
||||
|
||||
|
||||
# Azimuth and altitude
|
||||
__sun_coords.x = atan2(yhor, xhor) + PI
|
||||
__sun_coords.y = (PI * 0.5) - asin(zhor) # atan2(zhor, sqrt(xhor * xhor + yhor * yhor))
|
||||
|
||||
|
||||
|
||||
func __compute_realistic_moon_coords() -> void:
|
||||
# Orbital Elements
|
||||
|
|
@ -458,119 +465,119 @@ func __compute_realistic_moon_coords() -> void:
|
|||
__moon_orbital_elements.N = TOD_Math.rev(__moon_orbital_elements.N)
|
||||
__moon_orbital_elements.w = TOD_Math.rev(__moon_orbital_elements.w)
|
||||
__moon_orbital_elements.M = TOD_Math.rev(__moon_orbital_elements.M)
|
||||
|
||||
|
||||
var NRad: float = TOD_Math.DEG_TO_RAD * __moon_orbital_elements.N
|
||||
var IRad: float = TOD_Math.DEG_TO_RAD * __moon_orbital_elements.i
|
||||
var MRad: float = TOD_Math.DEG_TO_RAD * __moon_orbital_elements.M
|
||||
|
||||
|
||||
# Eccentric anomaly
|
||||
var E: float = __moon_orbital_elements.M + TOD_Math.RAD_TO_DEG * __moon_orbital_elements.e * sin(MRad) *\
|
||||
(1 + __sun_orbital_elements.e * cos(MRad))
|
||||
|
||||
|
||||
var ERad = TOD_Math.DEG_TO_RAD * E
|
||||
|
||||
|
||||
# Rectangular coords and true anomaly
|
||||
# Rectangular coordinates of the sun in the plane of the ecliptic
|
||||
var xv: float = __moon_orbital_elements.a * (cos(ERad) - __moon_orbital_elements.e)
|
||||
var yv: float = __moon_orbital_elements.a * (sin(ERad) * sqrt(1 - __moon_orbital_elements.e * \
|
||||
__moon_orbital_elements.e)) * sin(ERad)
|
||||
|
||||
|
||||
# Convert to distance and true anomaly(r = radians, v = degrees)
|
||||
var r: float = sqrt(xv * xv + yv * yv)
|
||||
var v: float = TOD_Math.RAD_TO_DEG * atan2(yv, xv)
|
||||
v = TOD_Math.rev(v)
|
||||
|
||||
|
||||
var l: float = TOD_Math.DEG_TO_RAD * v + __moon_orbital_elements.w
|
||||
|
||||
|
||||
var cosL: float = cos(l)
|
||||
var sinL: float = sin(l)
|
||||
var cosNRad: float = cos(NRad)
|
||||
var sinNRad: float = sin(NRad)
|
||||
var cosIRad: float = cos(IRad)
|
||||
|
||||
|
||||
var xeclip: float = r * (cosNRad * cosL - sinNRad * sinL * cosIRad)
|
||||
var yeclip: float = r * (sinNRad * cosL + cosNRad * sinL * cosIRad)
|
||||
var zeclip: float = r * (sinL * sin(IRad))
|
||||
|
||||
|
||||
# Geocentric coords
|
||||
# Geocentric position for the moon and Heliocentric position for the planets
|
||||
var lonecl: float = TOD_Math.RAD_TO_DEG * atan2(yeclip, xeclip)
|
||||
lonecl = TOD_Math.rev(lonecl)
|
||||
|
||||
|
||||
var latecl: float = TOD_Math.RAD_TO_DEG * atan2(zeclip, sqrt(xeclip * xeclip + yeclip * yeclip))
|
||||
|
||||
|
||||
# Get true sun longitude
|
||||
var lonsun: float = __true_sun_longitude
|
||||
|
||||
|
||||
# Ecliptic longitude and latitude in radians
|
||||
var loneclRad: float = TOD_Math.DEG_TO_RAD * lonecl
|
||||
var lateclRad: float = TOD_Math.DEG_TO_RAD * latecl
|
||||
|
||||
|
||||
var nr: float = 1.0
|
||||
var xh: float = nr * cos(loneclRad) * cos(lateclRad)
|
||||
var yh: float = nr * sin(loneclRad) * cos(lateclRad)
|
||||
var zh: float = nr * sin(lateclRad)
|
||||
|
||||
|
||||
# Geocentric coords
|
||||
var xs: float = 0.0
|
||||
var ys: float = 0.0
|
||||
|
||||
|
||||
# Convert the geocentric position to heliocentric position
|
||||
var xg: float = xh + xs
|
||||
var yg: float = yh + ys
|
||||
var zg: float = zh
|
||||
|
||||
|
||||
# Ecuatorial coords
|
||||
# Cobert xg, yg un equatorial coords
|
||||
var obleclCos: float = cos(__get_oblecl())
|
||||
var obleclSin: float = sin(__get_oblecl())
|
||||
|
||||
var xe: float = xg
|
||||
|
||||
var xe: float = xg
|
||||
var ye: float = yg * obleclCos - zg * obleclSin
|
||||
var ze: float = yg * obleclSin + zg * obleclCos
|
||||
|
||||
|
||||
# Right ascention
|
||||
var RA: float = TOD_Math.RAD_TO_DEG * atan2(ye, xe)
|
||||
RA = TOD_Math.rev(RA)
|
||||
|
||||
|
||||
# Declination
|
||||
var decl: float = TOD_Math.RAD_TO_DEG * atan2(ze, sqrt(xe * xe + ye * ye))
|
||||
var declRad: float = TOD_Math.DEG_TO_RAD * decl
|
||||
|
||||
|
||||
# Sideral time and hour angle
|
||||
var HA: float = ((__sideral_time * 15) - RA)
|
||||
HA = TOD_Math.rev(HA)
|
||||
var HARAD: float = TOD_Math.DEG_TO_RAD * HA
|
||||
|
||||
|
||||
# HA y Decl in rectangular coordinates
|
||||
var declCos: float = cos(declRad)
|
||||
var xr: float = cos(HARAD) * declCos
|
||||
var yr: float = sin(HARAD) * declCos
|
||||
var zr: float = sin(declRad)
|
||||
|
||||
|
||||
# Rotate the rectangualar coordinates system along of the Y axis(radians)
|
||||
var sinLat: float = sin(__get_latitude_rad())
|
||||
var cosLat: float = cos(__get_latitude_rad())
|
||||
|
||||
|
||||
var xhor: float = xr * sinLat - zr * cosLat
|
||||
var yhor: float = yr
|
||||
var yhor: float = yr
|
||||
var zhor: float = xr * cosLat + zr * sinLat
|
||||
|
||||
|
||||
# Azimuth and altitude
|
||||
__moon_coords.x = atan2(yhor, xhor) + PI
|
||||
__moon_coords.y = (PI *0.5) - atan2(zhor, sqrt(xhor * xhor + yhor * yhor)) # Mathf.Asin(zhor)
|
||||
|
||||
|
||||
func _get_property_list() -> Array:
|
||||
var ret: Array
|
||||
var ret: Array
|
||||
ret.push_back({name = "Time Of Day", type=TYPE_NIL, usage=PROPERTY_USAGE_CATEGORY})
|
||||
|
||||
|
||||
ret.push_back({name = "Target", type=TYPE_NIL, usage=PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "dome_path", type=TYPE_NODE_PATH})
|
||||
|
||||
|
||||
ret.push_back({name = "DateTime", type=TYPE_NIL, usage=PROPERTY_USAGE_GROUP})
|
||||
ret.push_back({name = "system_sync", type=TYPE_BOOL})
|
||||
|
||||
|
||||
ret.push_back({name = "total_cycle_in_minutes", type=TYPE_FLOAT})
|
||||
ret.push_back({name = "total_hours", type=TYPE_FLOAT, hint=PROPERTY_HINT_RANGE, hint_string="0.0, 24.0"})
|
||||
ret.push_back({name = "day", type=TYPE_INT, hint=PROPERTY_HINT_RANGE, hint_string="0, 31"})
|
||||
|
|
@ -583,10 +590,11 @@ func _get_property_list() -> Array:
|
|||
|
||||
if celestials_calculations == 0 && compute_moon_coords:
|
||||
ret.push_back({name = "moon_coords_offset", type=TYPE_VECTOR2})
|
||||
|
||||
|
||||
ret.push_back({name = "compute_deep_space_coords", type=TYPE_BOOL})
|
||||
ret.push_back({name = "latitude", type=TYPE_FLOAT, hint=PROPERTY_HINT_RANGE, hint_string="-90.0, 90.0"})
|
||||
ret.push_back({name = "longitude", type=TYPE_FLOAT, hint=PROPERTY_HINT_RANGE, hint_string="-180.0, 180.0"})
|
||||
ret.push_back({name = "utc", type=TYPE_FLOAT, hint=PROPERTY_HINT_RANGE, hint_string="-12.0, 12.0"})
|
||||
|
||||
ret.push_back({name = "celestials_update_time", type=TYPE_FLOAT})
|
||||
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://blrv2g077uvcq
|
||||
uid://bviswil7dda20
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue