create weather controller and daynight controller
This commit is contained in:
75
core/daynight/clouds_shadow.gdshader
Normal file
75
core/daynight/clouds_shadow.gdshader
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
shader_type spatial;
|
||||||
|
render_mode unshaded, depth_test_disabled, cull_disabled;
|
||||||
|
|
||||||
|
/*
|
||||||
|
uniform sampler2D depth_texture : hint_depth_texture, repeat_disable, filter_nearest;
|
||||||
|
uniform sampler2D noise_texture : repeat_enable, filter_linear;
|
||||||
|
|
||||||
|
uniform float cloud_scale : hint_range(0.001, 0.2) = 0.05;
|
||||||
|
uniform float cloud_speed : hint_range(0.0, 1.0) = 0.05;
|
||||||
|
uniform vec2 direction = vec2(1.0, 0.2);
|
||||||
|
uniform vec2 sun_angle = vec2(0.5, 0.5);
|
||||||
|
|
||||||
|
group_uniforms Cloud_Shape;
|
||||||
|
uniform float cloud_density : hint_range(0.0, 1.0) = 0.5;
|
||||||
|
uniform float center_sharpness : hint_range(0.0, 0.99) = 0.7;
|
||||||
|
|
||||||
|
group_uniforms Adjustment;
|
||||||
|
uniform vec3 shadow_color : source_color = vec3(0.0, 0.0, 0.0);
|
||||||
|
uniform float opacity_center : hint_range(0.0, 1.0) = 0.5;
|
||||||
|
uniform float opacity_edge : hint_range(0.0, 1.0) = 0.2;
|
||||||
|
|
||||||
|
group_uniforms Fade_Depth;
|
||||||
|
uniform float fade_start : hint_range(10.0, 1000.0) = 150.0;
|
||||||
|
uniform float fade_end : hint_range(50.0, 2000.0) = 300.0;
|
||||||
|
|
||||||
|
group_uniforms Fade_Height;
|
||||||
|
uniform float height_fade_start : hint_range(0.0, 500.0) = 10.0; // Inizia a svanire sopra i 10 metri
|
||||||
|
uniform float height_fade_end : hint_range(0.0, 1000.0) = 50.0; // Scompare del tutto a 50 metri di altezza
|
||||||
|
|
||||||
|
void vertex() {
|
||||||
|
POSITION = vec4(VERTEX.xy, 1.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
float depth = texture(depth_texture, SCREEN_UV).x;
|
||||||
|
|
||||||
|
if (depth >= 0.9999) {
|
||||||
|
ALPHA = 0.0;
|
||||||
|
} else {
|
||||||
|
vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
|
||||||
|
vec4 view_pos = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
|
||||||
|
view_pos /= view_pos.w;
|
||||||
|
vec4 world_pos = INV_VIEW_MATRIX * view_pos;
|
||||||
|
|
||||||
|
//Distance and height fade
|
||||||
|
float dist = length(view_pos.xyz);
|
||||||
|
float dist_fade = smoothstep(fade_end, fade_start, dist);
|
||||||
|
float height_fade = smoothstep(height_fade_end, height_fade_start, world_pos.y);
|
||||||
|
|
||||||
|
float final_fade = dist_fade * height_fade;
|
||||||
|
|
||||||
|
if (final_fade <= 0.001) {
|
||||||
|
ALPHA = 0.0;
|
||||||
|
} else {
|
||||||
|
vec2 projected_xz = world_pos.xz + (world_pos.y * sun_angle);
|
||||||
|
vec2 uv = projected_xz * cloud_scale;
|
||||||
|
uv += TIME * cloud_speed * vec2(-direction.x, direction.y);
|
||||||
|
|
||||||
|
float n = texture(noise_texture, uv).r;
|
||||||
|
|
||||||
|
if (n < (1.0 - cloud_density)) {
|
||||||
|
ALPHA = 0.0;
|
||||||
|
} else {
|
||||||
|
float internal_n = (n - (1.0 - cloud_density)) / cloud_density;
|
||||||
|
float is_center = step(center_sharpness, internal_n);
|
||||||
|
|
||||||
|
ALBEDO = shadow_color;
|
||||||
|
|
||||||
|
//shade color based on height
|
||||||
|
ALPHA = mix(opacity_edge, opacity_center, is_center) * final_fade;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
1
core/daynight/clouds_shadow.gdshader.uid
Normal file
1
core/daynight/clouds_shadow.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://7vwkfffa5vao
|
||||||
44
core/daynight/day_night_controller.gd
Normal file
44
core/daynight/day_night_controller.gd
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
@tool
|
||||||
|
class_name DayNightController
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
#Time duration in seconds for a day
|
||||||
|
@export var day_duration: float = 120.0
|
||||||
|
|
||||||
|
#starting time
|
||||||
|
@export_range(0.0, 1.0) var start_time: float = 0.0
|
||||||
|
|
||||||
|
#Multiply for debug
|
||||||
|
@export var time_scale: float = 1.0
|
||||||
|
|
||||||
|
@export var paused: bool = false
|
||||||
|
|
||||||
|
signal time_changed(time: float)
|
||||||
|
|
||||||
|
var current_time: float = 0.0
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
current_time = start_time
|
||||||
|
update_time(current_time)
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if paused or day_duration <= 0.0:
|
||||||
|
return
|
||||||
|
|
||||||
|
var increment: float = (delta * time_scale) / day_duration
|
||||||
|
current_time = wrapf(current_time + increment, 0.0, 1.0)
|
||||||
|
|
||||||
|
update_time(current_time)
|
||||||
|
|
||||||
|
func get_time_string() -> String:
|
||||||
|
var total_minutes: int = int(current_time * 1440.0) # 1440 = 24*60
|
||||||
|
var hours: int = total_minutes / 60
|
||||||
|
var minutes: int = total_minutes % 60
|
||||||
|
return "%02d:%02d" % [hours, minutes]
|
||||||
|
|
||||||
|
func set_time(t: float) -> void:
|
||||||
|
current_time = wrapf(t, 0.0, 1.0)
|
||||||
|
update_time(current_time)
|
||||||
|
|
||||||
|
func update_time(currtime: float) -> void:
|
||||||
|
emit_signal("time_changed", currtime)
|
||||||
1
core/daynight/day_night_controller.gd.uid
Normal file
1
core/daynight/day_night_controller.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bl05bf0o5tde8
|
||||||
121
core/daynight/edge_detection_compositor.gd
Normal file
121
core/daynight/edge_detection_compositor.gd
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
@tool
|
||||||
|
class_name EdgeDetectionCompositor
|
||||||
|
extends CompositorEffect
|
||||||
|
|
||||||
|
var rd: RenderingDevice
|
||||||
|
var shader: RID
|
||||||
|
var pipeline: RID
|
||||||
|
var parameter_storage_buffer := RID()
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
effect_callback_type = CompositorEffect.EFFECT_CALLBACK_TYPE_POST_OPAQUE
|
||||||
|
rd = RenderingServer.get_rendering_device()
|
||||||
|
RenderingServer.call_on_render_thread(_initialize_compute)
|
||||||
|
|
||||||
|
var data := PackedFloat32Array()
|
||||||
|
data.resize(20)
|
||||||
|
data.fill(0)
|
||||||
|
var parameter_data := data.to_byte_array()
|
||||||
|
parameter_storage_buffer = rd.storage_buffer_create(parameter_data.size(), parameter_data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# System notifications, we want to react on the notification that
|
||||||
|
# alerts us we are about to be destroyed.
|
||||||
|
func _notification(what: int) -> void:
|
||||||
|
if what == NOTIFICATION_PREDELETE:
|
||||||
|
if shader.is_valid():
|
||||||
|
# Freeing our shader will also free any dependents such as the pipeline!
|
||||||
|
rd.free_rid(shader)
|
||||||
|
|
||||||
|
|
||||||
|
#region Code in this region runs on the rendering thread.
|
||||||
|
# Compile our shader at initialization.
|
||||||
|
func _initialize_compute() -> void:
|
||||||
|
rd = RenderingServer.get_rendering_device()
|
||||||
|
if not rd:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Compile our shader.
|
||||||
|
var shader_file := load("res://core/daynight/edge_detection_shader.glsl")
|
||||||
|
var shader_spirv: RDShaderSPIRV = shader_file.get_spirv()
|
||||||
|
|
||||||
|
shader = rd.shader_create_from_spirv(shader_spirv)
|
||||||
|
if shader.is_valid():
|
||||||
|
pipeline = rd.compute_pipeline_create(shader)
|
||||||
|
|
||||||
|
|
||||||
|
# Called by the rendering thread every frame.
|
||||||
|
func _render_callback(p_effect_callback_type: EffectCallbackType, p_render_data: RenderData) -> void:
|
||||||
|
if rd and p_effect_callback_type == EFFECT_CALLBACK_TYPE_POST_OPAQUE and pipeline.is_valid():
|
||||||
|
# Get our render scene buffers object, this gives us access to our render buffers.
|
||||||
|
# Note that implementation differs per renderer hence the need for the cast.
|
||||||
|
var render_scene_buffers := p_render_data.get_render_scene_buffers()
|
||||||
|
if render_scene_buffers:
|
||||||
|
# Get our render size, this is the 3D render resolution!
|
||||||
|
var size = render_scene_buffers.get_internal_size()
|
||||||
|
if size.x == 0 and size.y == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
@warning_ignore("integer_division")
|
||||||
|
var x_groups : int = (size.x - 1.0) / 8.0 + 1.0
|
||||||
|
@warning_ignore("integer_division")
|
||||||
|
var y_groups : int = (size.y - 1.0) / 8.0 + 1.0
|
||||||
|
var z_groups := 1.0
|
||||||
|
|
||||||
|
|
||||||
|
# Loop through views just in case we're doing stereo rendering. No extra cost if this is mono.
|
||||||
|
var view_count: int = render_scene_buffers.get_view_count()
|
||||||
|
for view in view_count:
|
||||||
|
# Get the RID for our color image, we will be reading from and writing to it.
|
||||||
|
var input_image: RID = render_scene_buffers.get_color_layer(view)
|
||||||
|
var input_depth: RID = render_scene_buffers.get_depth_layer(view)
|
||||||
|
var input_normal: RID = render_scene_buffers.get_texture("forward_clustered","normal_roughness")
|
||||||
|
|
||||||
|
var texture_sampler = RDSamplerState.new()
|
||||||
|
texture_sampler = rd.sampler_create(texture_sampler)
|
||||||
|
|
||||||
|
|
||||||
|
var parameters := PackedFloat32Array([size.x, size.y, 0.0, 0.0])
|
||||||
|
var inv_proj_mat := p_render_data.get_render_scene_data().get_cam_projection().inverse()
|
||||||
|
var inv_proj_mat_array := PackedVector4Array([inv_proj_mat.x, inv_proj_mat.y, inv_proj_mat.z, inv_proj_mat.w])
|
||||||
|
|
||||||
|
var parameter_data := parameters.to_byte_array()
|
||||||
|
parameter_data.append_array(inv_proj_mat_array.to_byte_array())
|
||||||
|
rd.buffer_update(parameter_storage_buffer, 0, parameter_data.size(), parameter_data)
|
||||||
|
|
||||||
|
var uniform_parameter := RDUniform.new()
|
||||||
|
uniform_parameter.uniform_type = RenderingDevice.UNIFORM_TYPE_STORAGE_BUFFER
|
||||||
|
uniform_parameter.binding = 0
|
||||||
|
uniform_parameter.add_id(parameter_storage_buffer)
|
||||||
|
|
||||||
|
# Create a uniform set, this will be cached, the cache will be cleared if our viewports configuration is changed.
|
||||||
|
var uniform_color := RDUniform.new()
|
||||||
|
uniform_color.uniform_type = RenderingDevice.UNIFORM_TYPE_IMAGE
|
||||||
|
uniform_color.binding = 1
|
||||||
|
uniform_color.add_id(input_image)
|
||||||
|
|
||||||
|
var uniform_depth := RDUniform.new()
|
||||||
|
uniform_depth.uniform_type = RenderingDevice.UNIFORM_TYPE_SAMPLER_WITH_TEXTURE
|
||||||
|
uniform_depth.binding = 2
|
||||||
|
uniform_depth.add_id(texture_sampler)
|
||||||
|
uniform_depth.add_id(input_depth)
|
||||||
|
|
||||||
|
var uniform_normal := RDUniform.new()
|
||||||
|
uniform_normal.uniform_type = RenderingDevice.UNIFORM_TYPE_SAMPLER_WITH_TEXTURE
|
||||||
|
uniform_normal.binding = 3
|
||||||
|
uniform_normal.add_id(texture_sampler)
|
||||||
|
uniform_normal.add_id(input_normal)
|
||||||
|
|
||||||
|
var uniform_set := UniformSetCacheRD.get_cache(shader, 0, [uniform_parameter, uniform_color, uniform_depth, uniform_normal])
|
||||||
|
|
||||||
|
# Run our compute shader.
|
||||||
|
var compute_list := rd.compute_list_begin()
|
||||||
|
rd.compute_list_bind_compute_pipeline(compute_list, pipeline)
|
||||||
|
rd.compute_list_bind_uniform_set(compute_list, uniform_set, 0)
|
||||||
|
#rd.compute_list_set_push_constant(compute_list, push_constant.to_byte_array(), push_constant.size() * 4)
|
||||||
|
rd.compute_list_dispatch(compute_list, x_groups, y_groups, z_groups)
|
||||||
|
rd.compute_list_end()
|
||||||
|
rd.free_rid(texture_sampler)
|
||||||
|
#endregion
|
||||||
1
core/daynight/edge_detection_compositor.gd.uid
Normal file
1
core/daynight/edge_detection_compositor.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://brcimd12tx3dm
|
||||||
146
core/daynight/edge_detection_shader.glsl
Normal file
146
core/daynight/edge_detection_shader.glsl
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
#[compute]
|
||||||
|
#version 450
|
||||||
|
// FOR THIS PROJECT THE INNER LINES MADE WITH THE SCREEN NORMAL IS NOT BEING USED, BUT THE CODE IS STILL AVAILABLE IN THE FILE
|
||||||
|
|
||||||
|
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||||
|
|
||||||
|
layout(set = 0, binding = 0, std430) readonly buffer Params {
|
||||||
|
vec2 raster_size;
|
||||||
|
vec2 reserved;
|
||||||
|
mat4 inv_proj_mat;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
layout(rgba16f, set = 0, binding = 1) uniform image2D color_image;
|
||||||
|
layout(set = 0, binding = 2) uniform sampler2D depth_texture;
|
||||||
|
layout(set = 0, binding = 3) uniform sampler2D normal_texture;
|
||||||
|
|
||||||
|
|
||||||
|
const vec2 offset = vec2(0.0001);
|
||||||
|
const float line_highlight = 0.1;
|
||||||
|
const float line_shadow = 0.55;
|
||||||
|
|
||||||
|
|
||||||
|
float GetLinearDepth(vec2 uv, float mask) {
|
||||||
|
float raw_depth = texture(depth_texture, uv).r * mask;
|
||||||
|
vec3 ndc = vec3(uv * 2.0 - 1.0, raw_depth);
|
||||||
|
vec4 view = params.inv_proj_mat * vec4(ndc, 1.0);
|
||||||
|
view.xyz /= view.w;
|
||||||
|
return -view.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec4 GetNormal(vec2 uv, float mask){
|
||||||
|
vec4 normal = texture(normal_texture, uv + offset) * mask;
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec4 NormalRoughnessCompatibility(vec4 p_normal_roughness) {
|
||||||
|
float roughness = p_normal_roughness.w;
|
||||||
|
if (roughness > 0.5) {
|
||||||
|
roughness = 1.0 - roughness;
|
||||||
|
}
|
||||||
|
roughness /= (127.0 / 255.0);
|
||||||
|
vec4 normal_comp = vec4(normalize(p_normal_roughness.xyz * 2.0 - 1.0) * 0.5 + 0.5, roughness);
|
||||||
|
normal_comp = normal_comp * 2.0 - 1.0;
|
||||||
|
return normal_comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float NormalEdgeIndicator(vec3 normal_edge_bias, vec3 normal, vec3 neighbor_normal, float depth_difference){
|
||||||
|
float normal_difference = dot(normal - neighbor_normal, normal_edge_bias);
|
||||||
|
float normal_indicator = clamp(smoothstep(-.01, .01, normal_difference), 0.0, 1.0);
|
||||||
|
float depth_indicator = clamp(sign(depth_difference * .25 + .0025), 0.0, 1.0);
|
||||||
|
return (1.0 - dot(normal, neighbor_normal)) * depth_indicator * normal_indicator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec2 size = params.raster_size;
|
||||||
|
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
||||||
|
|
||||||
|
if (uv.x >= size.x || uv.y >= size.y) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 uv_normalized = uv / size;
|
||||||
|
vec2 texel_size = 1.0 / size.xy;
|
||||||
|
|
||||||
|
// 1. Leggiamo subito il canale Alpha (che in Godot contiene la Roughness codificata)
|
||||||
|
float raw_roughness = texture(normal_texture, uv_normalized + offset).a;
|
||||||
|
|
||||||
|
// --- INIZIO TRUCCO ESCLUSIONE ERBA ---
|
||||||
|
// Decodifichiamo la roughness esattamente come fa Godot (preso dalla tua funzione in alto)
|
||||||
|
float actual_roughness = raw_roughness;
|
||||||
|
if (actual_roughness > 0.5) {
|
||||||
|
actual_roughness = 1.0 - actual_roughness;
|
||||||
|
}
|
||||||
|
actual_roughness /= (127.0 / 255.0);
|
||||||
|
|
||||||
|
// Controlliamo se la roughness è quella "magica" dell'erba (0.02)
|
||||||
|
// Usiamo 0.005 come margine d'errore perché i float non sono mai precisi al 100%
|
||||||
|
if (abs(actual_roughness - 0.02) < 0.005) {
|
||||||
|
// Chiudiamo l'esecuzione per questo specifico pixel!
|
||||||
|
// Siccome non facciamo "imageStore", l'immagine mantiene i suoi colori
|
||||||
|
// originali senza che venga disegnata alcuna linea nera.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// --- FINE TRUCCO ---
|
||||||
|
|
||||||
|
// Da qui in poi, il codice prosegue normalmente solo per gli altri oggetti
|
||||||
|
|
||||||
|
// UV ofssets
|
||||||
|
vec2 uv_offsets[4];
|
||||||
|
uv_offsets[0] = uv_normalized + vec2(0.0, -1.0) * texel_size + offset;
|
||||||
|
uv_offsets[1] = uv_normalized + vec2(0.0, 1.0) * texel_size + offset;
|
||||||
|
uv_offsets[2] = uv_normalized + vec2(1.0, 0.0) * texel_size + offset;
|
||||||
|
uv_offsets[3] = uv_normalized + vec2(-1.0, 0.0) * texel_size + offset;
|
||||||
|
|
||||||
|
float mask = ceil(raw_roughness);
|
||||||
|
|
||||||
|
// Depth based Outlines
|
||||||
|
float depth_difference = 0.0;
|
||||||
|
float inv_depth_difference = 0.5;
|
||||||
|
float depth = GetLinearDepth(uv_normalized + offset, mask);
|
||||||
|
|
||||||
|
for (int i = 0; i < uv_offsets.length(); i++){
|
||||||
|
float dOff = GetLinearDepth(uv_offsets[i], mask);
|
||||||
|
depth_difference += clamp(dOff - depth, 0.0, 1.0);
|
||||||
|
inv_depth_difference += depth - dOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
inv_depth_difference = clamp(inv_depth_difference, 0.0, 1.0);
|
||||||
|
inv_depth_difference = clamp(smoothstep(0.9, 0.9, inv_depth_difference) * 10.0 , 0.0, 1.0);
|
||||||
|
depth_difference = smoothstep(0.45, 0.5, depth_difference);
|
||||||
|
|
||||||
|
|
||||||
|
// Normal based Innerlines
|
||||||
|
//float normal_difference = 0.0;
|
||||||
|
//vec3 normal_edge_bias = vec3(1.0, 1.0, 1.0);
|
||||||
|
//vec3 normal = NormalRoughnessCompatibility(GetNormal(uv_normalized, mask)).rgb;
|
||||||
|
|
||||||
|
//for (int i = 0; i < uv_offsets.length(); i++){
|
||||||
|
//vec3 n_offset = NormalRoughnessCompatibility(GetNormal(uv_offsets[i], mask)).rgb;
|
||||||
|
//normal_difference += NormalEdgeIndicator(normal_edge_bias, normal, n_offset, depth_difference);
|
||||||
|
//}
|
||||||
|
//normal_difference = smoothstep(0.2, 0.2, normal_difference);
|
||||||
|
//normal_difference = clamp(normal_difference - inv_depth_difference, 0.0, 1.0);
|
||||||
|
|
||||||
|
|
||||||
|
// Combine with screen render
|
||||||
|
|
||||||
|
vec4 color = imageLoad(color_image, uv);
|
||||||
|
|
||||||
|
vec3 outline = vec3(depth_difference);
|
||||||
|
//vec3 innerline = vec3(normal_difference) - outline;
|
||||||
|
//innerline = clamp(innerline, vec3(0.0), vec3(1.0));
|
||||||
|
//float line_mask = depth_difference + normal_difference;
|
||||||
|
float line_mask = depth_difference;
|
||||||
|
|
||||||
|
// Combine colors with lines
|
||||||
|
//vec4 color_with_lines = vec4(color.rgb + (innerline * line_highlight) - (color.rgb * outline * line_shadow), line_mask);
|
||||||
|
//vec4 color_with_lines = vec4(color.rgb - (color.rgb * outline * line_shadow), line_mask);
|
||||||
|
vec4 color_with_lines = mix(color, color * vec4(vec3(outline), 1.0) * vec4(vec3(line_shadow), 1.0), line_mask);
|
||||||
|
|
||||||
|
imageStore(color_image, uv, color_with_lines);
|
||||||
|
}
|
||||||
14
core/daynight/edge_detection_shader.glsl.import
Normal file
14
core/daynight/edge_detection_shader.glsl.import
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="glsl"
|
||||||
|
type="RDShaderFile"
|
||||||
|
uid="uid://cot8vqnj0h5by"
|
||||||
|
path="res://.godot/imported/edge_detection_shader.glsl-1a7158ec83d4a5f09c7cbc868285fb08.res"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://core/daynight/edge_detection_shader.glsl"
|
||||||
|
dest_files=["res://.godot/imported/edge_detection_shader.glsl-1a7158ec83d4a5f09c7cbc868285fb08.res"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
224
core/daynight/environment_management.tscn
Normal file
224
core/daynight/environment_management.tscn
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
[gd_scene format=3 uid="uid://cmuvmmp7xam4o"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://d27xbipk650kf" path="res://core/daynight/environment_manager.gd" id="1_wecen"]
|
||||||
|
[ext_resource type="Script" uid="uid://butda6k2tli3o" path="res://core/environment_config.gd" id="2_h6hjk"]
|
||||||
|
[ext_resource type="Shader" uid="uid://7vwkfffa5vao" path="res://core/daynight/clouds_shadow.gdshader" id="2_i3hjl"]
|
||||||
|
[ext_resource type="Shader" uid="uid://cq4vlcj8cuvge" path="res://core/daynight/fog.gdshader" id="2_r4tfj"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dyxvcf2l8ba5x" path="res://core/daynight/god_ray.tscn" id="5_411rw"]
|
||||||
|
[ext_resource type="Shader" uid="uid://bb1jjwe31fl7o" path="res://core/daynight/wind.gdshader" id="5_djqkg"]
|
||||||
|
[ext_resource type="Shader" uid="uid://b6l166fnyto24" path="res://core/daynight/fogoverlay.gdshader" id="7_i6gqj"]
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ruhh7"]
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("2_i3hjl")
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_r4tfj"]
|
||||||
|
transparency = 2
|
||||||
|
alpha_scissor_threshold = 0.0
|
||||||
|
alpha_antialiasing_mode = 0
|
||||||
|
disable_ambient_light = true
|
||||||
|
albedo_color = Color(0.8523133, 0.64268667, 0.43305993, 1)
|
||||||
|
billboard_mode = 3
|
||||||
|
particles_anim_h_frames = 1
|
||||||
|
particles_anim_v_frames = 1
|
||||||
|
particles_anim_loop = false
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_b5atu"]
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("2_r4tfj")
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_r4tfj"]
|
||||||
|
script = ExtResource("2_h6hjk")
|
||||||
|
material_fog = SubResource("ShaderMaterial_b5atu")
|
||||||
|
material_drops = SubResource("StandardMaterial3D_r4tfj")
|
||||||
|
material_clouds = SubResource("ShaderMaterial_ruhh7")
|
||||||
|
rain_fade_time = null
|
||||||
|
snow_fade_time = null
|
||||||
|
metadata/_custom_type_script = "uid://butda6k2tli3o"
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_i3hjl"]
|
||||||
|
offsets = PackedFloat32Array(0, 0.49019608, 1)
|
||||||
|
colors = PackedColorArray(0, 0, 0, 0, 1, 0.8980392, 0.3764706, 1, 1, 1, 1, 0)
|
||||||
|
|
||||||
|
[sub_resource type="GradientTexture1D" id="GradientTexture1D_djqkg"]
|
||||||
|
gradient = SubResource("Gradient_i3hjl")
|
||||||
|
|
||||||
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_i3hjl"]
|
||||||
|
emission_shape = 3
|
||||||
|
emission_box_extents = Vector3(20, 3, 20)
|
||||||
|
gravity = Vector3(0, 0.2, 0)
|
||||||
|
color_ramp = SubResource("GradientTexture1D_djqkg")
|
||||||
|
turbulence_enabled = true
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_djqkg"]
|
||||||
|
transparency = 1
|
||||||
|
vertex_color_use_as_albedo = true
|
||||||
|
emission_enabled = true
|
||||||
|
emission = Color(0.94509804, 0.827451, 0.09411765, 1)
|
||||||
|
emission_energy_multiplier = 16.0
|
||||||
|
billboard_mode = 3
|
||||||
|
particles_anim_h_frames = 1
|
||||||
|
particles_anim_v_frames = 1
|
||||||
|
particles_anim_loop = false
|
||||||
|
|
||||||
|
[sub_resource type="QuadMesh" id="QuadMesh_b5atu"]
|
||||||
|
material = SubResource("StandardMaterial3D_djqkg")
|
||||||
|
size = Vector2(0.1, 0.1)
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_djqkg"]
|
||||||
|
offsets = PackedFloat32Array(0, 0.491, 1)
|
||||||
|
colors = PackedColorArray(0, 0, 0, 0, 1, 1, 1, 0.7647059, 0, 0, 0, 0)
|
||||||
|
|
||||||
|
[sub_resource type="GradientTexture1D" id="GradientTexture1D_b5atu"]
|
||||||
|
gradient = SubResource("Gradient_djqkg")
|
||||||
|
|
||||||
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_ruhh7"]
|
||||||
|
lifetime_randomness = 0.5
|
||||||
|
emission_shape_scale = Vector3(5, 5, 5)
|
||||||
|
emission_shape = 3
|
||||||
|
emission_box_extents = Vector3(25, 5, 25)
|
||||||
|
direction = Vector3(0, 1, 0)
|
||||||
|
initial_velocity_min = 6.0
|
||||||
|
initial_velocity_max = 6.0
|
||||||
|
gravity = Vector3(0, 0, 0)
|
||||||
|
color_ramp = SubResource("GradientTexture1D_b5atu")
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id="Curve_b5atu"]
|
||||||
|
_data = [Vector2(0.00440529, 0.49729878), 0.0, 0.0, 0, 0, Vector2(0.4977974, 0.988911), 0.0, 0.0, 0, 0, Vector2(1, 0.50284326), 0.0, 0.0, 0, 0]
|
||||||
|
point_count = 3
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_cer0u"]
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("5_djqkg")
|
||||||
|
|
||||||
|
[sub_resource type="TubeTrailMesh" id="TubeTrailMesh_vo82p"]
|
||||||
|
material = SubResource("ShaderMaterial_cer0u")
|
||||||
|
custom_aabb = AABB(20, 20, 20, 0, 0, 0)
|
||||||
|
radius = 0.06
|
||||||
|
radial_steps = 16
|
||||||
|
section_length = 2.0
|
||||||
|
curve = SubResource("Curve_b5atu")
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_b5atu"]
|
||||||
|
offsets = PackedFloat32Array(0, 0.49019608, 1)
|
||||||
|
colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0)
|
||||||
|
|
||||||
|
[sub_resource type="GradientTexture1D" id="GradientTexture1D_ruhh7"]
|
||||||
|
gradient = SubResource("Gradient_b5atu")
|
||||||
|
|
||||||
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_cer0u"]
|
||||||
|
particle_flag_align_y = true
|
||||||
|
emission_shape_scale = Vector3(50, 10, 50)
|
||||||
|
emission_shape = 3
|
||||||
|
emission_box_extents = Vector3(1, 1, 1)
|
||||||
|
direction = Vector3(0, -1, 0)
|
||||||
|
spread = 0.0
|
||||||
|
initial_velocity_min = 2.5
|
||||||
|
initial_velocity_max = 5.0
|
||||||
|
gravity = Vector3(0, -2, 0)
|
||||||
|
scale_max = 10.0
|
||||||
|
color_ramp = SubResource("GradientTexture1D_ruhh7")
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_b5atu"]
|
||||||
|
transparency = 1
|
||||||
|
emission_enabled = true
|
||||||
|
emission = Color(1, 1, 1, 1)
|
||||||
|
emission_energy_multiplier = 0.2
|
||||||
|
billboard_mode = 3
|
||||||
|
particles_anim_h_frames = 1
|
||||||
|
particles_anim_v_frames = 1
|
||||||
|
particles_anim_loop = false
|
||||||
|
|
||||||
|
[sub_resource type="QuadMesh" id="QuadMesh_ruhh7"]
|
||||||
|
material = SubResource("StandardMaterial3D_b5atu")
|
||||||
|
size = Vector2(0.2, 0.2)
|
||||||
|
|
||||||
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_b5atu"]
|
||||||
|
particle_flag_align_y = true
|
||||||
|
emission_shape_scale = Vector3(50, 10, 50)
|
||||||
|
emission_shape = 3
|
||||||
|
emission_box_extents = Vector3(1, 1, 1)
|
||||||
|
direction = Vector3(0, -1, 0)
|
||||||
|
spread = 0.0
|
||||||
|
initial_velocity_min = 10.0
|
||||||
|
initial_velocity_max = 25.0
|
||||||
|
gravity = Vector3(0, -9, 0)
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ruhh7"]
|
||||||
|
transparency = 2
|
||||||
|
alpha_scissor_threshold = 0.5
|
||||||
|
alpha_antialiasing_mode = 0
|
||||||
|
disable_ambient_light = true
|
||||||
|
albedo_color = Color(0.4745098, 0.69411767, 0.7607843, 0.7411765)
|
||||||
|
billboard_mode = 3
|
||||||
|
particles_anim_h_frames = 1
|
||||||
|
particles_anim_v_frames = 1
|
||||||
|
particles_anim_loop = false
|
||||||
|
|
||||||
|
[sub_resource type="QuadMesh" id="QuadMesh_cer0u"]
|
||||||
|
material = SubResource("StandardMaterial3D_ruhh7")
|
||||||
|
size = Vector2(0.05, 0.8)
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ik86e"]
|
||||||
|
shader = ExtResource("7_i6gqj")
|
||||||
|
shader_parameter/fog_color = Color(0.85, 0.9, 0.95, 1)
|
||||||
|
shader_parameter/clear_center_radius = 0.39200001862
|
||||||
|
shader_parameter/edge_softness = 0.30900001397898
|
||||||
|
shader_parameter/max_opacity = 0.10000000475
|
||||||
|
|
||||||
|
[node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain")]
|
||||||
|
script = ExtResource("1_wecen")
|
||||||
|
environment_config = SubResource("Resource_r4tfj")
|
||||||
|
particles_wind = NodePath("Particles_Wind")
|
||||||
|
particles_snow = NodePath("Particles_Snow")
|
||||||
|
particles_fireflies = NodePath("Particles_Fireflies")
|
||||||
|
particles_rain = NodePath("Particles_Rain")
|
||||||
|
godray = ExtResource("5_411rw")
|
||||||
|
|
||||||
|
[node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133]
|
||||||
|
visible = false
|
||||||
|
emitting = false
|
||||||
|
amount = 60
|
||||||
|
lifetime = 4.0
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_i3hjl")
|
||||||
|
draw_pass_1 = SubResource("QuadMesh_b5atu")
|
||||||
|
|
||||||
|
[node name="Particles_Wind" type="GPUParticles3D" parent="." unique_id=1238214694]
|
||||||
|
transform = Transform3D(-0.9999756, -8.742171e-08, -0.0069812723, -0.0069812723, -3.051611e-10, 0.9999756, -8.742171e-08, 1, -3.051611e-10, 0, 4.573, 21.04)
|
||||||
|
visible = false
|
||||||
|
emitting = false
|
||||||
|
amount = 100
|
||||||
|
lifetime = 3.0
|
||||||
|
fixed_fps = 60
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_ruhh7")
|
||||||
|
draw_pass_1 = SubResource("TubeTrailMesh_vo82p")
|
||||||
|
|
||||||
|
[node name="Particles_Snow" type="GPUParticles3D" parent="." unique_id=1877039876]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 30, 0)
|
||||||
|
visible = false
|
||||||
|
emitting = false
|
||||||
|
amount = 2000
|
||||||
|
lifetime = 4.0
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_cer0u")
|
||||||
|
draw_pass_1 = SubResource("QuadMesh_ruhh7")
|
||||||
|
|
||||||
|
[node name="Particles_Rain" type="GPUParticles3D" parent="." unique_id=1543042897]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 30, 0)
|
||||||
|
visible = false
|
||||||
|
cast_shadow = 0
|
||||||
|
extra_cull_margin = 10.0
|
||||||
|
emitting = false
|
||||||
|
amount = 5000
|
||||||
|
lifetime = 1.5
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_b5atu")
|
||||||
|
draw_pass_1 = SubResource("QuadMesh_cer0u")
|
||||||
|
|
||||||
|
[node name="FogOverlay" type="ColorRect" parent="." unique_id=1694754918]
|
||||||
|
visible = false
|
||||||
|
material = SubResource("ShaderMaterial_ik86e")
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
64
core/daynight/environment_manager.gd
Normal file
64
core/daynight/environment_manager.gd
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
@tool
|
||||||
|
class_name EnvironmentManagerRoot
|
||||||
|
extends Node3D
|
||||||
|
|
||||||
|
@export var environment_config: EnvironmentConfig
|
||||||
|
|
||||||
|
@export_group("Particles")
|
||||||
|
@export var particles_wind: GPUParticles3D
|
||||||
|
@export var particles_snow: GPUParticles3D
|
||||||
|
@export var particles_fireflies: GPUParticles3D
|
||||||
|
@export var particles_rain: GPUParticles3D
|
||||||
|
@export var godray: PackedScene
|
||||||
|
@export var fog_overlay: ColorRect
|
||||||
|
|
||||||
|
#environment nodes
|
||||||
|
@onready var sun: DirectionalLight3D = $"../DirectionalLight3D"
|
||||||
|
@onready var environment: WorldEnvironment = $"../WorldEnvironment"
|
||||||
|
|
||||||
|
var day_night_controller: DayNightController
|
||||||
|
var weather_controller: WeatherController
|
||||||
|
|
||||||
|
var day_tween: Tween
|
||||||
|
var day_time: float = 0.0
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
|
||||||
|
if day_night_controller == null:
|
||||||
|
day_night_controller = DayNightController.new()
|
||||||
|
day_night_controller.name = "DayNightController"
|
||||||
|
day_night_controller.time_changed.connect(select_day_time)
|
||||||
|
add_child(day_night_controller)
|
||||||
|
|
||||||
|
if weather_controller == null:
|
||||||
|
weather_controller = WeatherController.new(
|
||||||
|
particles_wind,
|
||||||
|
particles_snow,
|
||||||
|
particles_fireflies,
|
||||||
|
particles_rain,
|
||||||
|
godray,
|
||||||
|
sun,
|
||||||
|
environment,
|
||||||
|
environment_config
|
||||||
|
)
|
||||||
|
weather_controller.name = "WeatherController"
|
||||||
|
add_child(weather_controller)
|
||||||
|
|
||||||
|
func select_day_time(normalized_time: float) -> void:
|
||||||
|
# Convert 0.0-1.0 normalized time to range used by atmosphere lerps
|
||||||
|
# morning (dawn→noon) = 1.0-2.0, afternoon/night (noon→midnight) = 2.0-3.0
|
||||||
|
if normalized_time < 0.5:
|
||||||
|
# 0.0→0.5 maps to 1.0→2.0 (morning to afternoon)
|
||||||
|
day_time = 1.0 + (normalized_time / 0.5)
|
||||||
|
else:
|
||||||
|
# 0.5→1.0 maps to 2.0→3.0 (afternoon to night)
|
||||||
|
day_time = 2.0 + ((normalized_time - 0.5) / 0.5)
|
||||||
|
|
||||||
|
if day_tween and day_tween.is_valid():
|
||||||
|
day_tween.kill()
|
||||||
|
day_tween = create_tween()
|
||||||
|
day_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||||
|
day_tween.tween_property(self, "day_time", day_time, 3.0)
|
||||||
|
|
||||||
|
if weather_controller:
|
||||||
|
weather_controller.day_time = day_time
|
||||||
1
core/daynight/environment_manager.gd.uid
Normal file
1
core/daynight/environment_manager.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://d27xbipk650kf
|
||||||
40
core/daynight/fog.gdshader
Normal file
40
core/daynight/fog.gdshader
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
shader_type spatial;
|
||||||
|
render_mode unshaded, depth_draw_never, cull_disabled, blend_mix;
|
||||||
|
/*
|
||||||
|
group_uniforms TextureCheck;
|
||||||
|
uniform sampler2D fog_noise : repeat_enable, filter_linear_mipmap;
|
||||||
|
uniform bool use_red_as_alpha = true;
|
||||||
|
|
||||||
|
group_uniforms Settings;
|
||||||
|
uniform vec4 fog_color : source_color = vec4(0.8, 0.85, 0.9, 0.5);
|
||||||
|
uniform vec2 scroll_speed = vec2(0.05, 0.01);
|
||||||
|
uniform vec2 texture_scale = vec2(1.0, 1.0);
|
||||||
|
|
||||||
|
group_uniforms Edges;
|
||||||
|
uniform float edge_softness_y : hint_range(0.0, 0.5) = 0.2;
|
||||||
|
uniform float edge_softness_x : hint_range(0.0, 0.5) = 0.1;
|
||||||
|
|
||||||
|
group_uniforms Illumination;
|
||||||
|
uniform float night_intensity : hint_range(0.0, 1.0) = 0.0;
|
||||||
|
uniform vec3 sun_color : source_color = vec3(1.0);
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
vec2 moving_uv = UV * texture_scale + (TIME * scroll_speed);
|
||||||
|
vec4 noise_tex = texture(fog_noise, moving_uv);
|
||||||
|
|
||||||
|
float noise_alpha = noise_tex.a;
|
||||||
|
if (use_red_as_alpha) {
|
||||||
|
noise_alpha = noise_tex.r;
|
||||||
|
}
|
||||||
|
|
||||||
|
float fade_y = smoothstep(0.0, edge_softness_y, UV.y) * smoothstep(1.0, 1.0 - edge_softness_y, UV.y);
|
||||||
|
float fade_x = smoothstep(0.0, edge_softness_x, UV.x) * smoothstep(1.0, 1.0 - edge_softness_x, UV.x);
|
||||||
|
float edge_mask = fade_x * fade_y;
|
||||||
|
|
||||||
|
//Paint fog with sun color
|
||||||
|
vec3 tinted_fog = fog_color.rgb * sun_color;
|
||||||
|
vec3 dark_fog = tinted_fog * 0.5;
|
||||||
|
ALBEDO = mix(tinted_fog, dark_fog, night_intensity);
|
||||||
|
|
||||||
|
ALPHA = fog_color.a * noise_alpha * edge_mask;
|
||||||
|
}*/
|
||||||
1
core/daynight/fog.gdshader.uid
Normal file
1
core/daynight/fog.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cq4vlcj8cuvge
|
||||||
29
core/daynight/fogoverlay.gdshader
Normal file
29
core/daynight/fogoverlay.gdshader
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
shader_type canvas_item;
|
||||||
|
|
||||||
|
// Colore della tua nebbia (scegli un colore che stia bene col tuo Skybox)
|
||||||
|
uniform vec4 fog_color : source_color = vec4(0.85, 0.9, 0.95, 1.0);
|
||||||
|
|
||||||
|
// Quanto è grande lo spazio pulito al centro per il treno
|
||||||
|
uniform float clear_center_radius : hint_range(0.0, 1.0) = 0.4;
|
||||||
|
|
||||||
|
// Quanto è morbida la sfumatura della nebbia verso i bordi
|
||||||
|
uniform float edge_softness : hint_range(0.01, 1.0) = 0.5;
|
||||||
|
|
||||||
|
// Opacità massima ai bordi estremi dello schermo
|
||||||
|
uniform float max_opacity : hint_range(0.0, 1.0) = 0.8;
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
// Calcola la distanza del pixel dal centro dello schermo (0.5, 0.5)
|
||||||
|
float dist_from_center = distance(SCREEN_UV, vec2(0.5));
|
||||||
|
|
||||||
|
// Crea una maschera morbida circolare
|
||||||
|
// Al centro (distanza < clear_center) sarà 0.0 (trasparente)
|
||||||
|
// Verso i bordi salirà dolcemente fino a 1.0 (opaco)
|
||||||
|
float fog_amount = smoothstep(clear_center_radius, clear_center_radius + edge_softness, dist_from_center);
|
||||||
|
|
||||||
|
// Moltiplica per l'opacità massima desiderata
|
||||||
|
fog_amount *= max_opacity;
|
||||||
|
|
||||||
|
// Applica il colore della nebbia solo dove serve
|
||||||
|
COLOR = vec4(fog_color.rgb, fog_color.a * fog_amount);
|
||||||
|
}
|
||||||
1
core/daynight/fogoverlay.gdshader.uid
Normal file
1
core/daynight/fogoverlay.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://b6l166fnyto24
|
||||||
37
core/daynight/god_ray.tscn
Normal file
37
core/daynight/god_ray.tscn
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dyxvcf2l8ba5x"]
|
||||||
|
|
||||||
|
[ext_resource type="Shader" uid="uid://caavljcth87so" path="res://core/daynight/godrays.gdshader" id="1_qxph4"]
|
||||||
|
[ext_resource type="Script" uid="uid://d0kgbg142recf" path="res://core/daynight/godrays.gd" id="2_v3yr3"]
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id="PlaneMesh_l01hg"]
|
||||||
|
size = Vector2(2, 10)
|
||||||
|
|
||||||
|
[sub_resource type="FastNoiseLite" id="FastNoiseLite_llprl"]
|
||||||
|
noise_type = 3
|
||||||
|
seed = 4
|
||||||
|
frequency = 0.0096
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_kavln"]
|
||||||
|
noise = SubResource("FastNoiseLite_llprl")
|
||||||
|
seamless = true
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_joqvq"]
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("1_qxph4")
|
||||||
|
shader_parameter/noise_texture = SubResource("NoiseTexture2D_kavln")
|
||||||
|
shader_parameter/ray_color = Color(1, 0.78431374, 0.27058825, 1)
|
||||||
|
shader_parameter/base_alpha = 1.0
|
||||||
|
shader_parameter/noise_stretching = 3.17200010317
|
||||||
|
shader_parameter/noise_scale = 1.0
|
||||||
|
shader_parameter/scrolling_speed = Vector2(0, 0.15)
|
||||||
|
shader_parameter/depth_softness = 1.0
|
||||||
|
shader_parameter/edge_fade_power = 2.0
|
||||||
|
shader_parameter/intensity_multiplier = 0.5330000253175
|
||||||
|
|
||||||
|
[node name="GodRay" type="Node3D" unique_id=1679441931]
|
||||||
|
|
||||||
|
[node name="GodRays" type="MeshInstance3D" parent="." unique_id=341055819]
|
||||||
|
transform = Transform3D(3.39, 0, 0, 0, -3.1996737e-07, 13, 0, -7.32, -5.68248e-07, 0, 0, 0)
|
||||||
|
mesh = SubResource("PlaneMesh_l01hg")
|
||||||
|
surface_material_override/0 = SubResource("ShaderMaterial_joqvq")
|
||||||
|
script = ExtResource("2_v3yr3")
|
||||||
35
core/daynight/godrays.gd
Normal file
35
core/daynight/godrays.gd
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
extends MeshInstance3D
|
||||||
|
|
||||||
|
@export_group("Animation")
|
||||||
|
@export var life_time: float = 8.0
|
||||||
|
@export var fade_in_time: float = 4.0
|
||||||
|
@export var max_base_alpha: float = 1.0
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var mat = get_active_material(0).duplicate()
|
||||||
|
set_surface_override_material(0, mat)
|
||||||
|
|
||||||
|
#add_to_group("camere")
|
||||||
|
|
||||||
|
#set alpha to 0 before first frame to avoid "pop"
|
||||||
|
mat.set_shader_parameter("base_alpha", 0.0)
|
||||||
|
|
||||||
|
animate_godray(mat)
|
||||||
|
|
||||||
|
func animate_godray(mat: ShaderMaterial):
|
||||||
|
var tween_alpha = create_tween()
|
||||||
|
tween_alpha.tween_property(mat, "shader_parameter/base_alpha", max_base_alpha, fade_in_time).from(0.0)
|
||||||
|
|
||||||
|
var tween_intensity = create_tween()
|
||||||
|
#tween from 1.0 to 2.0
|
||||||
|
tween_intensity.tween_property(mat, "shader_parameter/intensity_multiplier", 0.2, life_time * 0.3).from(1.0)
|
||||||
|
#tween to 0.5
|
||||||
|
tween_intensity.tween_property(mat, "shader_parameter/intensity_multiplier", 0.5, life_time * 0.3)
|
||||||
|
#tween to 0.0
|
||||||
|
tween_intensity.tween_property(mat, "shader_parameter/intensity_multiplier", 0.0, life_time * 0.4)
|
||||||
|
|
||||||
|
tween_intensity.tween_callback(queue_free)
|
||||||
|
|
||||||
|
var tween_edge = create_tween()
|
||||||
|
tween_edge.tween_property(mat, "shader_parameter/edge_fade_power", 0.5, life_time * 0.5).from(2.0)
|
||||||
|
tween_edge.tween_property(mat, "shader_parameter/edge_fade_power", 2.0, life_time * 0.5)
|
||||||
1
core/daynight/godrays.gd.uid
Normal file
1
core/daynight/godrays.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://d0kgbg142recf
|
||||||
43
core/daynight/godrays.gdshader
Normal file
43
core/daynight/godrays.gdshader
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
shader_type spatial;
|
||||||
|
render_mode blend_add, depth_draw_never, cull_disabled, unshaded;
|
||||||
|
|
||||||
|
uniform sampler2D depth_texture : hint_depth_texture, filter_nearest;
|
||||||
|
uniform sampler2D noise_texture : repeat_enable, filter_linear;
|
||||||
|
|
||||||
|
uniform vec3 ray_color : source_color = vec3(1.0, 0.9, 0.7);
|
||||||
|
uniform float base_alpha : hint_range(0.0, 1.0) = 0.5;
|
||||||
|
|
||||||
|
group_uniforms Noise_Stretching;
|
||||||
|
uniform float noise_stretching : hint_range(1.0, 50.0) = 20.0;
|
||||||
|
uniform float noise_scale : hint_range(0.1, 10.0) = 1.0;
|
||||||
|
uniform vec2 scrolling_speed = vec2(0.0, -0.1);
|
||||||
|
|
||||||
|
group_uniforms Fades;
|
||||||
|
uniform float depth_softness = 1.0;
|
||||||
|
uniform float edge_fade_power = 2.0;
|
||||||
|
|
||||||
|
uniform float intensity_multiplier : hint_range(0.0, 1.0) = 0.0;
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
vec2 stretchy_uv = UV * noise_scale;
|
||||||
|
|
||||||
|
stretchy_uv.x *= noise_stretching;
|
||||||
|
|
||||||
|
stretchy_uv += TIME * scrolling_speed;
|
||||||
|
|
||||||
|
float noise = texture(noise_texture, stretchy_uv).r;
|
||||||
|
|
||||||
|
float depth = textureLod(depth_texture, SCREEN_UV, 0.0).r;
|
||||||
|
vec4 upos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth, 1.0);
|
||||||
|
vec3 pixel_position = upos.xyz / upos.w;
|
||||||
|
float depth_fade = clamp((VERTEX.z - pixel_position.z) / depth_softness, 0.0, 1.0);
|
||||||
|
|
||||||
|
float edge_fade = smoothstep(0.0, 0.5, UV.x) * smoothstep(1.0, 0.5, UV.x);
|
||||||
|
edge_fade = pow(edge_fade, edge_fade_power); // Rende la sfumatura più o meno aggressiva
|
||||||
|
|
||||||
|
float vertical_fade = smoothstep(0.0, 0.2, UV.y) * smoothstep(1.0, 0.7, UV.y);
|
||||||
|
|
||||||
|
ALBEDO = ray_color;
|
||||||
|
|
||||||
|
ALPHA = noise * base_alpha * depth_fade * edge_fade * vertical_fade * intensity_multiplier;
|
||||||
|
}
|
||||||
1
core/daynight/godrays.gdshader.uid
Normal file
1
core/daynight/godrays.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://caavljcth87so
|
||||||
26
core/daynight/godrays.tres
Normal file
26
core/daynight/godrays.tres
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[gd_resource type="ShaderMaterial" format=3 uid="uid://cwbxvmtih5wsc"]
|
||||||
|
|
||||||
|
[ext_resource type="Shader" uid="uid://dkmdtejrbks8n" path="res://Shaders/godrays.gdshader" id="1_pbkwa"]
|
||||||
|
|
||||||
|
[sub_resource type="FastNoiseLite" id="FastNoiseLite_xa3jw"]
|
||||||
|
noise_type = 3
|
||||||
|
seed = 4
|
||||||
|
frequency = 0.0096
|
||||||
|
metadata/_preview_in_3d_space_ = true
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_eyx0r"]
|
||||||
|
noise = SubResource("FastNoiseLite_xa3jw")
|
||||||
|
seamless = true
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("1_pbkwa")
|
||||||
|
shader_parameter/noise_texture = SubResource("NoiseTexture2D_eyx0r")
|
||||||
|
shader_parameter/ray_color = Color(0.99999994, 0.782454, 0.2698755, 1)
|
||||||
|
shader_parameter/base_alpha = 1.0
|
||||||
|
shader_parameter/noise_stretching = 3.17200010317
|
||||||
|
shader_parameter/noise_scale = 1.0
|
||||||
|
shader_parameter/scrolling_speed = Vector2(0, 0.15)
|
||||||
|
shader_parameter/depth_softness = 1.0
|
||||||
|
shader_parameter/edge_fade_power = 2.0
|
||||||
|
shader_parameter/intensity_multiplier = 0.5330000253175
|
||||||
BIN
core/daynight/lighting_albedo.png
Normal file
BIN
core/daynight/lighting_albedo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
41
core/daynight/lighting_albedo.png.import
Normal file
41
core/daynight/lighting_albedo.png.import
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://csihlq3annhfu"
|
||||||
|
path.s3tc="res://.godot/imported/lighting_albedo.png-9b144a7d6c28cf34aed8366e91547306.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://core/daynight/lighting_albedo.png"
|
||||||
|
dest_files=["res://.godot/imported/lighting_albedo.png-9b144a7d6c28cf34aed8366e91547306.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=0
|
||||||
141
core/daynight/sky.gdshader
Normal file
141
core/daynight/sky.gdshader
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
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 Clouds;
|
||||||
|
uniform sampler2D cloud_noise : filter_linear_mipmap, repeat_enable;
|
||||||
|
uniform vec3 sun_color : source_color = vec3(1.0);
|
||||||
|
uniform vec4 cloud_center_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
uniform vec4 cloud_edge_color : source_color = vec4(0.8, 0.85, 0.9, 1.0);
|
||||||
|
uniform vec2 cloud_direction = vec2(0.5, 0.2);
|
||||||
|
uniform float cloud_speed : hint_range(0.0, 2.0) = 0.1;
|
||||||
|
uniform float cloud_scale = 0.5;
|
||||||
|
uniform float cloud_threshold : hint_range(0.0, 1.0) = 0.5;
|
||||||
|
uniform float cloud_edge_thickness : hint_range(0.0, 0.5) = 0.1;
|
||||||
|
uniform float cloud_edge_softness : hint_range(0.0, 0.5) = 0.05;
|
||||||
|
|
||||||
|
group_uniforms Fixed_Start;
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
vec3 final_sky = mix(sky_horizon_color, sky_top_color, sky_v);
|
||||||
|
|
||||||
|
if (night_intensity > 0.05) {
|
||||||
|
|
||||||
|
//Fixed Start
|
||||||
|
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, 4.0);
|
||||||
|
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 * night_intensity;
|
||||||
|
|
||||||
|
//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 * night_intensity) {
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (flight_axis.y > 0.0) {
|
||||||
|
flight_axis = -flight_axis;
|
||||||
|
side_axis = -side_axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 fade_in = smoothstep(0.0, shooting_star_lifetime * 0.2, time_progress);
|
||||||
|
float fade_out = 1.0 - smoothstep(shooting_star_lifetime * 0.7, shooting_star_lifetime, time_progress);
|
||||||
|
float fade = fade_in * fade_out;
|
||||||
|
final_sky += star_tex * shooting_star_color.rgb * night_intensity * fade;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clouds
|
||||||
|
vec2 cloud_uv = EYEDIR.xz / (EYEDIR.y + 0.5);
|
||||||
|
cloud_uv = cloud_uv * cloud_scale + (TIME * cloud_direction * cloud_speed);
|
||||||
|
float noise = texture(cloud_noise, cloud_uv).r;
|
||||||
|
float cloud_alpha = smoothstep(cloud_threshold, cloud_threshold + cloud_edge_softness, noise);
|
||||||
|
float color_gradient = smoothstep(cloud_threshold, cloud_threshold + cloud_edge_thickness, noise);
|
||||||
|
|
||||||
|
vec3 tinted_center = cloud_center_color.rgb * sun_color;
|
||||||
|
vec3 tinted_edge = cloud_edge_color.rgb * sun_color;
|
||||||
|
vec3 day_cloud_color = mix(tinted_edge, tinted_center, color_gradient);
|
||||||
|
|
||||||
|
vec3 night_cloud_color = sky_top_color * 0.4;
|
||||||
|
vec3 current_cloud_color = mix(day_cloud_color, night_cloud_color, night_intensity);
|
||||||
|
|
||||||
|
cloud_alpha *= smoothstep(0.1, 0.4, EYEDIR.y);
|
||||||
|
|
||||||
|
//Apply clouds to sky
|
||||||
|
final_sky = mix(final_sky, current_cloud_color, cloud_alpha);
|
||||||
|
|
||||||
|
COLOR = final_sky;
|
||||||
|
}
|
||||||
1
core/daynight/sky.gdshader.uid
Normal file
1
core/daynight/sky.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bneoex8xpmcm8
|
||||||
19
core/daynight/snow.gdshader
Normal file
19
core/daynight/snow.gdshader
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
shader_type spatial;
|
||||||
|
render_mode blend_mix, depth_draw_opaque;
|
||||||
|
|
||||||
|
global uniform float global_snow_amount;
|
||||||
|
|
||||||
|
uniform vec4 snow_color : source_color = vec4(0.95, 0.98, 1.0, 1.0);
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
vec3 world_normal = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
|
||||||
|
float up_dot = dot(world_normal, vec3(0.0, 1.0, 0.0));
|
||||||
|
float snow_mask = smoothstep(1.0 - global_snow_amount, 1.1 - global_snow_amount, up_dot);
|
||||||
|
snow_mask *= step(0.01, global_snow_amount);
|
||||||
|
|
||||||
|
ALBEDO = snow_color.rgb;
|
||||||
|
ALPHA = snow_mask;
|
||||||
|
|
||||||
|
ROUGHNESS = 0.3;
|
||||||
|
SPECULAR = 0.5;
|
||||||
|
}
|
||||||
1
core/daynight/snow.gdshader.uid
Normal file
1
core/daynight/snow.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cjd72g8cgjear
|
||||||
BIN
core/daynight/stars_albedo.png
Normal file
BIN
core/daynight/stars_albedo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
41
core/daynight/stars_albedo.png.import
Normal file
41
core/daynight/stars_albedo.png.import
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dest0qa7vaid0"
|
||||||
|
path.s3tc="res://.godot/imported/stars_albedo.png-ffa754833f21fee8e65e202b777e20a6.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://core/daynight/stars_albedo.png"
|
||||||
|
dest_files=["res://.godot/imported/stars_albedo.png-ffa754833f21fee8e65e202b777e20a6.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=0
|
||||||
452
core/daynight/weather_controller.gd
Normal file
452
core/daynight/weather_controller.gd
Normal file
@@ -0,0 +1,452 @@
|
|||||||
|
@tool
|
||||||
|
class_name WeatherController
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var particles_wind: GPUParticles3D
|
||||||
|
var particles_snow: GPUParticles3D
|
||||||
|
var particles_fireflies: GPUParticles3D
|
||||||
|
var particles_rain: GPUParticles3D
|
||||||
|
var godray: PackedScene
|
||||||
|
var fog_overlay: ColorRect
|
||||||
|
|
||||||
|
var sun: DirectionalLight3D
|
||||||
|
var environment: WorldEnvironment
|
||||||
|
var environment_config: EnvironmentConfig
|
||||||
|
|
||||||
|
var day_time: float = 0.0
|
||||||
|
|
||||||
|
var lightning_sprite: Sprite3D
|
||||||
|
var lightning_light = DirectionalLight3D.new();
|
||||||
|
var timer_next_lightning: float = 0.0
|
||||||
|
|
||||||
|
var is_raining: bool = false
|
||||||
|
var rain_intensity: float = 0.0
|
||||||
|
var rain_tween: Tween
|
||||||
|
|
||||||
|
var snow_tween: Tween
|
||||||
|
var snow_particles_tween: Tween
|
||||||
|
var is_snowing: bool = false
|
||||||
|
var is_snow_accumulated: bool = false
|
||||||
|
var actual_snow_amount: float = 0.0
|
||||||
|
|
||||||
|
var cold_tween: Tween
|
||||||
|
var is_windy: bool = false
|
||||||
|
var thereare_fireflies: bool = false
|
||||||
|
|
||||||
|
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||||
|
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
|
||||||
|
thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig) -> void:
|
||||||
|
particles_wind = wind
|
||||||
|
particles_snow = snow
|
||||||
|
particles_fireflies = fireflies
|
||||||
|
particles_rain = rain
|
||||||
|
godray = ray
|
||||||
|
sun = thesun
|
||||||
|
environment = theenvironment
|
||||||
|
environment_config = environmentconfig
|
||||||
|
|
||||||
|
set_rain()
|
||||||
|
|
||||||
|
set_fireflies()
|
||||||
|
|
||||||
|
set_wind()
|
||||||
|
|
||||||
|
set_snow()
|
||||||
|
|
||||||
|
set_lightning()
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
#connect events
|
||||||
|
UIEvents.toggle_rain.connect(toggle_rain)
|
||||||
|
UIEvents.toggle_snow.connect(toggle_snow)
|
||||||
|
UIEvents.toggle_wind.connect(toggle_wind)
|
||||||
|
UIEvents.toggle_fireflies.connect(toggle_fireflies)
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
var base_tint: Color
|
||||||
|
var base_sky_top: Color
|
||||||
|
var base_sky_horizon: Color
|
||||||
|
var base_fog_color: Color
|
||||||
|
var base_fog_density: float
|
||||||
|
var base_bloom: float
|
||||||
|
var base_exposure: float
|
||||||
|
var base_grad_top: Color
|
||||||
|
var base_grad_bot: Color
|
||||||
|
var base_grad_intensity: float
|
||||||
|
var base_rotation_sun: Vector3
|
||||||
|
|
||||||
|
var storm_is_active = is_raining and is_snowing
|
||||||
|
|
||||||
|
if storm_is_active:
|
||||||
|
rain_intensity = move_toward(rain_intensity, 1.0, delta * 0.5)
|
||||||
|
if is_raining:
|
||||||
|
timer_next_lightning -= delta
|
||||||
|
if timer_next_lightning <= 0.0:
|
||||||
|
start_lightning()
|
||||||
|
set_lightning_timer()
|
||||||
|
else:
|
||||||
|
rain_intensity = move_toward(rain_intensity, 0.0, delta * 0.5)
|
||||||
|
|
||||||
|
if environment_config.material_clouds:
|
||||||
|
var current_density = lerp(0.4, 1.0, rain_intensity)
|
||||||
|
environment_config.material_clouds.set_shader_parameter("cloud_density", current_density)
|
||||||
|
var current_sharpness = lerp(0.14, 0.0, rain_intensity)
|
||||||
|
environment_config.material_clouds.set_shader_parameter("center_sharpness", current_sharpness)
|
||||||
|
|
||||||
|
if day_time <= 2.0:
|
||||||
|
var t = day_time - 1.0
|
||||||
|
base_tint = environment_config.morning_color.lerp(environment_config.afternoon_color, t)
|
||||||
|
base_sky_top = environment_config.sky_top_morning.lerp(environment_config.sky_top_afternoon, t)
|
||||||
|
base_sky_horizon = environment_config.sky_horizon_morning.lerp(environment_config.sky_horizon_afternoon, t)
|
||||||
|
base_fog_color = environment_config.fog_color_morning.lerp(environment_config.fog_color_afternoon, t)
|
||||||
|
base_fog_density = lerp(environment_config.fog_density_morning, environment_config.fog_density_afternoon, t)
|
||||||
|
base_bloom = lerp(environment_config.glow_morning, environment_config.glow_afternoon, t)
|
||||||
|
base_exposure = lerp(environment_config.exposure_morning, environment_config.exposure_afternoon, t)
|
||||||
|
base_grad_top = environment_config.grad_top_morning.lerp(environment_config.grad_top_afternoon, t)
|
||||||
|
base_grad_bot = environment_config.grad_top_morning.lerp(environment_config.grad_bot_afternoon, t)
|
||||||
|
base_grad_intensity = lerp(environment_config.grad_intensity_morning, environment_config.grad_intensity_afternoon, t)
|
||||||
|
base_rotation_sun = environment_config.sun_rotation_morning.lerp(environment_config.sun_rotation_afternoon, t)
|
||||||
|
else:
|
||||||
|
var t = day_time - 2.0
|
||||||
|
base_tint = environment_config.afternoon_color.lerp(environment_config.night_color, t)
|
||||||
|
base_sky_top = environment_config.sky_top_afternoon.lerp(environment_config.sky_top_night, t)
|
||||||
|
base_sky_horizon = environment_config.sky_horizon_afternoon.lerp(environment_config.sky_horizon_night, t)
|
||||||
|
base_fog_color = environment_config.fog_color_afternoon.lerp(environment_config.fog_color_night, t)
|
||||||
|
base_fog_density = lerp(environment_config.fog_density_afternoon, environment_config.fog_density_night, t)
|
||||||
|
base_bloom = lerp(environment_config.glow_afternoon, environment_config.glow_night, t)
|
||||||
|
base_exposure = lerp(environment_config.exposure_afternoon, environment_config.exposure_night, t)
|
||||||
|
base_grad_top = environment_config.grad_top_afternoon.lerp(environment_config.grad_top_night, t)
|
||||||
|
base_grad_bot = environment_config.grad_bot_afternoon.lerp(environment_config.grad_bot_night, t)
|
||||||
|
base_grad_intensity = lerp(environment_config.grad_intensity_afternoon, environment_config.grad_intensity_night, t)
|
||||||
|
base_rotation_sun = environment_config.sun_rotation_afternoon.lerp(environment_config.sun_rotation_night, t)
|
||||||
|
|
||||||
|
var final_tint = base_tint.lerp(base_tint * environment_config.rain_mode_color, rain_intensity)
|
||||||
|
var final_sky_top = base_sky_top.lerp(base_sky_top * environment_config.rain_mode_color, rain_intensity)
|
||||||
|
var final_sky_horizon = base_sky_horizon.lerp(base_sky_horizon * environment_config.rain_mode_color, rain_intensity)
|
||||||
|
var final_fog_color = base_fog_color.lerp(base_fog_color * environment_config.rain_mode_color, rain_intensity)
|
||||||
|
var final_fog_density = lerp(base_fog_density, base_fog_density * 4.0, rain_intensity)
|
||||||
|
|
||||||
|
#Shader parameters for global trunk_shader
|
||||||
|
var final_grad_top = base_grad_top.lerp(base_grad_top * environment_config.rain_mode_color, rain_intensity)
|
||||||
|
var final_grad_bot = base_grad_bot.lerp(base_grad_bot * environment_config.rain_mode_color, rain_intensity)
|
||||||
|
|
||||||
|
RenderingServer.global_shader_parameter_set("global_gradient_color_top", final_grad_top)
|
||||||
|
RenderingServer.global_shader_parameter_set("global_gradient_color_bot", final_grad_bot)
|
||||||
|
RenderingServer.global_shader_parameter_set("global_gradient_intensity", base_grad_intensity)
|
||||||
|
|
||||||
|
var night_val = clamp(day_time - 2.0, 0.0, 1.0)
|
||||||
|
|
||||||
|
#Snow exposure compensation
|
||||||
|
var snow_light_attenuation = lerp(1.0, 0.55, actual_snow_amount * (1.0 - night_val))
|
||||||
|
var snow_glow_attenuation = lerp(1.0, 0.5, actual_snow_amount)
|
||||||
|
|
||||||
|
var final_bloom = lerp(base_bloom, base_bloom * 0.5, rain_intensity) * snow_glow_attenuation
|
||||||
|
|
||||||
|
# We calculate the final exposure by applying snow damping directly to the camera exposure
|
||||||
|
var final_esposizione = base_exposure * snow_light_attenuation
|
||||||
|
|
||||||
|
var reflected_color = Color(0.4, 0.5, 0.6, 1.0)
|
||||||
|
var drops_color = final_sky_horizon.lerp(reflected_color, 0.15)
|
||||||
|
drops_color = drops_color.lerp(drops_color * 0.4, night_val)
|
||||||
|
|
||||||
|
if environment_config.material_drops:
|
||||||
|
environment_config.material_drops.albedo_color = drops_color
|
||||||
|
|
||||||
|
if sun:
|
||||||
|
sun.light_color = final_tint
|
||||||
|
sun.rotation_degrees = base_rotation_sun
|
||||||
|
#var target_energy = lerp(1.0, night_light_energy, night_val)
|
||||||
|
|
||||||
|
# Sunlight scales normally based on weather/night (global exposure does the rest of the work)
|
||||||
|
#sun.light_energy = lerp(target_energy, target_energy * 0.4, rain_intensity)
|
||||||
|
|
||||||
|
if environment and environment.environment:
|
||||||
|
environment.environment.ambient_light_color = final_tint
|
||||||
|
|
||||||
|
# Apply fog
|
||||||
|
environment.environment.fog_enabled = true
|
||||||
|
environment.environment.fog_light_color = final_fog_color
|
||||||
|
environment.environment.fog_density = final_fog_density
|
||||||
|
|
||||||
|
# Apply glow
|
||||||
|
environment.environment.glow_enabled = true
|
||||||
|
environment.environment.glow_intensity = final_bloom
|
||||||
|
|
||||||
|
# Make sure the Tonemap Mode in the Environment is set to ACES or Filmic for best results!
|
||||||
|
environment.environment.tonemap_exposure = final_esposizione
|
||||||
|
|
||||||
|
var sky_mat = environment.environment.sky.sky_material as ShaderMaterial
|
||||||
|
if sky_mat:
|
||||||
|
sky_mat.set_shader_parameter("sky_top_color", final_sky_top)
|
||||||
|
sky_mat.set_shader_parameter("sky_horizon_color", final_sky_horizon)
|
||||||
|
sky_mat.set_shader_parameter("sun_color", final_tint)
|
||||||
|
sky_mat.set_shader_parameter("night_intensity", night_val)
|
||||||
|
|
||||||
|
if environment_config.material_fog:
|
||||||
|
environment_config.material_fog.set_shader_parameter("night_intensity", night_val)
|
||||||
|
environment_config.material_fog.set_shader_parameter("sun_color", final_tint)
|
||||||
|
|
||||||
|
var e_night = day_time >= 2.5
|
||||||
|
|
||||||
|
#if nodo_polvere:
|
||||||
|
#nodo_polvere.visible = (not storm_is_active and not e_night)
|
||||||
|
|
||||||
|
if particles_fireflies:
|
||||||
|
particles_fireflies.emitting = (not storm_is_active and e_night and thereare_fireflies)
|
||||||
|
|
||||||
|
if particles_wind:
|
||||||
|
particles_wind.emitting = (not storm_is_active and not e_night and is_windy)
|
||||||
|
|
||||||
|
#region fireflies
|
||||||
|
func toggle_fireflies(value: bool):
|
||||||
|
thereare_fireflies = value
|
||||||
|
|
||||||
|
#disable fireflies and set default values and materials
|
||||||
|
func set_fireflies():
|
||||||
|
if particles_fireflies:
|
||||||
|
particles_fireflies.visible = true
|
||||||
|
particles_fireflies.emitting = false
|
||||||
|
particles_fireflies.amount = environment_config.fireflies_amount
|
||||||
|
var proc_mat = particles_fireflies.process_material as ParticleProcessMaterial
|
||||||
|
if proc_mat:
|
||||||
|
proc_mat.emission_box_extents = Vector3(environment_config.fireflies_spawn_ray, environment_config.fireflies_spawn_height, environment_config.fireflies_spawn_ray)
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Wind
|
||||||
|
func toggle_wind(value: bool):
|
||||||
|
is_windy = value
|
||||||
|
|
||||||
|
#disable wind and set default values and materials
|
||||||
|
func set_wind():
|
||||||
|
if particles_wind:
|
||||||
|
particles_wind.visible = true
|
||||||
|
particles_wind.emitting = false
|
||||||
|
particles_wind.amount = environment_config.wind_amount
|
||||||
|
var proc_mat_wind = particles_wind.process_material as ParticleProcessMaterial
|
||||||
|
if proc_mat_wind:
|
||||||
|
proc_mat_wind.emission_box_extents = Vector3(environment_config.wind_spawn_ray, environment_config.wind_spawn_height, environment_config.wind_spawn_ray)
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Lightning
|
||||||
|
#set lightning
|
||||||
|
func set_lightning():
|
||||||
|
lightning_light.name = "Lightning Light"
|
||||||
|
lightning_light.transform = Transform3D(
|
||||||
|
Vector3(-0.6238797, -0.342596, 0.7024259), # asse X
|
||||||
|
Vector3(0.0, 0.89879405, 0.43837115), # asse Y
|
||||||
|
Vector3(-0.7815204, 0.27349085, -0.56073934), # asse Z
|
||||||
|
Vector3(0.0, 0.0, 30.411049) # origine
|
||||||
|
)
|
||||||
|
|
||||||
|
lightning_light.light_color = Color(0.8, 1.0, 1.0, 1.0)
|
||||||
|
lightning_light.light_energy = 0.0
|
||||||
|
lightning_light.shadow_enabled = true
|
||||||
|
add_child(lightning_light)
|
||||||
|
|
||||||
|
create_lightning_sprite()
|
||||||
|
set_lightning_timer()
|
||||||
|
|
||||||
|
func create_lightning_sprite():
|
||||||
|
lightning_sprite = Sprite3D.new()
|
||||||
|
lightning_sprite.name = "Lightning Sprite"
|
||||||
|
|
||||||
|
lightning_sprite.transform = Transform3D(
|
||||||
|
Basis(
|
||||||
|
Vector3(4, 0, 0),
|
||||||
|
Vector3(0, 7.32, 0),
|
||||||
|
Vector3(0, 0, 7.3)
|
||||||
|
),
|
||||||
|
Vector3(0, 17.324, 30.411049)
|
||||||
|
)
|
||||||
|
|
||||||
|
lightning_sprite.modulate = Color(1, 1, 1, 0)
|
||||||
|
lightning_sprite.billboard = BaseMaterial3D.BILLBOARD_ENABLED
|
||||||
|
lightning_sprite.alpha_cut = SpriteBase3D.ALPHA_CUT_DISCARD
|
||||||
|
|
||||||
|
#Add Texture
|
||||||
|
lightning_sprite.texture = load(environment_config.lightning_texture)
|
||||||
|
|
||||||
|
add_child(lightning_sprite)
|
||||||
|
|
||||||
|
#set next lightning timer
|
||||||
|
func set_lightning_timer():
|
||||||
|
timer_next_lightning = randf_range(environment_config.lightning_min_time, environment_config.lightning_max_time)
|
||||||
|
|
||||||
|
func start_lightning():
|
||||||
|
if lightning_light:
|
||||||
|
var tween_luce = create_tween()
|
||||||
|
lightning_light.light_energy = 5.0
|
||||||
|
|
||||||
|
tween_luce.tween_interval(0.05)
|
||||||
|
tween_luce.tween_callback(func(): lightning_light.light_energy = 0.0)
|
||||||
|
tween_luce.tween_interval(0.05)
|
||||||
|
tween_luce.tween_callback(func(): lightning_light.light_energy = 2.0)
|
||||||
|
tween_luce.tween_method(func(val): lightning_light.light_energy = val, 2.0, 0.0, 0.2)
|
||||||
|
|
||||||
|
var lightning_number = randi_range(environment_config.lightning_min, environment_config.lightning_max)
|
||||||
|
|
||||||
|
for i in lightning_number:
|
||||||
|
if lightning_sprite:
|
||||||
|
var angolo_casuale = randf() * TAU
|
||||||
|
var distanza = randf_range(10.0, 40.0)
|
||||||
|
|
||||||
|
lightning_sprite.position = Vector3(cos(angolo_casuale) * distanza, 10.0, sin(angolo_casuale) * distanza)
|
||||||
|
|
||||||
|
lightning_sprite.modulate = environment_config.lightning_color
|
||||||
|
lightning_sprite.modulate.a = 1.0
|
||||||
|
|
||||||
|
var s = randf_range(environment_config.lightning_scale_min, environment_config.lightning_scale_max)
|
||||||
|
lightning_sprite.scale = Vector3(s, s, s)
|
||||||
|
|
||||||
|
var tween_sprite = create_tween()
|
||||||
|
tween_sprite.tween_interval(0.2)
|
||||||
|
tween_sprite.tween_property(lightning_sprite, "modulate:a", 0.0, 0.4)
|
||||||
|
|
||||||
|
if lightning_number > 1:
|
||||||
|
await get_tree().create_timer(randf_range(0.05, 0.15)).timeout
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Rain
|
||||||
|
|
||||||
|
#disable rain
|
||||||
|
func set_rain():
|
||||||
|
if particles_rain:
|
||||||
|
particles_rain.visible = true
|
||||||
|
particles_rain.emitting = false
|
||||||
|
|
||||||
|
func toggle_rain(value: bool):
|
||||||
|
is_raining = value
|
||||||
|
|
||||||
|
if not particles_rain:
|
||||||
|
return
|
||||||
|
|
||||||
|
if is_raining and is_snowing:
|
||||||
|
toggle_snow(false)
|
||||||
|
|
||||||
|
if rain_tween and rain_tween.is_valid():
|
||||||
|
rain_tween.kill()
|
||||||
|
|
||||||
|
if is_raining:
|
||||||
|
particles_rain.amount_ratio = 0.0
|
||||||
|
particles_rain.emitting = true
|
||||||
|
rain_tween = create_tween()
|
||||||
|
rain_tween.tween_property(particles_rain, "amount_ratio", 1.0, environment_config.rain_fade_time)
|
||||||
|
else:
|
||||||
|
rain_tween = create_tween()
|
||||||
|
rain_tween.tween_property(particles_rain, "amount_ratio", 0.0, environment_config.rain_fade_time)
|
||||||
|
rain_tween.tween_callback(func():
|
||||||
|
particles_rain.emitting = false
|
||||||
|
trigger_after_rain())
|
||||||
|
|
||||||
|
func trigger_morning() -> void:
|
||||||
|
spawn_single_godray()
|
||||||
|
|
||||||
|
func trigger_after_rain() -> void:
|
||||||
|
if day_time < 2.5:
|
||||||
|
var count: int = randi_range(1, environment_config.godray_max_rain)
|
||||||
|
for i in count:
|
||||||
|
spawn_single_godray()
|
||||||
|
|
||||||
|
func spawn_single_godray() -> void:
|
||||||
|
var ray: Node3D = godray.instantiate()
|
||||||
|
get_tree().current_scene.add_child(ray)
|
||||||
|
|
||||||
|
var random_x: float = randf_range(-environment_config.godray_spawn_radius, environment_config.godray_spawn_radius)
|
||||||
|
var random_z: float = randf_range(-environment_config.godray_spawn_radius, environment_config.godray_spawn_radius)
|
||||||
|
|
||||||
|
#TODO: FLAVIO: fix global position using the camera position if needed
|
||||||
|
ray.global_position = Vector3(random_x, environment_config.godray_spawn_height, random_z)
|
||||||
|
ray.rotation_degrees = environment_config.godray_rotation_degrees
|
||||||
|
ray.scale = environment_config.godray_scale
|
||||||
|
|
||||||
|
var godray_tween: Tween = create_tween()
|
||||||
|
godray_tween.tween_interval(2.0)
|
||||||
|
godray_tween.tween_property(ray, "scale", Vector3.ZERO, 2.0).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_SINE)
|
||||||
|
godray_tween.tween_callback(ray.queue_free)
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Snow
|
||||||
|
|
||||||
|
func toggle_snow(value: bool):
|
||||||
|
is_snowing = value
|
||||||
|
|
||||||
|
if is_snowing and is_raining:
|
||||||
|
toggle_rain(false)
|
||||||
|
|
||||||
|
# Fade particelle neve
|
||||||
|
if particles_snow:
|
||||||
|
if snow_particles_tween and snow_particles_tween.is_valid():
|
||||||
|
snow_particles_tween.kill()
|
||||||
|
|
||||||
|
if is_snowing:
|
||||||
|
particles_snow.amount_ratio = 0.0
|
||||||
|
particles_snow.visible = true
|
||||||
|
particles_snow.emitting = true
|
||||||
|
snow_particles_tween = create_tween()
|
||||||
|
snow_particles_tween.tween_property(particles_snow, "amount_ratio", 1.0, environment_config.snow_fade_time)
|
||||||
|
else:
|
||||||
|
snow_particles_tween = create_tween()
|
||||||
|
snow_particles_tween.tween_property(particles_snow, "amount_ratio", 0.0, environment_config.snow_fade_time)
|
||||||
|
snow_particles_tween.tween_callback(func():
|
||||||
|
particles_snow.emitting = false)
|
||||||
|
|
||||||
|
# Accumulo neve sulle superfici
|
||||||
|
var target_snow: float = 1.0 if is_snowing else 0.0
|
||||||
|
if snow_tween and snow_tween.is_valid():
|
||||||
|
snow_tween.kill()
|
||||||
|
snow_tween = create_tween()
|
||||||
|
snow_tween.tween_method(set_snow_amount, actual_snow_amount, target_snow, environment_config.snow_transaction_time)
|
||||||
|
|
||||||
|
if fog_overlay and fog_overlay.material:
|
||||||
|
var target_opacity: float = 0.5 if is_snowing else 0.1
|
||||||
|
var target_radius: float = 0.350 if is_snowing else 0.465
|
||||||
|
|
||||||
|
if cold_tween and cold_tween.is_valid():
|
||||||
|
cold_tween.kill()
|
||||||
|
|
||||||
|
cold_tween = create_tween()
|
||||||
|
cold_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||||
|
cold_tween.set_parallel(true)
|
||||||
|
cold_tween.tween_property(fog_overlay.material, "shader_parameter/max_opacity", target_opacity, 4.0)
|
||||||
|
cold_tween.tween_property(fog_overlay.material, "shader_parameter/clear_center_radius", target_radius, 4.0)
|
||||||
|
|
||||||
|
#disable snow and set default values and shader
|
||||||
|
func set_snow(value: float = 0.0):
|
||||||
|
actual_snow_amount = value
|
||||||
|
RenderingServer.global_shader_parameter_set("global_snow_amount", value)
|
||||||
|
if particles_snow:
|
||||||
|
particles_snow.emitting = false
|
||||||
|
particles_snow.amount = environment_config.snow_amount
|
||||||
|
|
||||||
|
func set_snow_amount(value: float):
|
||||||
|
actual_snow_amount = value
|
||||||
|
RenderingServer.global_shader_parameter_set("global_snow_amount", value)
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#func _genera_evento_meteo_casuale() -> void:
|
||||||
|
#sto_cambiando_in_cinematic = true
|
||||||
|
#
|
||||||
|
#var scelta = randi() % 3
|
||||||
|
#
|
||||||
|
#if scelta == 0:
|
||||||
|
#var nuovo_orario = randi() % 3
|
||||||
|
#if menu_giornata:
|
||||||
|
#menu_giornata.selected = nuovo_orario
|
||||||
|
#_on_giornata_selezionata(nuovo_orario)
|
||||||
|
#
|
||||||
|
#elif scelta == 1:
|
||||||
|
#if not is_snowing:
|
||||||
|
#var piove = randf() > 0.5
|
||||||
|
#if bottone_pioggia:
|
||||||
|
#bottone_pioggia.set_pressed_no_signal(piove)
|
||||||
|
#_on_pioggia_toggled(piove)
|
||||||
|
#
|
||||||
|
#elif scelta == 2:
|
||||||
|
#if not is_snowing:
|
||||||
|
#if not is_raining:
|
||||||
|
#if bottone_pioggia:
|
||||||
|
#bottone_pioggia.set_pressed_no_signal(true)
|
||||||
|
#_on_pioggia_toggled(true)
|
||||||
|
#_scatena_fulmine()
|
||||||
|
|
||||||
1
core/daynight/weather_controller.gd.uid
Normal file
1
core/daynight/weather_controller.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://33hfgtk73je1
|
||||||
18
core/daynight/wind.gdshader
Normal file
18
core/daynight/wind.gdshader
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
shader_type spatial;
|
||||||
|
render_mode unshaded;
|
||||||
|
/*
|
||||||
|
uniform float time_scale = 3.0;
|
||||||
|
uniform float wave_amplitude = 0.5;
|
||||||
|
uniform float wave_frequency = 1.0;
|
||||||
|
|
||||||
|
void vertex() {
|
||||||
|
float random_seed_offset = INSTANCE_CUSTOM.x * 100.0;
|
||||||
|
float scaled_time = (TIME + random_seed_offset) * time_scale;
|
||||||
|
|
||||||
|
VERTEX.x += sin(VERTEX.y * wave_frequency + scaled_time) * wave_amplitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
ALBEDO = COLOR.rgb;
|
||||||
|
ALPHA = COLOR.a;
|
||||||
|
}*/
|
||||||
1
core/daynight/wind.gdshader.uid
Normal file
1
core/daynight/wind.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bb1jjwe31fl7o
|
||||||
99
core/environment_config.gd
Normal file
99
core/environment_config.gd
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
@tool
|
||||||
|
class_name EnvironmentConfig
|
||||||
|
extends Resource
|
||||||
|
|
||||||
|
@export_group("Directional Lights and Environment")
|
||||||
|
@export var morning_color: Color = Color(1.0, 0.9, 0.8, 1.0)
|
||||||
|
@export var afternoon_color: Color = Color(1.0, 0.6, 0.2, 1.0)
|
||||||
|
@export var night_color: Color = Color(0.1, 0.1, 0.3, 1.0)
|
||||||
|
|
||||||
|
@export_group("Sun Rotation")
|
||||||
|
@export var sun_rotation_morning: Vector3 = Vector3(-15.0, 45.0, 0.0)
|
||||||
|
@export var sun_rotation_afternoon: Vector3 = Vector3(-75.0, 10.0, 0.0)
|
||||||
|
@export var sun_rotation_night: Vector3 = Vector3(-35.0, -120.0, 0.0)
|
||||||
|
|
||||||
|
@export_group("General Exposition")
|
||||||
|
@export var exposure_morning: float = 1.0
|
||||||
|
@export var exposure_afternoon: float = 0.95
|
||||||
|
@export var exposure_night: float = 0.4
|
||||||
|
|
||||||
|
@export_group("Sky Colors - Top")
|
||||||
|
@export var sky_top_morning: Color = Color(0.35, 0.65, 0.9, 1.0)
|
||||||
|
@export var sky_top_afternoon: Color = Color(0.7, 0.45, 0.2, 1.0)
|
||||||
|
@export var sky_top_night: Color = Color(0.05, 0.05, 0.15, 1.0)
|
||||||
|
|
||||||
|
@export_group("Sky Color - Horizon")
|
||||||
|
@export var sky_horizon_morning: Color = Color(0.75, 0.85, 0.95, 1.0)
|
||||||
|
@export var sky_horizon_afternoon: Color = Color(0.95, 0.65, 0.35, 1.0)
|
||||||
|
@export var sky_horizon_night: Color = Color(0.15, 0.1, 0.25, 1.0)
|
||||||
|
|
||||||
|
@export_subgroup("Gradient - Top")
|
||||||
|
@export var grad_top_morning: Color = Color(0.8, 0.4, 0.2, 1.0)
|
||||||
|
@export var grad_top_afternoon: Color = Color(0.2, 0.3, 0.5, 1.0)
|
||||||
|
@export var grad_top_night: Color = Color(0.05, 0.05, 0.1, 1.0)
|
||||||
|
|
||||||
|
@export_subgroup("Gradient - Bottom")
|
||||||
|
@export var grad_bot_morning: Color = Color(0.5, 0.2, 0.1, 1.0)
|
||||||
|
@export var grad_bot_afternoon: Color = Color(0.1, 0.15, 0.25, 1.0)
|
||||||
|
@export var grad_bot_night: Color = Color(0.01, 0.01, 0.05, 1.0)
|
||||||
|
|
||||||
|
@export_subgroup("Gradient Intensity")
|
||||||
|
@export var grad_intensity_morning: float = 0.5
|
||||||
|
@export var grad_intensity_afternoon: float = 0.3
|
||||||
|
@export var grad_intensity_night: float = 0.8
|
||||||
|
|
||||||
|
@export_group("Fog")
|
||||||
|
@export var fog_color_morning: Color = Color(0.75, 0.85, 0.95, 1.0)
|
||||||
|
@export var fog_color_afternoon: Color = Color(0.95, 0.65, 0.35, 1.0)
|
||||||
|
@export var fog_color_night: Color = Color(0.15, 0.1, 0.25, 1.0)
|
||||||
|
@export var fog_density_morning: float = 0.005
|
||||||
|
@export var fog_density_afternoon: float = 0.002
|
||||||
|
@export var fog_density_night: float = 0.015
|
||||||
|
|
||||||
|
@export_group("Glow")
|
||||||
|
@export var glow_morning: float = 1.2
|
||||||
|
@export var glow_afternoon: float = 0.8
|
||||||
|
@export var glow_night: float = 2.0
|
||||||
|
|
||||||
|
@export_group("Environment Materials")
|
||||||
|
@export var material_fog: ShaderMaterial
|
||||||
|
@export var material_drops: StandardMaterial3D
|
||||||
|
@export var material_clouds: ShaderMaterial
|
||||||
|
|
||||||
|
@export_group("Rain")
|
||||||
|
@export var rain_mode_color: Color = Color(0.5, 0.6, 0.7, 1.0)
|
||||||
|
@export var rain_fade_time: float = 5.0
|
||||||
|
|
||||||
|
@export_group("Lightning and Thunders")
|
||||||
|
@export var lightning_min_time: float = 5.0
|
||||||
|
@export var lightning_max_time: float = 15.0
|
||||||
|
@export var lightning_color: Color = Color(1.0, 1.0, 0.8, 1.0)
|
||||||
|
@export var lightning_min: int = 1
|
||||||
|
@export var lightning_max: int = 3
|
||||||
|
@export var lightning_scale_min: float = 1.0
|
||||||
|
@export var lightning_scale_max: float = 3.0
|
||||||
|
@export var lightning_texture: String = "res://core/daynight/lighting_albedo.png"
|
||||||
|
@export var weather_event_interval: float = 8.0
|
||||||
|
|
||||||
|
@export_group("God Rays")
|
||||||
|
@export var godray_max_rain: int = 8
|
||||||
|
@export var godray_spawn_radius: float = 15.0
|
||||||
|
@export var godray_spawn_offset: Vector3 = Vector3(15.0, 5.0, -15.0)
|
||||||
|
@export var godray_rotation_degrees: Vector3 = Vector3(-45.0, 45.0, -30.0)
|
||||||
|
@export var godray_spawn_height: float = 5.0
|
||||||
|
@export var godray_scale: Vector3 = Vector3(2.0, 6.0, 2.0)
|
||||||
|
|
||||||
|
@export_group("Snow")
|
||||||
|
@export var snow_amount: int = 2000
|
||||||
|
@export var snow_transaction_time: float = 10.0
|
||||||
|
@export var snow_fade_time: float = 5.0
|
||||||
|
|
||||||
|
@export_group("Wind")
|
||||||
|
@export var wind_amount: int = 100
|
||||||
|
@export var wind_spawn_ray: float = 25.0
|
||||||
|
@export var wind_spawn_height: float = 5.0
|
||||||
|
|
||||||
|
@export_group("Fireflies")
|
||||||
|
@export var fireflies_amount: int = 60
|
||||||
|
@export var fireflies_spawn_ray: float = 20.0
|
||||||
|
@export var fireflies_spawn_height: float = 3.0
|
||||||
1
core/environment_config.gd.uid
Normal file
1
core/environment_config.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://butda6k2tli3o
|
||||||
7
core/environment_config_resource.tres
Normal file
7
core/environment_config_resource.tres
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[gd_resource type="Resource" script_class="DayNightConfig" format=3 uid="uid://bem36s551mtw8"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://butda6k2tli3o" path="res://resources/environment_config.gd" id="1_u2jy3"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_u2jy3")
|
||||||
|
metadata/_custom_type_script = "uid://butda6k2tli3o"
|
||||||
7
core/ui_events.gd
Normal file
7
core/ui_events.gd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
#Weather signals
|
||||||
|
signal toggle_rain(value: bool)
|
||||||
|
signal toggle_snow(value: bool)
|
||||||
|
signal toggle_wind(value: bool)
|
||||||
|
signal toggle_fireflies(value: bool)
|
||||||
1
core/ui_events.gd.uid
Normal file
1
core/ui_events.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dehu28iq27mbn
|
||||||
70
docs/museums/daynight/camera_3d.gd
Normal file
70
docs/museums/daynight/camera_3d.gd
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
extends Camera3D
|
||||||
|
|
||||||
|
@export_group("Movement")
|
||||||
|
@export var move_speed: float = 10.0
|
||||||
|
@export var fast_move_multiplier: float = 3.0
|
||||||
|
@export var move_smoothing: float = 10.0
|
||||||
|
|
||||||
|
@export_group("Look")
|
||||||
|
@export var mouse_sensitivity: float = 0.3
|
||||||
|
@export var invert_y: bool = false
|
||||||
|
|
||||||
|
var _velocity: Vector3 = Vector3.ZERO
|
||||||
|
var _yaw: float = 0.0 # Y rotation
|
||||||
|
var _pitch: float = 0.0 # X rotation
|
||||||
|
var _is_active: bool = false
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
#Current rotation
|
||||||
|
_yaw = rotation_degrees.y
|
||||||
|
_pitch = rotation_degrees.x
|
||||||
|
|
||||||
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
|
#Activate camera movement using mouse right button
|
||||||
|
if event is InputEventMouseButton:
|
||||||
|
if event.button_index == MOUSE_BUTTON_RIGHT:
|
||||||
|
_is_active = event.pressed
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED if _is_active else Input.MOUSE_MODE_VISIBLE
|
||||||
|
|
||||||
|
if event is InputEventMouseMotion and _is_active:
|
||||||
|
_yaw -= event.relative.x * mouse_sensitivity
|
||||||
|
var pitch_delta = event.relative.y * mouse_sensitivity
|
||||||
|
_pitch += pitch_delta if invert_y else -pitch_delta
|
||||||
|
_pitch = clamp(_pitch, -89.0, 89.0)
|
||||||
|
|
||||||
|
if event.is_action_pressed("ui_cancel"):
|
||||||
|
_is_active = false
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
rotation_degrees.y = _yaw
|
||||||
|
rotation_degrees.x = _pitch
|
||||||
|
|
||||||
|
if not _is_active:
|
||||||
|
_velocity = _velocity.lerp(Vector3.ZERO, move_smoothing * delta)
|
||||||
|
position += _velocity * delta
|
||||||
|
return
|
||||||
|
|
||||||
|
var input_dir := Vector3.ZERO
|
||||||
|
|
||||||
|
if Input.is_key_pressed(KEY_W) or Input.is_key_pressed(KEY_UP):
|
||||||
|
input_dir -= basis.z # avanti
|
||||||
|
if Input.is_key_pressed(KEY_S) or Input.is_key_pressed(KEY_DOWN):
|
||||||
|
input_dir += basis.z # indietro
|
||||||
|
if Input.is_key_pressed(KEY_A) or Input.is_key_pressed(KEY_LEFT):
|
||||||
|
input_dir -= basis.x # sinistra
|
||||||
|
if Input.is_key_pressed(KEY_D) or Input.is_key_pressed(KEY_RIGHT):
|
||||||
|
input_dir += basis.x # destra
|
||||||
|
if Input.is_key_pressed(KEY_E) or Input.is_key_pressed(KEY_PAGEUP):
|
||||||
|
input_dir += Vector3.UP # su (world space)
|
||||||
|
if Input.is_key_pressed(KEY_Q) or Input.is_key_pressed(KEY_PAGEDOWN):
|
||||||
|
input_dir += Vector3.DOWN # giù (world space)
|
||||||
|
|
||||||
|
if input_dir != Vector3.ZERO:
|
||||||
|
input_dir = input_dir.normalized()
|
||||||
|
|
||||||
|
var speed := move_speed * fast_move_multiplier if Input.is_key_pressed(KEY_SHIFT) else move_speed
|
||||||
|
|
||||||
|
var target_velocity := input_dir * speed
|
||||||
|
_velocity = _velocity.lerp(target_velocity, move_smoothing * delta)
|
||||||
|
position += _velocity * delta
|
||||||
1
docs/museums/daynight/camera_3d.gd.uid
Normal file
1
docs/museums/daynight/camera_3d.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://ccdd52apoh4ir
|
||||||
13
docs/museums/daynight/control.gd
Normal file
13
docs/museums/daynight/control.gd
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
func _on_rain_toggled(toggled_on: bool) -> void:
|
||||||
|
UIEvents.toggle_rain.emit(toggled_on)
|
||||||
|
|
||||||
|
func _on_snow_toggled(toggled_on: bool) -> void:
|
||||||
|
UIEvents.toggle_snow.emit(toggled_on)
|
||||||
|
|
||||||
|
func _on_wind_toggled(toggled_on: bool) -> void:
|
||||||
|
UIEvents.toggle_wind.emit(toggled_on)
|
||||||
|
|
||||||
|
func _on_fireflies_toggled(toggled_on: bool) -> void:
|
||||||
|
UIEvents.toggle_fireflies.emit(toggled_on)
|
||||||
1
docs/museums/daynight/control.gd.uid
Normal file
1
docs/museums/daynight/control.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cx2tlvxhvatj5
|
||||||
180
docs/museums/daynight/museum_daynight.tscn
Normal file
180
docs/museums/daynight/museum_daynight.tscn
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bjkhawylawqof"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cmuvmmp7xam4o" path="res://core/daynight/environment_management.tscn" id="1_daynt"]
|
||||||
|
[ext_resource type="Shader" uid="uid://bneoex8xpmcm8" path="res://core/daynight/sky.gdshader" id="3_jiovi"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dest0qa7vaid0" path="res://core/daynight/stars_albedo.png" id="4_abyor"]
|
||||||
|
[ext_resource type="Script" uid="uid://brcimd12tx3dm" path="res://core/daynight/edge_detection_compositor.gd" id="5_jgh18"]
|
||||||
|
[ext_resource type="Script" uid="uid://cx2tlvxhvatj5" path="res://docs/museums/daynight/control.gd" id="6_q52t1"]
|
||||||
|
[ext_resource type="Script" uid="uid://ccdd52apoh4ir" path="res://docs/museums/daynight/camera_3d.gd" id="7_p2t1d"]
|
||||||
|
|
||||||
|
[sub_resource type="FastNoiseLite" id="FastNoiseLite_jiovi"]
|
||||||
|
fractal_lacunarity = 1.915
|
||||||
|
fractal_gain = 0.53
|
||||||
|
fractal_weighted_strength = 0.35
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_abyor"]
|
||||||
|
noise = SubResource("FastNoiseLite_jiovi")
|
||||||
|
seamless = true
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_abyor"]
|
||||||
|
shader = ExtResource("3_jiovi")
|
||||||
|
shader_parameter/sky_top_color = Color(0, 0.84999996, 1.5999999, 1)
|
||||||
|
shader_parameter/sky_horizon_color = Color(0.55, 1.0500001, 1.55, 1)
|
||||||
|
shader_parameter/night_intensity = 0.0
|
||||||
|
shader_parameter/cloud_noise = SubResource("NoiseTexture2D_abyor")
|
||||||
|
shader_parameter/sun_color = Color(1, 1.1999999, 1.4000001, 1)
|
||||||
|
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_rarity = 2500.0
|
||||||
|
shader_parameter/star_scale_variation = 0.5
|
||||||
|
shader_parameter/shooting_star_texture = ExtResource("4_abyor")
|
||||||
|
shader_parameter/shooting_star_color = Color(0.38431373, 0.61960787, 0.23137255, 1)
|
||||||
|
shader_parameter/shooting_star_density = 1.0
|
||||||
|
shader_parameter/shooting_star_speed = 1.0
|
||||||
|
shader_parameter/shooting_star_scale = 5.0
|
||||||
|
shader_parameter/shooting_star_lifetime = 0.5
|
||||||
|
shader_parameter/shooting_star_travel_dist = 15.0
|
||||||
|
|
||||||
|
[sub_resource type="Sky" id="Sky_50i22"]
|
||||||
|
sky_material = SubResource("ShaderMaterial_abyor")
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id="Environment_icuhg"]
|
||||||
|
background_mode = 2
|
||||||
|
sky = SubResource("Sky_50i22")
|
||||||
|
ambient_light_color = Color(1, 1.1999999, 1.4000001, 1)
|
||||||
|
tonemap_exposure = 1.05
|
||||||
|
ssao_enabled = true
|
||||||
|
ssao_radius = 0.5
|
||||||
|
ssao_intensity = 14.0
|
||||||
|
ssao_detail = 0.0
|
||||||
|
ssil_enabled = true
|
||||||
|
glow_enabled = true
|
||||||
|
glow_levels/4 = 1.0
|
||||||
|
glow_intensity = 1.6
|
||||||
|
glow_strength = 0.65
|
||||||
|
glow_bloom = 1.0
|
||||||
|
fog_enabled = true
|
||||||
|
fog_mode = 1
|
||||||
|
fog_light_color = Color(0.55, 1.0500001, 1.55, 1)
|
||||||
|
fog_density = 0.008
|
||||||
|
fog_sky_affect = 0.0
|
||||||
|
|
||||||
|
[sub_resource type="CompositorEffect" id="CompositorEffect_q52t1"]
|
||||||
|
resource_local_to_scene = false
|
||||||
|
resource_name = ""
|
||||||
|
enabled = true
|
||||||
|
effect_callback_type = 1
|
||||||
|
access_resolved_color = false
|
||||||
|
access_resolved_depth = false
|
||||||
|
needs_motion_vectors = false
|
||||||
|
needs_normal_roughness = false
|
||||||
|
script = ExtResource("5_jgh18")
|
||||||
|
metadata/_custom_type_script = "uid://brcimd12tx3dm"
|
||||||
|
|
||||||
|
[sub_resource type="Compositor" id="Compositor_jbfcc"]
|
||||||
|
compositor_effects = Array[CompositorEffect]([SubResource("CompositorEffect_q52t1")])
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_p2t1d"]
|
||||||
|
albedo_color = Color(0.135, 0.45, 0.18224995, 1)
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_p2t1d"]
|
||||||
|
size = Vector3(200, 0.08, 200)
|
||||||
|
|
||||||
|
[node name="Museum" type="Node3D" unique_id=1411616506]
|
||||||
|
|
||||||
|
[node name="DayNight" parent="." unique_id=1578787116 instance=ExtResource("1_daynt")]
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=6398994]
|
||||||
|
environment = SubResource("Environment_icuhg")
|
||||||
|
compositor = SubResource("Compositor_jbfcc")
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=565189502]
|
||||||
|
transform = Transform3D(0.17364818, 0.69636416, 0.69636416, 0, 0.7071067, -0.7071067, -0.9848075, 0.12278782, 0.12278782, 0, 0, 0)
|
||||||
|
light_color = Color(1, 1.1999999, 1.4000001, 1)
|
||||||
|
light_indirect_energy = 0.0
|
||||||
|
light_volumetric_fog_energy = 0.0
|
||||||
|
shadow_enabled = true
|
||||||
|
shadow_bias = 0.2
|
||||||
|
shadow_normal_bias = 0.0
|
||||||
|
shadow_opacity = 0.97
|
||||||
|
shadow_blur = 0.4
|
||||||
|
directional_shadow_mode = 0
|
||||||
|
directional_shadow_fade_start = 0.9
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="." unique_id=1032167802]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
script = ExtResource("6_q52t1")
|
||||||
|
|
||||||
|
[node name="Snow" type="CheckButton" parent="Control" unique_id=1267493556]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 21.0
|
||||||
|
offset_top = 13.0
|
||||||
|
offset_right = 109.0
|
||||||
|
offset_bottom = 44.0
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
|
||||||
|
text = "Snow"
|
||||||
|
|
||||||
|
[node name="Rain" type="CheckButton" parent="Control" unique_id=1387886007]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 21.0
|
||||||
|
offset_top = 41.0
|
||||||
|
offset_right = 109.0
|
||||||
|
offset_bottom = 72.0
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
|
||||||
|
text = "Rain"
|
||||||
|
|
||||||
|
[node name="Wind" type="CheckButton" parent="Control" unique_id=1160113828]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 21.0
|
||||||
|
offset_top = 71.0
|
||||||
|
offset_right = 109.0
|
||||||
|
offset_bottom = 102.0
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
|
||||||
|
text = "Wind"
|
||||||
|
|
||||||
|
[node name="Fireflies" type="CheckButton" parent="Control" unique_id=1177089839]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 21.0
|
||||||
|
offset_top = 100.0
|
||||||
|
offset_right = 130.0
|
||||||
|
offset_bottom = 131.0
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
|
||||||
|
text = "Fireflies"
|
||||||
|
|
||||||
|
[node name="Camera3D" type="Camera3D" parent="." unique_id=1893906598]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.99452555, -0.10449375, 0, 0.10449375, 0.99452555, 0.48949432, 25.39013, 0)
|
||||||
|
script = ExtResource("7_p2t1d")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1335123628]
|
||||||
|
material_override = SubResource("StandardMaterial3D_p2t1d")
|
||||||
|
mesh = SubResource("BoxMesh_p2t1d")
|
||||||
|
|
||||||
|
[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/Wind" to="Control" method="_on_wind_toggled"]
|
||||||
151
docs/museums/daynight/museum_daynight.tscn12025044106.tmp
Normal file
151
docs/museums/daynight/museum_daynight.tscn12025044106.tmp
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bjkhawylawqof"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://d27xbipk650kf" path="res://core/daynight/day_night.gd" id="1_o8twy"]
|
||||||
|
[ext_resource type="Script" uid="uid://butda6k2tli3o" path="res://core/environment_config.gd" id="2_ecsq1"]
|
||||||
|
[ext_resource type="Shader" uid="uid://bneoex8xpmcm8" path="res://core/daynight/sky.gdshader" id="3_jiovi"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dest0qa7vaid0" path="res://core/daynight/stars_albedo.png" id="4_abyor"]
|
||||||
|
[ext_resource type="Script" uid="uid://brcimd12tx3dm" path="res://core/daynight/edge_detection_compositor.gd" id="5_jgh18"]
|
||||||
|
[ext_resource type="Script" uid="uid://cx2tlvxhvatj5" path="res://docs/museums/daynight/control.gd" id="6_q52t1"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_50i22"]
|
||||||
|
script = ExtResource("2_ecsq1")
|
||||||
|
metadata/_custom_type_script = "uid://butda6k2tli3o"
|
||||||
|
|
||||||
|
[sub_resource type="FastNoiseLite" id="FastNoiseLite_jiovi"]
|
||||||
|
fractal_lacunarity = 1.915
|
||||||
|
fractal_gain = 0.53
|
||||||
|
fractal_weighted_strength = 0.35
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_abyor"]
|
||||||
|
noise = SubResource("FastNoiseLite_jiovi")
|
||||||
|
seamless = true
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_abyor"]
|
||||||
|
shader = ExtResource("3_jiovi")
|
||||||
|
shader_parameter/sky_top_color = Color(0.35, 0.65, 0.9, 1)
|
||||||
|
shader_parameter/sky_horizon_color = Color(0.75, 0.85, 0.95, 1)
|
||||||
|
shader_parameter/night_intensity = 0.0
|
||||||
|
shader_parameter/cloud_noise = SubResource("NoiseTexture2D_abyor")
|
||||||
|
shader_parameter/sun_color = Color(1, 0.9, 0.8, 1)
|
||||||
|
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_rarity = 2500.0
|
||||||
|
shader_parameter/star_scale_variation = 0.5
|
||||||
|
shader_parameter/shooting_star_texture = ExtResource("4_abyor")
|
||||||
|
shader_parameter/shooting_star_color = Color(0.38431373, 0.61960787, 0.23137255, 1)
|
||||||
|
shader_parameter/shooting_star_density = 1.0
|
||||||
|
shader_parameter/shooting_star_speed = 1.0
|
||||||
|
shader_parameter/shooting_star_scale = 5.0
|
||||||
|
shader_parameter/shooting_star_lifetime = 0.5
|
||||||
|
shader_parameter/shooting_star_travel_dist = 15.0
|
||||||
|
|
||||||
|
[sub_resource type="Sky" id="Sky_50i22"]
|
||||||
|
sky_material = SubResource("ShaderMaterial_abyor")
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id="Environment_icuhg"]
|
||||||
|
background_mode = 2
|
||||||
|
sky = SubResource("Sky_50i22")
|
||||||
|
ambient_light_color = Color(1, 0.9, 0.8, 1)
|
||||||
|
ssao_enabled = true
|
||||||
|
ssao_radius = 0.5
|
||||||
|
ssao_intensity = 14.0
|
||||||
|
ssao_detail = 0.0
|
||||||
|
ssil_enabled = true
|
||||||
|
glow_enabled = true
|
||||||
|
glow_levels/4 = 1.0
|
||||||
|
glow_intensity = 1.2
|
||||||
|
glow_strength = 0.65
|
||||||
|
glow_bloom = 1.0
|
||||||
|
fog_enabled = true
|
||||||
|
fog_mode = 1
|
||||||
|
fog_light_color = Color(0.75, 0.85, 0.95, 1)
|
||||||
|
fog_density = 0.005
|
||||||
|
fog_sky_affect = 0.0
|
||||||
|
|
||||||
|
[sub_resource type="CompositorEffect" id="CompositorEffect_q52t1"]
|
||||||
|
resource_local_to_scene = false
|
||||||
|
resource_name = ""
|
||||||
|
enabled = true
|
||||||
|
effect_callback_type = 1
|
||||||
|
access_resolved_color = false
|
||||||
|
access_resolved_depth = false
|
||||||
|
needs_motion_vectors = false
|
||||||
|
needs_normal_roughness = false
|
||||||
|
script = ExtResource("5_jgh18")
|
||||||
|
metadata/_custom_type_script = "uid://brcimd12tx3dm"
|
||||||
|
|
||||||
|
[sub_resource type="Compositor" id="Compositor_jbfcc"]
|
||||||
|
compositor_effects = Array[CompositorEffect]([SubResource("CompositorEffect_q52t1")])
|
||||||
|
|
||||||
|
[node name="Museum" type="Node3D" unique_id=1411616506]
|
||||||
|
|
||||||
|
[node name="DayNightRoot" type="Node3D" parent="." unique_id=1578787116]
|
||||||
|
script = ExtResource("1_o8twy")
|
||||||
|
environment_config = SubResource("Resource_50i22")
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=6398994]
|
||||||
|
environment = SubResource("Environment_icuhg")
|
||||||
|
compositor = SubResource("Compositor_jbfcc")
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=565189502]
|
||||||
|
transform = Transform3D(0.70710677, -0.1830127, 0.68301266, 0, 0.9659258, 0.25881904, -0.70710677, -0.1830127, 0.68301266, 0, 0, 0)
|
||||||
|
light_color = Color(1, 0.9, 0.8, 1)
|
||||||
|
light_indirect_energy = 0.0
|
||||||
|
light_volumetric_fog_energy = 0.0
|
||||||
|
shadow_enabled = true
|
||||||
|
shadow_bias = 0.2
|
||||||
|
shadow_normal_bias = 0.0
|
||||||
|
shadow_opacity = 0.97
|
||||||
|
shadow_blur = 0.4
|
||||||
|
directional_shadow_mode = 0
|
||||||
|
directional_shadow_fade_start = 0.9
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="." unique_id=1032167802]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
script = ExtResource("6_q52t1")
|
||||||
|
|
||||||
|
[node name="Snow" type="CheckButton" parent="Control" unique_id=1267493556]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 21.0
|
||||||
|
offset_top = 13.0
|
||||||
|
offset_right = 109.0
|
||||||
|
offset_bottom = 44.0
|
||||||
|
text = "Snow"
|
||||||
|
|
||||||
|
[node name="Rain" type="CheckButton" parent="Control" unique_id=1387886007]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 21.0
|
||||||
|
offset_top = 41.0
|
||||||
|
offset_right = 109.0
|
||||||
|
offset_bottom = 72.0
|
||||||
|
text = "Rain"
|
||||||
|
|
||||||
|
[node name="Wind" type="CheckButton" parent="Control" unique_id=1160113828]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 21.0
|
||||||
|
offset_top = 71.0
|
||||||
|
offset_right = 109.0
|
||||||
|
offset_bottom = 102.0
|
||||||
|
text = "Wind"
|
||||||
|
|
||||||
|
[node name="Fireflies" type="CheckButton" parent="Control" unique_id=1177089839]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 21.0
|
||||||
|
offset_top = 100.0
|
||||||
|
offset_right = 130.0
|
||||||
|
offset_bottom = 131.0
|
||||||
|
text = "Fireflies"
|
||||||
|
|
||||||
|
[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/Wind" to="Control" method="_on_wind_toggled"]
|
||||||
@@ -11,13 +11,46 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="tgcc"
|
config/name="tgcc"
|
||||||
|
run/main_scene="uid://bjkhawylawqof"
|
||||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
UIEvents="*uid://dehu28iq27mbn"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1920
|
||||||
|
window/size/viewport_height=1080
|
||||||
|
window/stretch/mode="canvas_items"
|
||||||
|
window/stretch/aspect="expand"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
3d/physics_engine="Jolt Physics"
|
3d/physics_engine="Jolt Physics"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
textures/canvas_textures/default_texture_filter=2
|
||||||
rendering_device/driver.windows="d3d12"
|
rendering_device/driver.windows="d3d12"
|
||||||
|
anti_aliasing/quality/use_taa=true
|
||||||
|
|
||||||
|
[shader_globals]
|
||||||
|
|
||||||
|
global_gradient_color_bot={
|
||||||
|
"type": "color",
|
||||||
|
"value": Color(0, 0, 0, 1)
|
||||||
|
}
|
||||||
|
global_gradient_color_top={
|
||||||
|
"type": "color",
|
||||||
|
"value": Color(0, 0, 0, 1)
|
||||||
|
}
|
||||||
|
global_gradient_intensity={
|
||||||
|
"type": "float",
|
||||||
|
"value": 0.0
|
||||||
|
}
|
||||||
|
global_snow_amount={
|
||||||
|
"type": "float",
|
||||||
|
"value": 0.0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user