main menu - fix sky

This commit is contained in:
Matteo Sonaglioni
2026-06-19 10:53:58 +02:00
parent f5ab6bcc54
commit c47fff7890
9 changed files with 274 additions and 28 deletions

View File

@@ -56,16 +56,15 @@ rain_exposure_morning = 0.3
rain_exposure_afternoon = 0.4 rain_exposure_afternoon = 0.4
rain_exposure_night = 1.8 rain_exposure_night = 1.8
storm_exposure_night = 1.8 storm_exposure_night = 1.8
sky_top_morning = Color(0.11764706, 0.35686275, 0.5411765, 1) sky_top_morning = Color(0.3176695, 0.43165123, 0.8895605, 1)
sky_top_afternoon = Color(0.7019608, 0.4509804, 0.2, 1) sky_top_afternoon = Color(0.42314696, 0.32907307, 0.74664044, 1)
sky_top_night = Color(0.050980393, 0.050980393, 0.14901961, 1) sky_top_night = Color(0.20675227, 0.20655477, 0.4437065, 1)
sky_horizon_morning = Color(0.4627451, 0.6745098, 0.8627451, 1) sky_horizon_afternoon = Color(0.96335155, 0.3563425, 0.1952039, 1)
sky_horizon_afternoon = Color(0.93333334, 0.6, 0.8039216, 1) sky_horizon_night = Color(0.13534775, 0.09013713, 0.2303626, 1)
sky_horizon_night = Color(0.14901961, 0.101960786, 0.2509804, 1)
grad_top_morning = Color(0.7921569, 0.8784314, 0.95686275, 1) grad_top_morning = Color(0.7921569, 0.8784314, 0.95686275, 1)
grad_top_afternoon = Color(0.8627451, 0.24313726, 0.5411765, 1) grad_top_afternoon = Color(0.8627451, 0.24313726, 0.5411765, 1)
grad_top_night = Color(0.16470589, 0.16470589, 0.26666668, 1) grad_top_night = Color(0.16470589, 0.16470589, 0.26666668, 1)
grad_bot_morning = Color(0.05882353, 0.078431375, 0.21568628, 1) grad_bot_morning = Color(0.64469576, 0.7045768, 0.9350398, 1)
grad_bot_afternoon = Color(0.2509804, 0.019607844, 0.043137256, 1) grad_bot_afternoon = Color(0.2509804, 0.019607844, 0.043137256, 1)
grad_intensity_morning = 0.05 grad_intensity_morning = 0.05
grad_intensity_afternoon = 0.1 grad_intensity_afternoon = 0.1

Binary file not shown.

View File

@@ -0,0 +1,44 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bio6eds43i7rt"
path="res://.godot/imported/cloud1.fbx-17a222b854adef5625cf45abfe9e12f7.scn"
[deps]
source_file="res://tgcc/chunk/prop/cloud/cloud1.fbx"
dest_files=["res://.godot/imported/cloud1.fbx-17a222b854adef5625cf45abfe9e12f7.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=true
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
fbx/importer=0
fbx/allow_geometry_helper_nodes=false
fbx/embedded_image_handling=1
fbx/naming_version=2

View File

@@ -0,0 +1,39 @@
shader_type spatial;
// Corretto: rimosso ambient_sink che mandava in errore il compilatore
render_mode diffuse_toon, specular_disabled;
uniform vec3 cloud_color : source_color = vec3(0.95, 0.95, 0.98);
uniform vec3 shadow_color : source_color = vec3(0.4, 0.45, 0.65);
uniform vec3 rim_color : source_color = vec3(1.0, 0.6, 0.4);
group_uniforms Cel_Shading_Control;
uniform float shadow_threshold : hint_range(-1.0, 1.0) = -0.1;
uniform float shadow_softness : hint_range(0.001, 1.0) = 0.05;
group_uniforms Rim_Light_Control;
uniform float rim_size : hint_range(0.0, 1.0) = 0.35;
uniform float rim_softness : hint_range(0.001, 1.0) = 0.1;
void fragment() {
ALBEDO = cloud_color;
}
void light() {
// 1. Calcolo del Cel Shading (Luce vs Ombra)
float NdotL = dot(NORMAL, LIGHT);
float shadow_mask = smoothstep(shadow_threshold, shadow_threshold + shadow_softness, NdotL);
vec3 base_lighting = mix(shadow_color, cloud_color, shadow_mask);
// 2. Calcolo del Rim Light (Il sole che illumina i bordi da dietro)
float VdotL = dot(VIEW, LIGHT);
float rim_dot = 1.0 - dot(NORMAL, VIEW);
float rim_mask = smoothstep(1.0 - rim_size, (1.0 - rim_size) + rim_softness, rim_dot);
rim_mask *= smoothstep(-0.3, 0.3, -VdotL);
// 3. Composizione Finale
vec3 final_color = mix(base_lighting, rim_color, rim_mask * shadow_mask) * LIGHT_COLOR;
DIFFUSE_LIGHT += final_color * ATTENUATION;
}

View File

@@ -0,0 +1 @@
uid://cpgtj8mhjklb8

View File

@@ -0,0 +1,20 @@
[gd_scene format=3 uid="uid://hvr66x101a0v"]
[ext_resource type="PackedScene" uid="uid://bio6eds43i7rt" path="res://tgcc/chunk/prop/cloud/cloud1.fbx" id="1_nnqat"]
[ext_resource type="Shader" uid="uid://cpgtj8mhjklb8" path="res://tgcc/chunk/prop/cloud/cloud3d.gdshader" id="2_j3pha"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_uam3e"]
render_priority = 0
shader = ExtResource("2_j3pha")
shader_parameter/cloud_color = Color(0.95, 0.95, 0.98, 1)
shader_parameter/shadow_color = Color(0.4, 0.45, 0.65, 1)
shader_parameter/rim_color = Color(1, 0.6, 0.4, 1)
shader_parameter/shadow_threshold = -0.1
shader_parameter/shadow_softness = 0.05
shader_parameter/rim_size = 0.4810000228475
shader_parameter/rim_softness = 0.07200000342
[node name="cloud1" unique_id=1538081576 instance=ExtResource("1_nnqat")]
[node name="Cube" parent="." index="0" unique_id=918471000]
surface_material_override/0 = SubResource("ShaderMaterial_uam3e")

View File

@@ -2,8 +2,8 @@
[ext_resource type="PackedScene" uid="uid://cmuvmmp7xam4o" path="res://core/daynight/environment_management.tscn" id="1_2o8pc"] [ext_resource type="PackedScene" uid="uid://cmuvmmp7xam4o" path="res://core/daynight/environment_management.tscn" id="1_2o8pc"]
[ext_resource type="PackedScene" uid="uid://bmwmdsdyfxfc1" path="res://tgcc/map/map_1/map_menu.tscn" id="2_wbrya"] [ext_resource type="PackedScene" uid="uid://bmwmdsdyfxfc1" path="res://tgcc/map/map_1/map_menu.tscn" id="2_wbrya"]
[ext_resource type="Shader" uid="uid://bneue3fq71vp8" path="res://tgcc/main menu/sky_test.gdshader" id="3_5p27e"]
[ext_resource type="Script" uid="uid://cx2tlvxhvatj5" path="res://docs/museums/daynight/control.gd" id="3_wbrya"] [ext_resource type="Script" uid="uid://cx2tlvxhvatj5" path="res://docs/museums/daynight/control.gd" id="3_wbrya"]
[ext_resource type="Shader" uid="uid://bneoex8xpmcm8" path="res://core/daynight/sky.gdshader" id="4_h3o38"]
[ext_resource type="Texture2D" uid="uid://dest0qa7vaid0" path="res://core/daynight/stars_albedo.png" id="5_25h5j"] [ext_resource type="Texture2D" uid="uid://dest0qa7vaid0" path="res://core/daynight/stars_albedo.png" id="5_25h5j"]
[ext_resource type="Script" uid="uid://brcimd12tx3dm" path="res://core/daynight/edge_detection_compositor.gd" id="6_4flsv"] [ext_resource type="Script" uid="uid://brcimd12tx3dm" path="res://core/daynight/edge_detection_compositor.gd" id="6_4flsv"]
[ext_resource type="Script" uid="uid://dboerd4a6dwj7" path="res://core/biome_generator/rails.gd" id="7_5p27e"] [ext_resource type="Script" uid="uid://dboerd4a6dwj7" path="res://core/biome_generator/rails.gd" id="7_5p27e"]
@@ -11,31 +11,15 @@
[ext_resource type="Resource" uid="uid://bjnytgwt8tmf4" path="res://core/biome_generator/wagon_pool.tres" id="9_wcae3"] [ext_resource type="Resource" uid="uid://bjnytgwt8tmf4" path="res://core/biome_generator/wagon_pool.tres" id="9_wcae3"]
[ext_resource type="PackedScene" uid="uid://0kgjaqijaqku" path="res://docs/museums/biome_generator/rails.tscn" id="10_00nq7"] [ext_resource type="PackedScene" uid="uid://0kgjaqijaqku" path="res://docs/museums/biome_generator/rails.tscn" id="10_00nq7"]
[ext_resource type="PackedScene" uid="uid://dn1btv0e0ses7" path="res://core/fireworks.tscn" id="11_aylkj"] [ext_resource type="PackedScene" uid="uid://dn1btv0e0ses7" path="res://core/fireworks.tscn" id="11_aylkj"]
[ext_resource type="PackedScene" uid="uid://hvr66x101a0v" path="res://tgcc/chunk/prop/cloud/cloud_1.tscn" id="12_ljvyb"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_1nm1b"]
fractal_lacunarity = 1.915
fractal_gain = 0.53
fractal_weighted_strength = 0.35
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_abyor"]
noise = SubResource("FastNoiseLite_1nm1b")
seamless = true
[sub_resource type="ShaderMaterial" id="ShaderMaterial_nbjr8"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_nbjr8"]
shader = ExtResource("4_h3o38") shader = ExtResource("3_5p27e")
shader_parameter/sky_top_color = Color(0.36438444, 0.6417803, 0.8712311, 1) shader_parameter/sky_top_color = Color(0.36438444, 0.6417803, 0.8712311, 1)
shader_parameter/sky_horizon_color = Color(0.75821966, 0.8417803, 0.92534095, 1) shader_parameter/sky_horizon_color = Color(0.75821966, 0.8417803, 0.92534095, 1)
shader_parameter/night_intensity = 0.0 shader_parameter/night_intensity = 0.0
shader_parameter/cloud_noise = SubResource("NoiseTexture2D_abyor") shader_parameter/horizon_height = 0.066000003135
shader_parameter/sun_color = Color(1, 0.88767046, 0.775341, 1) shader_parameter/horizon_blur = 0.4
shader_parameter/cloud_center_color = Color(1, 1, 1, 1)
shader_parameter/cloud_edge_color = Color(0.8, 0.85, 0.9, 1)
shader_parameter/cloud_direction = Vector2(0.5, 0.2)
shader_parameter/cloud_speed = 0.1
shader_parameter/cloud_scale = 0.5
shader_parameter/cloud_threshold = 0.5
shader_parameter/cloud_edge_thickness = 0.406000019285
shader_parameter/cloud_edge_softness = 0.0
shader_parameter/star_density = 1500.0 shader_parameter/star_density = 1500.0
shader_parameter/star_rarity = 2500.0 shader_parameter/star_rarity = 2500.0
shader_parameter/star_scale_variation = 0.5 shader_parameter/star_scale_variation = 0.5
@@ -368,6 +352,39 @@ fireworks_scene = ExtResource("11_aylkj")
[node name="MainMap" parent="." unique_id=1895741703 instance=ExtResource("2_wbrya")] [node name="MainMap" parent="." unique_id=1895741703 instance=ExtResource("2_wbrya")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 63.837585, 0, -4.743943e-06) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 63.837585, 0, -4.743943e-06)
[node name="cloud1" parent="." unique_id=1538081576 instance=ExtResource("12_ljvyb")]
transform = Transform3D(-3.0750962e-07, 0, 7.035, 0, 7.035, 0, -7.035, 0, -3.0750962e-07, 203.62189, 53.997868, 215.32469)
[node name="cloud2" parent="." unique_id=953705227 instance=ExtResource("12_ljvyb")]
transform = Transform3D(1.6706831e-07, 1.1604034e-06, 32.595, 32.052925, -3.165528, 0, 3.8220775, 26.546934, -1.4247728e-06, 391.87766, 43.10347, 332.97614)
[node name="cloud6" parent="." unique_id=141140018 instance=ExtResource("12_ljvyb")]
transform = Transform3D(1.6706831e-07, 1.1604034e-06, 32.595, 32.052925, -3.165528, 0, 3.8220775, 26.546934, -1.4247728e-06, 391.87766, -65.08275, 173.45769)
[node name="cloud7" parent="." unique_id=329542413 instance=ExtResource("12_ljvyb")]
transform = Transform3D(1.6706831e-07, 1.1604034e-06, 32.595, 32.052925, -3.165528, 0, 3.8220775, 26.546934, -1.4247728e-06, 391.87766, 178.66306, 202.5226)
[node name="cloud8" parent="." unique_id=1444868324 instance=ExtResource("12_ljvyb")]
transform = Transform3D(-3.0750962e-07, 0, 7.035, 0, 7.035, 0, -7.035, 0, -3.0750962e-07, 46.042877, 53.997868, 215.32469)
[node name="cloud9" parent="." unique_id=468105212 instance=ExtResource("12_ljvyb")]
transform = Transform3D(1.6706831e-07, 1.1604034e-06, 32.595, 32.052925, -3.165528, 0, 3.8220775, 26.546934, -1.4247728e-06, -338.22726, 43.10347, 332.97617)
[node name="cloud10" parent="." unique_id=1831290273 instance=ExtResource("12_ljvyb")]
transform = Transform3D(1.6706831e-07, 1.1604034e-06, 32.595, 32.052925, -3.165528, 0, 3.8220775, 26.546934, -1.4247728e-06, -338.22726, -65.08275, 173.45772)
[node name="cloud11" parent="." unique_id=358903943 instance=ExtResource("12_ljvyb")]
transform = Transform3D(1.6706831e-07, 1.1604034e-06, 32.595, 32.052925, -3.165528, 0, 3.8220775, 26.546934, -1.4247728e-06, -338.22726, 178.66306, 202.52263)
[node name="cloud3" parent="." unique_id=624295053 instance=ExtResource("12_ljvyb")]
transform = Transform3D(-4.9415723e-07, 0, 11.305, 0, 11.305, 0, -11.305, 0, -4.9415723e-07, -214.15395, 53.997868, 215.32469)
[node name="cloud4" parent="." unique_id=1608207264 instance=ExtResource("12_ljvyb")]
transform = Transform3D(6.5393685e-08, 5.484083e-07, 12.635, 12.54612, -1.4960332, 0, 1.4960332, 12.54612, -5.522934e-07, -244.47647, 64.2054, 242.8301)
[node name="cloud5" parent="." unique_id=9405030 instance=ExtResource("12_ljvyb")]
transform = Transform3D(-7.8421215e-07, -4.957583e-07, 21.225, -11.341628, 17.940683, 0, -17.940683, -11.341628, -9.2777424e-07, -309.56183, 75.29676, 291.66757)
[connection signal="toggled" from="Control/Snow" to="Control" method="_on_snow_toggled"] [connection signal="toggled" from="Control/Snow" to="Control" method="_on_snow_toggled"]
[connection signal="toggled" from="Control/Rain" to="Control" method="_on_rain_toggled"] [connection signal="toggled" from="Control/Rain" to="Control" method="_on_rain_toggled"]
[connection signal="toggled" from="Control/Wind" to="Control" method="_on_wind_toggled"] [connection signal="toggled" from="Control/Wind" to="Control" method="_on_wind_toggled"]

View File

@@ -0,0 +1,125 @@
shader_type sky;
uniform vec3 sky_top_color : source_color;
uniform vec3 sky_horizon_color : source_color;
uniform float night_intensity : hint_range(0.0, 1.0) = 0.0;
group_uniforms Sky_Gradient_Control;
// Controlla l'altezza massima a cui arriva il colore del tramonto (0.0 = solo orizzonte, 1.0 = tutto il cielo)
uniform float horizon_height : hint_range(0.0, 1.0) = 0.1;
// Controlla la morbidezza della sfumatura tra tramonto e cielo scuro
uniform float horizon_blur : hint_range(0.0, 1.0) = 0.4;
group_uniforms Fixed_Stars;
uniform float star_density : hint_range(0.0, 2000.0) = 1500.0;
uniform float star_rarity : hint_range(100.0, 5000.0) = 2500.0;
uniform float star_scale_variation : hint_range(0.0, 1.0) = 0.5;
group_uniforms Shooting_Stars;
uniform sampler2D shooting_star_texture : hint_default_black, filter_linear_mipmap;
uniform vec4 shooting_star_color : source_color = vec4(1.0, 0.9, 0.7, 1.0);
uniform float shooting_star_density : hint_range(0.0, 1.0) = 0.3;
uniform float shooting_star_speed : hint_range(0.1, 3.0) = 1.0;
uniform float shooting_star_scale : hint_range(0.1, 20.0) = 5.0;
uniform float shooting_star_lifetime : hint_range(0.1, 1.0) = 0.5;
uniform float shooting_star_travel_dist : hint_range(1.0, 30.0) = 15.0;
// Utility di hashing per la generazione procedurale delle stelle
float hash(vec3 p) {
p = fract(p * 0.1031);
p += dot(p, p.yzx + 33.33);
return fract((p.x + p.y) * p.z);
}
vec2 hash2(vec3 p) {
float h1 = hash(p);
float h2 = hash(p + vec3(57.1, 13.7, 9.3));
return vec2(h1, h2);
}
vec3 hash3(float seed) {
vec3 p = fract(vec3(seed) * vec3(0.1031, 0.1030, 0.0973));
p += dot(p, p.yzx + 33.33);
return fract((p.xxy + p.yzz) * p.zyx);
}
void sky() {
float sky_v = clamp(EYEDIR.y, 0.0, 1.0);
// Applichiamo la compressione non lineare al gradiente dell'orizzonte
float gradient_high = clamp(horizon_height + horizon_blur, 0.001, 1.0);
float adjusted_sky_v = smoothstep(horizon_height, gradient_high, sky_v);
// Mix dei colori del cielo basato sul nuovo gradiente compresso
vec3 final_sky = mix(sky_horizon_color, sky_top_color, adjusted_sky_v);
// --- STELLE FISSE E CADENTI (Comparsa graduale con la notte) ---
float star_fade = smoothstep(0.3, 0.8, night_intensity);
if (star_fade > 0.0) {
// Fixed Stars
vec3 star_pos = EYEDIR * star_density;
vec2 rnd = hash2(star_pos);
float star_shape = pow(rnd.x, star_rarity);
float scale_factor = mix(1.0, (rnd.y * 0.8 + 0.2), star_scale_variation);
star_shape *= scale_factor;
star_shape *= pow(sky_v, 2.0); // Le stelle si concentrano in alto lontano dall'orizzonte
float twinkle_speed = TIME * (1.0 + rnd.y * 5.0);
float twinkle_phase = rnd.x * 100.0;
float twinkle = sin(twinkle_speed + twinkle_phase) * 0.25 + 0.75;
star_shape *= twinkle;
final_sky += star_shape * star_fade;
// Shooting Stars
if (shooting_star_density > 0.001) {
float time_scaled = TIME * shooting_star_speed;
float time_seed = floor(time_scaled);
float time_progress = fract(time_scaled);
vec3 shoot_rnd = hash3(time_seed);
if (shoot_rnd.z < shooting_star_density * star_fade) {
vec3 center = normalize(vec3(shoot_rnd.x * 2.0 - 1.0, shoot_rnd.y * 0.6 + 0.4, shoot_rnd.z * 2.0 - 1.0));
vec3 up = vec3(0.0, 1.0, 0.0);
vec3 tangent = normalize(cross(up, center));
vec3 bitangent = cross(center, tangent);
float random_angle = hash(vec3(time_seed)) * 6.28318;
float s = sin(random_angle);
float c = cos(random_angle);
vec3 flight_axis = tangent * c - bitangent * s;
vec3 side_axis = tangent * s + bitangent * c;
flight_axis.y *= 0.15;
flight_axis = normalize(flight_axis);
side_axis = normalize(cross(flight_axis, center));
float proj_x = dot(EYEDIR, side_axis);
float proj_y = dot(EYEDIR, flight_axis);
float proj_z = dot(EYEDIR, center);
if (proj_z > 0.0) {
vec2 uv = vec2(proj_x, -proj_y) * shooting_star_scale;
uv.y += (time_progress - (shooting_star_lifetime * 0.5)) * shooting_star_travel_dist;
uv.x += 0.5;
float bounds = step(0.0, uv.x) * step(uv.x, 1.0) * step(0.0, uv.y) * step(uv.y, 1.0);
if (bounds > 0.5) {
float star_tex = texture(shooting_star_texture, uv).r;
float f_in = smoothstep(0.0, shooting_star_lifetime * 0.2, time_progress);
float f_out = 1.0 - smoothstep(shooting_star_lifetime * 0.7, shooting_star_lifetime, time_progress);
float fade = f_in * f_out;
final_sky += star_tex * shooting_star_color.rgb * star_fade * fade;
}
}
}
}
}
COLOR = final_sky;
}

View File

@@ -0,0 +1 @@
uid://bneue3fq71vp8