fix wind direction to follow global settings

This commit is contained in:
2026-04-21 08:49:59 +02:00
parent 24ac9dccb3
commit 7a1ac3b698
3 changed files with 17 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
shader_type spatial;
render_mode unshaded, depth_test_disabled, cull_disabled;
/*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;
@@ -71,3 +71,4 @@ void fragment() {
}
}
}
*/

View File

@@ -235,7 +235,7 @@ 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, 50, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0)
emitting = false
amount = 100
lifetime = 3.0

View File

@@ -318,6 +318,20 @@ func _apply_wind_config() -> void:
RenderingServer.global_shader_parameter_set("global_wind_direction", environment_config.wind_direction)
RenderingServer.global_shader_parameter_set("global_wind_scale", environment_config.wind_scale)
RenderingServer.global_shader_parameter_set("global_wind_strength", environment_config.wind_strength)
if particles_wind:
var proc_mat_wind = particles_wind.process_material as ParticleProcessMaterial
if proc_mat_wind:
var wind_direction_3d := Vector3(environment_config.wind_direction.x, 0.0, environment_config.wind_direction.y)
if wind_direction_3d.length_squared() > 0.0:
var wind_axis := wind_direction_3d.normalized()
var wind_cross := wind_axis.cross(Vector3.UP)
if wind_cross.length_squared() == 0.0:
wind_cross = Vector3.FORWARD
else:
wind_cross = wind_cross.normalized()
var wind_up := wind_cross.cross(wind_axis).normalized()
proc_mat_wind.direction = wind_axis
particles_wind.global_transform = Transform3D(Basis(wind_cross, wind_axis, wind_up), particles_wind.global_position)
func _apply_cloud_config() -> void:
var dir = environment_config.wind_direction