fix wind and make compatible wind_decoration

This commit is contained in:
2026-06-03 10:59:46 +02:00
parent afbda265b6
commit 243f89d9d2
4 changed files with 73 additions and 14 deletions

View File

@@ -56,7 +56,7 @@ void fragment() {
} else {
vec2 projected_xz = world_pos.xz + (world_pos.y * sun_angle);
vec2 uv = projected_xz * cloud_scale;
uv += TIME * cloud_speed * direction;
uv -= TIME * cloud_speed * direction;
float n = texture(noise_texture, uv).r;
@@ -71,4 +71,4 @@ void fragment() {
}
}
}
}
}

View File

@@ -118,7 +118,7 @@ void sky() {
//Clouds
vec2 cloud_uv = EYEDIR.xz / (EYEDIR.y + 0.5);
cloud_uv = cloud_uv * cloud_scale + (TIME * cloud_direction * cloud_speed);
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);
@@ -136,4 +136,4 @@ void sky() {
final_sky = mix(final_sky, current_cloud_color, cloud_alpha);
COLOR = final_sky;
}
}

View File

@@ -1,6 +1,8 @@
class_name WeatherController
extends Node
signal wind_parameters_changed(speed: float, strength: float, fade: float, direction: Vector2)
var thunder_audio_player: AudioStreamPlayer
var thunder_sounds: Array[AudioStream]
var rain_sounds: Array[AudioStream]
@@ -101,6 +103,8 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
camera_pivot.get_node("pivot").camera_changed.connect(_set_camera)
func _ready() -> void:
#used for wind change state (wind_decoration)
add_to_group("weather_controller")
#connect events
UIEvents.toggle_rain.connect(toggle_rain)
@@ -439,7 +443,7 @@ func _apply_wind_config() -> void:
else:
wind_cross = wind_cross.normalized()
var wind_up := wind_cross.cross(wind_axis).normalized()
proc_mat_wind.direction = wind_axis
proc_mat_wind.direction = Vector3.UP
particles_wind.global_transform = Transform3D(Basis(wind_cross, wind_axis, wind_up), particles_wind.global_position)
_apply_wind_state(true)
@@ -469,14 +473,23 @@ func _apply_wind_state(immediate: bool = false) -> void:
func _set_current_wind_speed(value: float) -> void:
current_wind_speed = value
RenderingServer.global_shader_parameter_set("global_wind_speed", value)
_sync_wind_event_state()
func _set_current_wind_strength(value: float) -> void:
current_wind_strength = value
RenderingServer.global_shader_parameter_set("global_wind_strength", value)
_sync_wind_event_state()
func _set_current_wind_fade(value: float) -> void:
current_wind_fade = value
RenderingServer.global_shader_parameter_set("global_wind_fade", value)
_sync_wind_event_state()
func _sync_wind_event_state() -> void:
if environment_config == null:
return
#used to notify wind_decoration when wind change state
wind_parameters_changed.emit(current_wind_speed, current_wind_strength, current_wind_fade, environment_config.wind_direction)
func _finish_wind_fade_out() -> void:
if is_windy: