add rain to materials
This commit is contained in:
@@ -31,8 +31,8 @@ func _ready() -> void:
|
|||||||
|
|
||||||
#set noise texture 2d to materials in special group
|
#set noise texture 2d to materials in special group
|
||||||
ApplyWindNoiseToMaterials()
|
ApplyWindNoiseToMaterials()
|
||||||
#set snow shader to materials in special group
|
#set weather overlay (snow + rain) to materials in special group
|
||||||
ApplySnowShaderToMaterials()
|
ApplyWeatherShaderToMaterials()
|
||||||
|
|
||||||
if day_night_controller == null:
|
if day_night_controller == null:
|
||||||
day_night_controller = DayNightController.new(
|
day_night_controller = DayNightController.new(
|
||||||
@@ -67,18 +67,17 @@ func ApplyWindNoiseToMaterials():
|
|||||||
if node is GeometryInstance3D:
|
if node is GeometryInstance3D:
|
||||||
node.material_override.set_shader_parameter("wind_noise", noise_tex)
|
node.material_override.set_shader_parameter("wind_noise", noise_tex)
|
||||||
|
|
||||||
func ApplySnowShaderToMaterials():
|
func ApplyWeatherShaderToMaterials():
|
||||||
var snow_shader = preload("res://core/daynight/snow_overlay.tres")
|
var weather_shader = preload("res://core/daynight/weather_overlay.tres")
|
||||||
|
|
||||||
#apply to node and childs
|
for node in get_tree().get_nodes_in_group("weather_materials"):
|
||||||
for node in get_tree().get_nodes_in_group("snow_materials"):
|
|
||||||
if node is GeometryInstance3D:
|
if node is GeometryInstance3D:
|
||||||
node.material_overlay = snow_shader
|
node.material_overlay = weather_shader
|
||||||
else:
|
else:
|
||||||
for child in node.get_children():
|
for child in node.get_children():
|
||||||
if child is GeometryInstance3D:
|
if child is GeometryInstance3D:
|
||||||
child.material_overlay = snow_shader
|
child.material_overlay = weather_shader
|
||||||
|
|
||||||
func select_day_time(normalized_time: float) -> void:
|
func select_day_time(normalized_time: float) -> void:
|
||||||
# 0.0→0.25 = alba: day_time 1.0→2.0 (night colors → morning colors)
|
# 0.0→0.25 = alba: day_time 1.0→2.0 (night colors → morning colors)
|
||||||
# 0.25→0.5 = giorno: day_time 2.0→2.0 (stays morning/afternoon)
|
# 0.25→0.5 = giorno: day_time 2.0→2.0 (stays morning/afternoon)
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
shader_type canvas_item;
|
|
||||||
|
|
||||||
uniform vec4 fog_color : source_color = vec4(0.85, 0.9, 0.95, 1.0);
|
|
||||||
uniform float clear_center_radius : hint_range(0.0, 1.0) = 0.4;
|
|
||||||
uniform float edge_softness : hint_range(0.01, 1.0) = 0.5;
|
|
||||||
uniform float max_opacity : hint_range(0.0, 1.0) = 0.8;
|
|
||||||
|
|
||||||
void fragment() {
|
|
||||||
float dist_from_center = distance(SCREEN_UV, vec2(0.5));
|
|
||||||
float fog_amount = smoothstep(clear_center_radius, clear_center_radius + edge_softness, dist_from_center);
|
|
||||||
|
|
||||||
fog_amount *= max_opacity;
|
|
||||||
|
|
||||||
COLOR = vec4(fog_color.rgb, fog_color.a * fog_amount);
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://b6l166fnyto24
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
shader_type spatial;
|
|
||||||
render_mode blend_mix, depth_draw_never;
|
|
||||||
|
|
||||||
global uniform float global_snow_start_time = -1.0;
|
|
||||||
global uniform float global_snow_accumulation_speed = 0.1;
|
|
||||||
global uniform float global_snow_melt_time = -1.0;
|
|
||||||
global uniform float global_snow_melt_speed = 0.1;
|
|
||||||
global uniform float global_snow_threshold = 0.5;
|
|
||||||
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
|
|
||||||
|
|
||||||
uniform sampler2D noise_texture : filter_linear_mipmap, repeat_enable;
|
|
||||||
uniform float noise_scale : hint_range(0.01, 1.0) = 0.15;
|
|
||||||
uniform float noise_edge_softness : hint_range(0.01, 0.5) = 0.2;
|
|
||||||
uniform float roughness_variation : hint_range(0.0, 0.3) = 0.15;
|
|
||||||
uniform float color_variation : hint_range(0.0, 0.15) = 0.05;
|
|
||||||
|
|
||||||
void fragment() {
|
|
||||||
float snow_amount = 0.0;
|
|
||||||
if (global_snow_start_time >= 0.0) {
|
|
||||||
snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (global_snow_melt_time >= 0.0) {
|
|
||||||
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
|
|
||||||
snow_amount = snow_amount * (1.0 - melt);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
|
||||||
vec3 world_normal = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
|
|
||||||
float facing_up = clamp(world_normal.y, 0.0, 1.0);
|
|
||||||
|
|
||||||
float noise_val = texture(noise_texture, world_pos.xz * noise_scale).r;
|
|
||||||
|
|
||||||
float edge = smoothstep(
|
|
||||||
global_snow_threshold - noise_edge_softness,
|
|
||||||
global_snow_threshold + noise_edge_softness,
|
|
||||||
facing_up + (noise_val - 0.5) * 0.4
|
|
||||||
);
|
|
||||||
float coverage = smoothstep(0.0, 0.6, noise_val + snow_amount - 0.4);
|
|
||||||
float snow_factor = edge * coverage * snow_amount;
|
|
||||||
|
|
||||||
float shade = mix(-color_variation, color_variation, noise_val);
|
|
||||||
vec3 snow_albedo = clamp(global_snow_color.rgb + vec3(shade), 0.0, 1.0);
|
|
||||||
|
|
||||||
float snow_roughness = mix(0.15 - roughness_variation, 0.15 + roughness_variation, noise_val);
|
|
||||||
|
|
||||||
ALBEDO = snow_albedo;
|
|
||||||
ROUGHNESS = snow_roughness;
|
|
||||||
METALLIC = 0.0;
|
|
||||||
ALPHA = snow_factor;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://cjd72g8cgjear
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://bn4onuaqif5q3"]
|
|
||||||
|
|
||||||
[ext_resource type="Shader" uid="uid://cjd72g8cgjear" path="res://core/daynight/snow.gdshader" id="1_vwtmf"]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
render_priority = 0
|
|
||||||
shader = ExtResource("1_vwtmf")
|
|
||||||
shader_parameter/noise_scale = 0.15
|
|
||||||
shader_parameter/noise_edge_softness = 0.2
|
|
||||||
shader_parameter/roughness_variation = 0.15
|
|
||||||
shader_parameter/color_variation = 0.05
|
|
||||||
@@ -73,7 +73,7 @@ func _ready() -> void:
|
|||||||
UIEvents.toggle_wind.connect(toggle_wind)
|
UIEvents.toggle_wind.connect(toggle_wind)
|
||||||
UIEvents.toggle_fireflies.connect(toggle_fireflies)
|
UIEvents.toggle_fireflies.connect(toggle_fireflies)
|
||||||
UIEvents.toggle_storm.connect(toggle_storm)
|
UIEvents.toggle_storm.connect(toggle_storm)
|
||||||
UIEvents.toggle_fog_overlay.connect(toggle_fog_overlay)
|
#UIEvents.toggle_fog_overlay.connect(toggle_fog_overlay)
|
||||||
UIEvents.toggle_dust.connect(toggle_dust)
|
UIEvents.toggle_dust.connect(toggle_dust)
|
||||||
UIEvents.toggle_blur.connect(toggle_blur)
|
UIEvents.toggle_blur.connect(toggle_blur)
|
||||||
UIEvents.toggle_shadows.connect(toggle_shadows)
|
UIEvents.toggle_shadows.connect(toggle_shadows)
|
||||||
@@ -94,9 +94,9 @@ func _process(delta: float) -> void:
|
|||||||
var base_grad_intensity: float
|
var base_grad_intensity: float
|
||||||
var base_rotation_sun: Vector3
|
var base_rotation_sun: Vector3
|
||||||
|
|
||||||
if is_storm:
|
if is_raining:
|
||||||
rain_intensity = move_toward(rain_intensity, 1.0, delta * 0.5)
|
rain_intensity = move_toward(rain_intensity, 1.0, delta * 0.5)
|
||||||
if is_raining:
|
if is_storm:
|
||||||
timer_next_lightning -= delta
|
timer_next_lightning -= delta
|
||||||
if timer_next_lightning <= 0.0:
|
if timer_next_lightning <= 0.0:
|
||||||
start_lightning()
|
start_lightning()
|
||||||
@@ -104,6 +104,8 @@ func _process(delta: float) -> void:
|
|||||||
else:
|
else:
|
||||||
rain_intensity = move_toward(rain_intensity, 0.0, delta * 0.5)
|
rain_intensity = move_toward(rain_intensity, 0.0, delta * 0.5)
|
||||||
|
|
||||||
|
RenderingServer.global_shader_parameter_set("global_rain_intensity", rain_intensity)
|
||||||
|
|
||||||
if day_time <= 2.0:
|
if day_time <= 2.0:
|
||||||
var t = day_time - 1.0
|
var t = day_time - 1.0
|
||||||
base_tint = environment_config.morning_color.lerp(environment_config.afternoon_color, t)
|
base_tint = environment_config.morning_color.lerp(environment_config.afternoon_color, t)
|
||||||
@@ -509,9 +511,6 @@ func start_snow_melt() -> void:
|
|||||||
|
|
||||||
#region Post-Process
|
#region Post-Process
|
||||||
|
|
||||||
func toggle_fog_overlay(value: bool) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
func toggle_dust(value: bool) -> void:
|
func toggle_dust(value: bool) -> void:
|
||||||
if environment_dust:
|
if environment_dust:
|
||||||
environment_dust.visible = value
|
environment_dust.visible = value
|
||||||
|
|||||||
141
core/daynight/weather_overlay.gdshader
Normal file
141
core/daynight/weather_overlay.gdshader
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
shader_type spatial;
|
||||||
|
render_mode blend_mix, depth_draw_never;
|
||||||
|
|
||||||
|
// --- Snow globals ---
|
||||||
|
global uniform float global_snow_start_time = -1.0;
|
||||||
|
global uniform float global_snow_accumulation_speed = 0.1;
|
||||||
|
global uniform float global_snow_melt_time = -1.0;
|
||||||
|
global uniform float global_snow_melt_speed = 0.1;
|
||||||
|
global uniform float global_snow_threshold = 0.5;
|
||||||
|
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
|
||||||
|
|
||||||
|
// --- Rain globals ---
|
||||||
|
global uniform float global_rain_intensity;
|
||||||
|
|
||||||
|
// --- Shared ---
|
||||||
|
uniform sampler2D noise_texture : filter_linear_mipmap, repeat_enable;
|
||||||
|
|
||||||
|
// --- Snow params ---
|
||||||
|
uniform float snow_noise_scale : hint_range(0.01, 1.0) = 0.15;
|
||||||
|
uniform float snow_edge_softness : hint_range(0.01, 0.5) = 0.2;
|
||||||
|
uniform float snow_roughness_variation : hint_range(0.0, 0.3) = 0.15;
|
||||||
|
uniform float snow_color_variation : hint_range(0.0, 0.15) = 0.05;
|
||||||
|
|
||||||
|
// --- Rain params ---
|
||||||
|
uniform float ripple_scale : hint_range(0.1, 5.0) = 1.5;
|
||||||
|
uniform float ripple_speed : hint_range(0.5, 5.0) = 2.0;
|
||||||
|
uniform float ripple_layers : hint_range(1.0, 4.0) = 3.0;
|
||||||
|
uniform float streak_scale : hint_range(0.1, 5.0) = 2.0;
|
||||||
|
uniform float streak_speed : hint_range(0.1, 3.0) = 0.8;
|
||||||
|
uniform float wetness_darkening : hint_range(0.0, 0.5) = 0.25;
|
||||||
|
uniform float wet_roughness : hint_range(0.0, 0.3) = 0.05;
|
||||||
|
uniform float rain_normal_strength : hint_range(0.0, 1.0) = 0.4;
|
||||||
|
|
||||||
|
float ripple_ring(vec2 uv, float time_offset) {
|
||||||
|
float d = length(uv);
|
||||||
|
float ring = sin(d * 30.0 - TIME * ripple_speed + time_offset) * 0.5 + 0.5;
|
||||||
|
float fade = smoothstep(0.5, 0.0, d);
|
||||||
|
return ring * fade;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||||
|
vec3 world_normal = normalize((INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz);
|
||||||
|
float facing_up = clamp(world_normal.y, 0.0, 1.0);
|
||||||
|
float noise_val = texture(noise_texture, world_pos.xz * snow_noise_scale).r;
|
||||||
|
|
||||||
|
// ===================== SNOW =====================
|
||||||
|
float snow_amount = 0.0;
|
||||||
|
if (global_snow_start_time >= 0.0) {
|
||||||
|
snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
if (global_snow_melt_time >= 0.0) {
|
||||||
|
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
|
||||||
|
snow_amount *= (1.0 - melt);
|
||||||
|
}
|
||||||
|
|
||||||
|
float snow_edge = smoothstep(
|
||||||
|
global_snow_threshold - snow_edge_softness,
|
||||||
|
global_snow_threshold + snow_edge_softness,
|
||||||
|
facing_up + (noise_val - 0.5) * 0.4
|
||||||
|
);
|
||||||
|
float snow_coverage = smoothstep(0.0, 0.6, noise_val + snow_amount - 0.4);
|
||||||
|
float snow_factor = snow_edge * snow_coverage * snow_amount;
|
||||||
|
|
||||||
|
float shade = mix(-snow_color_variation, snow_color_variation, noise_val);
|
||||||
|
vec3 snow_albedo = clamp(global_snow_color.rgb + vec3(shade), 0.0, 1.0);
|
||||||
|
float snow_rough = mix(0.15 - snow_roughness_variation, 0.15 + snow_roughness_variation, noise_val);
|
||||||
|
|
||||||
|
// ===================== RAIN =====================
|
||||||
|
float rain_int = clamp(global_rain_intensity, 0.0, 1.0);
|
||||||
|
float rain_factor = 0.0;
|
||||||
|
vec3 rain_albedo = vec3(0.0);
|
||||||
|
float rain_rough = wet_roughness;
|
||||||
|
float rain_metallic = 0.0;
|
||||||
|
vec3 rain_normal = vec3(0.5, 0.5, 1.0);
|
||||||
|
|
||||||
|
if (rain_int > 0.01 && facing_up > 0.3) {
|
||||||
|
float surface_mask = smoothstep(0.3, 0.6, facing_up);
|
||||||
|
|
||||||
|
// Slope detection: 0 = flat, 1 = peak at ~30-45 degrees
|
||||||
|
float slope_angle = 1.0 - facing_up;
|
||||||
|
float slope_mask = smoothstep(0.1, 0.25, slope_angle) * smoothstep(0.75, 0.5, slope_angle);
|
||||||
|
|
||||||
|
// Ripples on horizontal surfaces
|
||||||
|
float ripple = 0.0;
|
||||||
|
for (float i = 0.0; i < ripple_layers; i += 1.0) {
|
||||||
|
float phase = i * 2.17;
|
||||||
|
vec2 cell_offset = vec2(
|
||||||
|
texture(noise_texture, world_pos.xz * ripple_scale * 0.3 + vec2(phase)).r,
|
||||||
|
texture(noise_texture, world_pos.xz * ripple_scale * 0.3 + vec2(0.0, phase)).r
|
||||||
|
);
|
||||||
|
vec2 ripple_uv = fract(world_pos.xz * ripple_scale + cell_offset) - 0.5;
|
||||||
|
ripple += ripple_ring(ripple_uv, phase * 3.7);
|
||||||
|
}
|
||||||
|
ripple /= ripple_layers;
|
||||||
|
|
||||||
|
// Flowing water on inclined surfaces (30-45 degrees)
|
||||||
|
vec3 down_dir = normalize(world_normal - vec3(0.0, 1.0, 0.0) * facing_up);
|
||||||
|
float flow_speed = streak_speed * (1.0 + slope_angle * 2.0);
|
||||||
|
|
||||||
|
// Main flow rivulets
|
||||||
|
float flow_coord = dot(world_pos, down_dir);
|
||||||
|
float lateral_coord = dot(world_pos.xz, vec2(-down_dir.z, down_dir.x)) * streak_scale;
|
||||||
|
vec2 flow_uv = vec2(lateral_coord, flow_coord * streak_scale - TIME * flow_speed);
|
||||||
|
float flow_noise = texture(noise_texture, flow_uv * 0.4).r;
|
||||||
|
float flow2 = texture(noise_texture, flow_uv * 0.7 + vec2(0.3, TIME * flow_speed * 0.3)).r;
|
||||||
|
float rivulets = smoothstep(0.3, 0.7, flow_noise) * smoothstep(0.25, 0.6, flow2);
|
||||||
|
|
||||||
|
// Accumulation at bottom (lower world_pos.y gets more water)
|
||||||
|
float height_factor = texture(noise_texture, world_pos.xz * 0.05).r;
|
||||||
|
float accumulation = smoothstep(0.6, 0.2, fract(world_pos.y * 0.3 + height_factor * 0.5));
|
||||||
|
rivulets = mix(rivulets, rivulets + accumulation * 0.3, slope_mask);
|
||||||
|
|
||||||
|
float streak = rivulets * slope_mask;
|
||||||
|
|
||||||
|
// Blend ripples (flat) and streaks (inclined)
|
||||||
|
float flat_weight = smoothstep(0.3, 0.15, slope_angle);
|
||||||
|
float effect = mix(streak, ripple, flat_weight) * rain_int * surface_mask;
|
||||||
|
float darkness = wetness_darkening * rain_int * surface_mask;
|
||||||
|
|
||||||
|
vec2 normal_offset = vec2(dFdx(effect), dFdy(effect)) * rain_normal_strength;
|
||||||
|
rain_normal = vec3(normal_offset.x + 0.5, normal_offset.y + 0.5, 1.0);
|
||||||
|
rain_albedo = vec3(0.02, 0.02, 0.03);
|
||||||
|
rain_metallic = 0.3 * rain_int;
|
||||||
|
rain_factor = effect * 0.8 + darkness;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== COMBINE =====================
|
||||||
|
if (snow_factor > rain_factor) {
|
||||||
|
ALBEDO = snow_albedo;
|
||||||
|
ROUGHNESS = snow_rough;
|
||||||
|
METALLIC = 0.0;
|
||||||
|
ALPHA = snow_factor;
|
||||||
|
} else {
|
||||||
|
ALBEDO = rain_albedo;
|
||||||
|
ROUGHNESS = rain_rough;
|
||||||
|
METALLIC = rain_metallic;
|
||||||
|
NORMAL_MAP = rain_normal;
|
||||||
|
ALPHA = rain_factor;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
core/daynight/weather_overlay.gdshader.uid
Normal file
1
core/daynight/weather_overlay.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dh3j2jp6defuk
|
||||||
21
core/daynight/weather_overlay.tres
Normal file
21
core/daynight/weather_overlay.tres
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
[gd_resource type="ShaderMaterial" format=3]
|
||||||
|
|
||||||
|
[ext_resource type="Shader" path="res://core/daynight/weather_overlay.gdshader" id="1_weather"]
|
||||||
|
[ext_resource type="NoiseTexture2D" uid="uid://bpswbjh4jj1ou" path="res://core/daynight/noise.tres" id="2_noise"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("1_weather")
|
||||||
|
shader_parameter/noise_texture = ExtResource("2_noise")
|
||||||
|
shader_parameter/snow_noise_scale = 0.15
|
||||||
|
shader_parameter/snow_edge_softness = 0.2
|
||||||
|
shader_parameter/snow_roughness_variation = 0.15
|
||||||
|
shader_parameter/snow_color_variation = 0.05
|
||||||
|
shader_parameter/ripple_scale = 1.5
|
||||||
|
shader_parameter/ripple_speed = 2.0
|
||||||
|
shader_parameter/ripple_layers = 3.0
|
||||||
|
shader_parameter/streak_scale = 2.0
|
||||||
|
shader_parameter/streak_speed = 0.8
|
||||||
|
shader_parameter/wetness_darkening = 0.25
|
||||||
|
shader_parameter/wet_roughness = 0.05
|
||||||
|
shader_parameter/rain_normal_strength = 0.4
|
||||||
@@ -97,9 +97,9 @@ extends Resource
|
|||||||
@export var snow_amount: float = 0.0
|
@export var snow_amount: float = 0.0
|
||||||
@export var snow_transaction_time: float = 10.0
|
@export var snow_transaction_time: float = 10.0
|
||||||
@export var snow_fade_time: float = 5.0
|
@export var snow_fade_time: float = 5.0
|
||||||
@export var snow_threshold: float = 0.6
|
@export var snow_threshold: float = 0.4
|
||||||
@export var snow_accumulation_speed: float = 0.05 #0.1 -> accumulation time 10secs; 0.05 -> accumulation time 20secs; realistic; 0.2 -> accumulation time 5secs;
|
@export var snow_accumulation_speed: float = 0.02 #0.1 -> accumulation time 10secs; 0.05 -> accumulation time 20secs; realistic; 0.2 -> accumulation time 5secs;
|
||||||
@export var snow_melt_speed: float = 0.1
|
@export var snow_melt_speed: float = 0.05
|
||||||
@export var snow_color: Color = Color(0.9, 0.95, 1.0)
|
@export var snow_color: Color = Color(0.9, 0.95, 1.0)
|
||||||
@export var snow_mode_color: Color = Color(0.7, 0.75, 0.8, 1.0)
|
@export var snow_mode_color: Color = Color(0.7, 0.75, 0.8, 1.0)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
[gd_scene format=3 uid="uid://cahsl77384kf1"]
|
[gd_scene format=3 uid="uid://cahsl77384kf1"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dllpmxm6ttwg" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house_Muraglione.fbx" id="1_m4ocs"]
|
[ext_resource type="PackedScene" uid="uid://dllpmxm6ttwg" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house_Muraglione.fbx" id="1_m4ocs"]
|
||||||
[ext_resource type="Material" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house.tres" id="2_7l0dg"]
|
[ext_resource type="Material" uid="uid://biaudrjlfoflm" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house.tres" id="2_7l0dg"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_bdf8l"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_bdf8l"]
|
||||||
|
|
||||||
[node name="House_Muraglione" unique_id=1060427946 groups=["snow_materials"] instance=ExtResource("1_m4ocs")]
|
[node name="House_Muraglione" unique_id=1060427946 groups=["weather_materials", "wind_materials"] instance=ExtResource("1_m4ocs")]
|
||||||
|
|
||||||
[node name="House_Muraglione" parent="." index="0" unique_id=517623360]
|
[node name="House_Muraglione" parent="." index="0" unique_id=517623360]
|
||||||
material_overlay = SubResource("ShaderMaterial_bdf8l")
|
material_overlay = SubResource("ShaderMaterial_bdf8l")
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -5,6 +5,11 @@ global uniform float global_wind_speed;
|
|||||||
global uniform vec2 global_wind_direction;
|
global uniform vec2 global_wind_direction;
|
||||||
global uniform float global_wind_scale;
|
global uniform float global_wind_scale;
|
||||||
global uniform float global_wind_strength;
|
global uniform float global_wind_strength;
|
||||||
|
global uniform float global_snow_start_time;
|
||||||
|
global uniform float global_snow_accumulation_speed;
|
||||||
|
global uniform float global_snow_melt_time;
|
||||||
|
global uniform float global_snow_melt_speed;
|
||||||
|
global uniform vec4 global_snow_color;
|
||||||
|
|
||||||
uniform sampler2D wind_noise : filter_linear_mipmap;
|
uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||||
uniform bool billboard_enabled = true;
|
uniform bool billboard_enabled = true;
|
||||||
@@ -24,6 +29,7 @@ uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
|
|||||||
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
|
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
|
||||||
|
|
||||||
varying vec3 v_final_color;
|
varying vec3 v_final_color;
|
||||||
|
varying float v_shade_factor;
|
||||||
|
|
||||||
float hash(vec3 p) {
|
float hash(vec3 p) {
|
||||||
p = fract(p * 0.1031);
|
p = fract(p * 0.1031);
|
||||||
@@ -48,6 +54,8 @@ void vertex() {
|
|||||||
float combined_factor = mix(h_factor, leaf_rand, random_mix);
|
float combined_factor = mix(h_factor, leaf_rand, random_mix);
|
||||||
combined_factor = ceil(combined_factor * light_steps) / light_steps;
|
combined_factor = ceil(combined_factor * light_steps) / light_steps;
|
||||||
|
|
||||||
|
v_shade_factor = combined_factor;
|
||||||
|
|
||||||
vec3 dark_color = base_color.rgb * (1.0 - shadow_intensity);
|
vec3 dark_color = base_color.rgb * (1.0 - shadow_intensity);
|
||||||
vec3 light_color = base_color.rgb + (vec3(1.0) - base_color.rgb) * highlight_intensity;
|
vec3 light_color = base_color.rgb + (vec3(1.0) - base_color.rgb) * highlight_intensity;
|
||||||
v_final_color = mix(dark_color, light_color, combined_factor);
|
v_final_color = mix(dark_color, light_color, combined_factor);
|
||||||
@@ -76,7 +84,25 @@ void fragment() {
|
|||||||
vec2 shifted_uv = UV + texture_offset;
|
vec2 shifted_uv = UV + texture_offset;
|
||||||
vec4 tex = texture(alpha_texture, shifted_uv);
|
vec4 tex = texture(alpha_texture, shifted_uv);
|
||||||
|
|
||||||
ALBEDO = v_final_color;
|
// Snow accumulation
|
||||||
|
float snow_amount = 0.0;
|
||||||
|
if (global_snow_start_time >= 0.0) {
|
||||||
|
snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
if (global_snow_melt_time >= 0.0) {
|
||||||
|
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
|
||||||
|
snow_amount *= (1.0 - melt);
|
||||||
|
}
|
||||||
|
|
||||||
|
float top_mask = 1.0 - shifted_uv.y;
|
||||||
|
float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
|
||||||
|
snow_mask *= step(0.01, snow_amount);
|
||||||
|
|
||||||
|
vec3 dark_snow = global_snow_color.rgb * (1.0 - shadow_intensity);
|
||||||
|
vec3 shaded_snow = mix(dark_snow, global_snow_color.rgb, v_shade_factor);
|
||||||
|
vec3 final_albedo = mix(v_final_color, shaded_snow, snow_mask);
|
||||||
|
|
||||||
|
ALBEDO = final_albedo;
|
||||||
ALPHA = tex.r * opacity;
|
ALPHA = tex.r * opacity;
|
||||||
ALPHA_SCISSOR_THRESHOLD = 0.5;
|
ALPHA_SCISSOR_THRESHOLD = 0.5;
|
||||||
ROUGHNESS = 0.02;
|
ROUGHNESS = 0.02;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[gd_scene format=3 uid="uid://jj15telqu3rp"]
|
[gd_scene format=3 uid="uid://jj15telqu3rp"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://e1an0215p6k2" path="res://docs/museums/daynight/scenes/grain_test/tree_v1.fbx" id="1_1rhib"]
|
[ext_resource type="PackedScene" uid="uid://e1an0215p6k2" path="res://docs/museums/daynight/scenes/grain_test/tree_v1.fbx" id="1_1rhib"]
|
||||||
[ext_resource type="Material" path="res://docs/museums/daynight/scenes/grass_test/grass.tres" id="2_4v7oi"]
|
[ext_resource type="Material" uid="uid://cudoptcrtgl7u" path="res://docs/museums/daynight/scenes/grass_test/grass.tres" id="2_4v7oi"]
|
||||||
[ext_resource type="Material" path="res://docs/museums/daynight/scenes/grass_test/grass3.tres" id="3_aek5d"]
|
[ext_resource type="Material" uid="uid://bjrb33qwp1p43" path="res://docs/museums/daynight/scenes/grass_test/grass3.tres" id="3_aek5d"]
|
||||||
[ext_resource type="Material" path="res://docs/museums/daynight/scenes/grass_test/grass4.tres" id="4_bawi4"]
|
[ext_resource type="Material" uid="uid://0x17mj2v807r" path="res://docs/museums/daynight/scenes/grass_test/grass4.tres" id="4_bawi4"]
|
||||||
|
|
||||||
[sub_resource type="QuadMesh" id="QuadMesh_rpt6v"]
|
[sub_resource type="QuadMesh" id="QuadMesh_rpt6v"]
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ instance_count = 40
|
|||||||
mesh = SubResource("QuadMesh_rpt6v")
|
mesh = SubResource("QuadMesh_rpt6v")
|
||||||
buffer = PackedFloat32Array(-1.001, 0, 0, -2.8797488, 0, 1.001, -5.966425e-08, -0.7477443, 0, -5.966425e-08, -1.001, -4.2194977, -1.001, 0, 0, -1.7037079, 0, 1.001, -5.966425e-08, -0.7477442, 0, -5.966425e-08, -1.001, -3.2446604, -1.001, 0, 0, 1.2830465, 0, 1.001, -5.966425e-08, -0.7477443, 0, -5.966425e-08, -1.001, -4.557446, -1.001, 0, 0, -5.028355, 0, 1.001, -5.966425e-08, -0.74774426, 0, -5.966425e-08, -1.001, -3.6429324, -1.001, 0, 0, -6.371053, 0, 1.001, -5.966425e-08, -0.7477439, 0, -5.966425e-08, -1.001, 4.1175256, 0, 0, -1.001, -1.5100684, 4.5406587e-08, 1.001, 0, -0.7477439, 1.001, -4.5406587e-08, 0, 4.42225, -1.001, 0, 0, -5.2487645, 0, 1.001, -5.966425e-08, -0.7477441, 0, -5.966425e-08, -1.001, -0.013931215, 0, 0, -1.001, 6.235317, 4.5406587e-08, 1.001, 0, -0.74774384, 1.001, -4.5406587e-08, 0, 6.248699, 0, 0, -1.001, 1.3825206, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, 1.1873395, 0, 0, -1.001, 2.780786, 4.5406587e-08, 1.001, 0, -0.747744, 1.001, -4.5406587e-08, 0, 1.1765423, -1.001, 0, 0, 1.0532601, 0, 1.001, -5.966425e-08, -0.74774444, 0, -5.966425e-08, -1.001, -6.5395527, -1.001, 0, 0, -4.3666453, 0, 1.001, -5.966425e-08, -0.747744, 0, -5.966425e-08, -1.001, 1.6017916, -1.001, 0, 0, -1.3377903, 0, 1.001, -5.966425e-08, -0.7477441, 0, -5.966425e-08, -1.001, -0.6376221, 0, 0, -1.001, 5.4567842, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, 0.5279622, 0, 0, -1.001, -1.2204466, 4.5406587e-08, 1.001, 0, -0.74774396, 1.001, -4.5406587e-08, 0, 1.4669147, -1.001, 0, 0, -5.0291324, 0, 1.001, -5.966425e-08, -0.74774426, 0, -5.966425e-08, -1.001, -3.9644425, 0, 0, -1.001, 4.144575, 4.5406587e-08, 1.001, 0, -0.7477443, 1.001, -4.5406587e-08, 0, -3.9907537, -1.001, 0, 0, -0.18894172, 0, 1.001, -5.966425e-08, -0.7477443, 0, -5.966425e-08, -1.001, -5.562557, 0, 0, -1.001, 3.410009, 4.5406587e-08, 1.001, 0, -0.74774396, 1.001, -4.5406587e-08, 0, 1.8935597, 0, 0, -1.001, -2.7810845, 4.5406587e-08, 1.001, 0, -0.7477439, 1.001, -4.5406587e-08, 0, 3.808044, -1.001, 0, 0, 0.284374, 0, 1.001, -5.966425e-08, -0.7477441, 0, -5.966425e-08, -1.001, -0.58144546, -1.001, 0, 0, -3.1262631, 0, 1.001, -5.966425e-08, -0.7477442, 0, -5.966425e-08, -1.001, -2.8066845, 0, 0, -1.001, 5.7749968, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, 0.935482, -1.001, 0, 0, -5.218869, 0, 1.001, -5.966425e-08, -0.74774426, 0, -5.966425e-08, -1.001, -4.2917852, 0, 0, -1.001, 6.1626782, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, 0.21193457, -1.001, 0, 0, 3.9669042, 0, 1.001, -5.966425e-08, -0.7477443, 0, -5.966425e-08, -1.001, -5.853158, 0, 0, -1.001, 2.2436643, 4.5406587e-08, 1.001, 0, -0.74774396, 1.001, -4.5406587e-08, 0, 3.1271167, 0, 0, -1.001, 2.4900956, 4.5406587e-08, 1.001, 0, -0.7477439, 1.001, -4.5406587e-08, 0, 3.9106765, 0, 0, -1.001, 5.5539966, 4.5406587e-08, 1.001, 0, -0.74774384, 1.001, -4.5406587e-08, 0, 6.162884, 0, 0, -1.001, -1.6500849, 4.5406587e-08, 1.001, 0, -0.74774384, 1.001, -4.5406587e-08, 0, 5.425037, 0, 0, -1.001, 1.2913516, 4.5406587e-08, 1.001, 0, -0.7477438, 1.001, -4.5406587e-08, 0, 5.9583297, 0, 0, -1.001, 3.403863, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, -1.3604579, 0, 0, -1.001, 2.5133843, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, -1.2172651, 0, 0, -1.001, -1.865159, 4.5406587e-08, 1.001, 0, -0.74774396, 1.001, -4.5406587e-08, 0, 2.02114, -1.001, 0, 0, -2.1462004, 0, 1.001, -5.966425e-08, -0.747744, 0, -5.966425e-08, -1.001, 1.2531993, 0, 0, -1.001, 6.005666, 4.5406587e-08, 1.001, 0, -0.747744, 1.001, -4.5406587e-08, 0, 1.2401769, 0, 0, -1.001, 2.402935, 4.5406587e-08, 1.001, 0, -0.7477439, 1.001, -4.5406587e-08, 0, 2.778954, -1.001, 0, 0, -6.482737, 0, 1.001, -5.966425e-08, -0.74774384, 0, -5.966425e-08, -1.001, 5.1091228, -1.001, 0, 0, 0.6619804, 0, 1.001, -5.966425e-08, -0.74774414, 0, -5.966425e-08, -1.001, -1.2692692, -1.001, 0, 0, 3.7678468, 0, 1.001, -5.966425e-08, -0.74774426, 0, -5.966425e-08, -1.001, -4.5863547)
|
buffer = PackedFloat32Array(-1.001, 0, 0, -2.8797488, 0, 1.001, -5.966425e-08, -0.7477443, 0, -5.966425e-08, -1.001, -4.2194977, -1.001, 0, 0, -1.7037079, 0, 1.001, -5.966425e-08, -0.7477442, 0, -5.966425e-08, -1.001, -3.2446604, -1.001, 0, 0, 1.2830465, 0, 1.001, -5.966425e-08, -0.7477443, 0, -5.966425e-08, -1.001, -4.557446, -1.001, 0, 0, -5.028355, 0, 1.001, -5.966425e-08, -0.74774426, 0, -5.966425e-08, -1.001, -3.6429324, -1.001, 0, 0, -6.371053, 0, 1.001, -5.966425e-08, -0.7477439, 0, -5.966425e-08, -1.001, 4.1175256, 0, 0, -1.001, -1.5100684, 4.5406587e-08, 1.001, 0, -0.7477439, 1.001, -4.5406587e-08, 0, 4.42225, -1.001, 0, 0, -5.2487645, 0, 1.001, -5.966425e-08, -0.7477441, 0, -5.966425e-08, -1.001, -0.013931215, 0, 0, -1.001, 6.235317, 4.5406587e-08, 1.001, 0, -0.74774384, 1.001, -4.5406587e-08, 0, 6.248699, 0, 0, -1.001, 1.3825206, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, 1.1873395, 0, 0, -1.001, 2.780786, 4.5406587e-08, 1.001, 0, -0.747744, 1.001, -4.5406587e-08, 0, 1.1765423, -1.001, 0, 0, 1.0532601, 0, 1.001, -5.966425e-08, -0.74774444, 0, -5.966425e-08, -1.001, -6.5395527, -1.001, 0, 0, -4.3666453, 0, 1.001, -5.966425e-08, -0.747744, 0, -5.966425e-08, -1.001, 1.6017916, -1.001, 0, 0, -1.3377903, 0, 1.001, -5.966425e-08, -0.7477441, 0, -5.966425e-08, -1.001, -0.6376221, 0, 0, -1.001, 5.4567842, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, 0.5279622, 0, 0, -1.001, -1.2204466, 4.5406587e-08, 1.001, 0, -0.74774396, 1.001, -4.5406587e-08, 0, 1.4669147, -1.001, 0, 0, -5.0291324, 0, 1.001, -5.966425e-08, -0.74774426, 0, -5.966425e-08, -1.001, -3.9644425, 0, 0, -1.001, 4.144575, 4.5406587e-08, 1.001, 0, -0.7477443, 1.001, -4.5406587e-08, 0, -3.9907537, -1.001, 0, 0, -0.18894172, 0, 1.001, -5.966425e-08, -0.7477443, 0, -5.966425e-08, -1.001, -5.562557, 0, 0, -1.001, 3.410009, 4.5406587e-08, 1.001, 0, -0.74774396, 1.001, -4.5406587e-08, 0, 1.8935597, 0, 0, -1.001, -2.7810845, 4.5406587e-08, 1.001, 0, -0.7477439, 1.001, -4.5406587e-08, 0, 3.808044, -1.001, 0, 0, 0.284374, 0, 1.001, -5.966425e-08, -0.7477441, 0, -5.966425e-08, -1.001, -0.58144546, -1.001, 0, 0, -3.1262631, 0, 1.001, -5.966425e-08, -0.7477442, 0, -5.966425e-08, -1.001, -2.8066845, 0, 0, -1.001, 5.7749968, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, 0.935482, -1.001, 0, 0, -5.218869, 0, 1.001, -5.966425e-08, -0.74774426, 0, -5.966425e-08, -1.001, -4.2917852, 0, 0, -1.001, 6.1626782, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, 0.21193457, -1.001, 0, 0, 3.9669042, 0, 1.001, -5.966425e-08, -0.7477443, 0, -5.966425e-08, -1.001, -5.853158, 0, 0, -1.001, 2.2436643, 4.5406587e-08, 1.001, 0, -0.74774396, 1.001, -4.5406587e-08, 0, 3.1271167, 0, 0, -1.001, 2.4900956, 4.5406587e-08, 1.001, 0, -0.7477439, 1.001, -4.5406587e-08, 0, 3.9106765, 0, 0, -1.001, 5.5539966, 4.5406587e-08, 1.001, 0, -0.74774384, 1.001, -4.5406587e-08, 0, 6.162884, 0, 0, -1.001, -1.6500849, 4.5406587e-08, 1.001, 0, -0.74774384, 1.001, -4.5406587e-08, 0, 5.425037, 0, 0, -1.001, 1.2913516, 4.5406587e-08, 1.001, 0, -0.7477438, 1.001, -4.5406587e-08, 0, 5.9583297, 0, 0, -1.001, 3.403863, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, -1.3604579, 0, 0, -1.001, 2.5133843, 4.5406587e-08, 1.001, 0, -0.7477441, 1.001, -4.5406587e-08, 0, -1.2172651, 0, 0, -1.001, -1.865159, 4.5406587e-08, 1.001, 0, -0.74774396, 1.001, -4.5406587e-08, 0, 2.02114, -1.001, 0, 0, -2.1462004, 0, 1.001, -5.966425e-08, -0.747744, 0, -5.966425e-08, -1.001, 1.2531993, 0, 0, -1.001, 6.005666, 4.5406587e-08, 1.001, 0, -0.747744, 1.001, -4.5406587e-08, 0, 1.2401769, 0, 0, -1.001, 2.402935, 4.5406587e-08, 1.001, 0, -0.7477439, 1.001, -4.5406587e-08, 0, 2.778954, -1.001, 0, 0, -6.482737, 0, 1.001, -5.966425e-08, -0.74774384, 0, -5.966425e-08, -1.001, 5.1091228, -1.001, 0, 0, 0.6619804, 0, 1.001, -5.966425e-08, -0.74774414, 0, -5.966425e-08, -1.001, -1.2692692, -1.001, 0, 0, 3.7678468, 0, 1.001, -5.966425e-08, -0.74774426, 0, -5.966425e-08, -1.001, -4.5863547)
|
||||||
|
|
||||||
[node name="Grass" unique_id=838519336 groups=["snow_materials", "wind_materials"] instance=ExtResource("1_1rhib")]
|
[node name="Grass" unique_id=838519336 groups=["weather_materials", "wind_materials"] instance=ExtResource("1_1rhib")]
|
||||||
|
|
||||||
[node name="Leaf" parent="." index="0" unique_id=770569390]
|
[node name="Leaf" parent="." index="0" unique_id=770569390]
|
||||||
visible = false
|
visible = false
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ window/stretch/aspect="expand"
|
|||||||
[global_group]
|
[global_group]
|
||||||
|
|
||||||
wind_materials="Materials to apply wind"
|
wind_materials="Materials to apply wind"
|
||||||
snow_materials=""
|
weather_materials=""
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
@@ -99,3 +99,7 @@ global_snow_melt_speed={
|
|||||||
"type": "float",
|
"type": "float",
|
||||||
"value": 0.0
|
"value": 0.0
|
||||||
}
|
}
|
||||||
|
global_rain_intensity={
|
||||||
|
"type": "float",
|
||||||
|
"value": 0.0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user