add env shadows; add clouds and wind parameters for sky and envshadwows

This commit is contained in:
2026-03-27 13:22:39 +01:00
parent 052f200c5d
commit 2f4fd27dfd
17 changed files with 496 additions and 29 deletions

View File

@@ -7,6 +7,9 @@ var particles_fireflies: GPUParticles3D
var particles_rain: GPUParticles3D
var godray: PackedScene
var fog_overlay: ColorRect
var environment_dust: ColorRect
var blur: ColorRect
var environment_shadows: MeshInstance3D
var sun: DirectionalLight3D
var environment: WorldEnvironment
@@ -36,6 +39,7 @@ var thereare_fireflies: bool = false
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
fogov: ColorRect, dust: ColorRect, blurr: ColorRect, envshadows: MeshInstance3D,
thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig,
thecamera: Camera3D = null) -> void:
particles_wind = wind
@@ -44,6 +48,10 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
particles_rain = rain
godray = ray
sun = thesun
fog_overlay = fogov
environment_dust = dust
blur = blurr
environment_shadows = envshadows
environment = theenvironment
environment_config = environmentconfig
camera = thecamera
@@ -65,8 +73,13 @@ func _ready() -> void:
UIEvents.toggle_wind.connect(toggle_wind)
UIEvents.toggle_fireflies.connect(toggle_fireflies)
UIEvents.toggle_storm.connect(toggle_storm)
UIEvents.toggle_fog_overlay.connect(toggle_fog_overlay)
UIEvents.toggle_dust.connect(toggle_dust)
UIEvents.toggle_blur.connect(toggle_blur)
UIEvents.toggle_shadows.connect(toggle_shadows)
func _process(delta: float) -> void:
_follow_camera()
var base_tint: Color
@@ -204,7 +217,7 @@ func _follow_camera() -> void:
if particles_fireflies:
particles_fireflies.global_position = Vector3(cam_pos.x, particles_fireflies.position.y, cam_pos.z)
#region fireflies
#region Fireflies
func toggle_fireflies(value: bool):
thereare_fireflies = value
@@ -241,6 +254,28 @@ func set_wind():
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)
if environment_config:
_apply_cloud_config()
func _apply_cloud_config() -> void:
var dir = environment_config.wind_direction
var cloud_scale = environment_config.cloud_scale
var cloud_speed = environment_config.cloud_speed
var envshadows_scale_rate = environment_config.cloud_scale_envshadows_rate
var envshadows_speed_rate = environment_config.cloud_speed_envshadows_rate
if environment and environment.environment and environment.environment.sky:
var sky_mat = environment.environment.sky.sky_material as ShaderMaterial
if sky_mat:
sky_mat.set_shader_parameter("cloud_direction", dir)
sky_mat.set_shader_parameter("cloud_scale", cloud_scale)
sky_mat.set_shader_parameter("cloud_speed", cloud_speed)
if environment_shadows and environment_shadows.material_override:
environment_shadows.material_override.set_shader_parameter("direction", dir)
environment_shadows.material_override.set_shader_parameter("cloud_scale", cloud_scale * envshadows_scale_rate)
environment_shadows.material_override.set_shader_parameter("cloud_speed", cloud_speed * envshadows_speed_rate)
#endregion
@@ -325,6 +360,7 @@ func start_lightning():
if lightning_number > 1:
await get_tree().create_timer(randf_range(0.05, 0.15)).timeout
#endregion
#region Rain
@@ -386,6 +422,7 @@ func spawn_single_godray() -> void:
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
@@ -446,3 +483,23 @@ func set_snow_amount(value: float):
RenderingServer.global_shader_parameter_set("global_snow_amount", value)
#endregion
#region Post-Process
func toggle_fog_overlay(value: bool) -> void:
if fog_overlay:
fog_overlay.visible = value
func toggle_dust(value: bool) -> void:
if environment_dust:
environment_dust.visible = value
func toggle_blur(value: bool) -> void:
if blur:
blur.visible = value
func toggle_shadows(value: bool) -> void:
if environment_shadows:
environment_shadows.visible = value
#endregion