fix fog
This commit is contained in:
@@ -265,7 +265,7 @@ shader_parameter/edge_softness_x = 0.5
|
|||||||
shader_parameter/night_intensity = 0.0
|
shader_parameter/night_intensity = 0.0
|
||||||
shader_parameter/sun_color = Color(1, 1, 1, 1)
|
shader_parameter/sun_color = Color(1, 1, 1, 1)
|
||||||
|
|
||||||
[node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain", "environment_dust", "blur", "environment_shadows")]
|
[node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain", "environment_dust", "blur", "environment_shadows", "fog")]
|
||||||
script = ExtResource("1_wecen")
|
script = ExtResource("1_wecen")
|
||||||
environment_config = SubResource("Resource_r4tfj")
|
environment_config = SubResource("Resource_r4tfj")
|
||||||
particles_wind = NodePath("Particles_Wind")
|
particles_wind = NodePath("Particles_Wind")
|
||||||
@@ -276,6 +276,7 @@ godray = ExtResource("5_411rw")
|
|||||||
environment_dust = NodePath("EnvironmentDust")
|
environment_dust = NodePath("EnvironmentDust")
|
||||||
blur = NodePath("Blur")
|
blur = NodePath("Blur")
|
||||||
environment_shadows = NodePath("EnvironmentCloudsShadows")
|
environment_shadows = NodePath("EnvironmentCloudsShadows")
|
||||||
|
fog = NodePath("Fog")
|
||||||
|
|
||||||
[node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133]
|
[node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||||
@@ -340,11 +341,11 @@ surface_material_override/0 = SubResource("ShaderMaterial_oqt1s")
|
|||||||
[node name="Fog" type="Node3D" parent="." unique_id=1626352238]
|
[node name="Fog" type="Node3D" parent="." unique_id=1626352238]
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Fog" unique_id=96635311]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="Fog" unique_id=96635311]
|
||||||
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, -67, 14, 0)
|
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, -41.926987, 14, 0)
|
||||||
mesh = SubResource("QuadMesh_yn8v8")
|
mesh = SubResource("QuadMesh_yn8v8")
|
||||||
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
|
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
|
||||||
|
|
||||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Fog" unique_id=10121049]
|
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Fog" unique_id=10121049]
|
||||||
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, 67, 14, 0)
|
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, 59.320038, 14, 0)
|
||||||
mesh = SubResource("QuadMesh_yn8v8")
|
mesh = SubResource("QuadMesh_yn8v8")
|
||||||
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
|
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const WEATHER_PLAIN_SHADER: Material = preload("res://core/daynight/weather_plai
|
|||||||
@export var environment_dust: ColorRect
|
@export var environment_dust: ColorRect
|
||||||
@export var blur: ColorRect
|
@export var blur: ColorRect
|
||||||
@export var environment_shadows: MeshInstance3D
|
@export var environment_shadows: MeshInstance3D
|
||||||
|
@export var fog: Node3D
|
||||||
|
|
||||||
@export_group("Sound")
|
@export_group("Sound")
|
||||||
@export var thunder_sounds: Array[AudioStream]
|
@export var thunder_sounds: Array[AudioStream]
|
||||||
@@ -28,7 +29,6 @@ const WEATHER_PLAIN_SHADER: Material = preload("res://core/daynight/weather_plai
|
|||||||
#environment nodes
|
#environment nodes
|
||||||
@onready var sun: DirectionalLight3D = $"../DirectionalLight3D"
|
@onready var sun: DirectionalLight3D = $"../DirectionalLight3D"
|
||||||
@onready var environment: WorldEnvironment = $"../WorldEnvironment"
|
@onready var environment: WorldEnvironment = $"../WorldEnvironment"
|
||||||
@onready var fog_node: Node3D = $Fog
|
|
||||||
|
|
||||||
var day_night_controller: DayNightController
|
var day_night_controller: DayNightController
|
||||||
var weather_controller: WeatherController
|
var weather_controller: WeatherController
|
||||||
@@ -40,7 +40,6 @@ func _ready() -> void:
|
|||||||
|
|
||||||
#connect shader when new node is added
|
#connect shader when new node is added
|
||||||
get_tree().node_added.connect(_on_tree_node_added)
|
get_tree().node_added.connect(_on_tree_node_added)
|
||||||
UIEvents.toggle_fog.connect(toggle_fog)
|
|
||||||
|
|
||||||
#set noise texture 2d to materials in special group
|
#set noise texture 2d to materials in special group
|
||||||
ApplyWindNoiseToMaterials()
|
ApplyWindNoiseToMaterials()
|
||||||
@@ -64,6 +63,7 @@ func _ready() -> void:
|
|||||||
godray,
|
godray,
|
||||||
environment_dust,
|
environment_dust,
|
||||||
blur,
|
blur,
|
||||||
|
fog,
|
||||||
environment_shadows,
|
environment_shadows,
|
||||||
sun,
|
sun,
|
||||||
environment,
|
environment,
|
||||||
@@ -160,7 +160,3 @@ func select_day_time(normalized_time: float) -> void:
|
|||||||
|
|
||||||
if weather_controller:
|
if weather_controller:
|
||||||
weather_controller.day_time = day_time
|
weather_controller.day_time = day_time
|
||||||
|
|
||||||
func toggle_fog(value: bool) -> void:
|
|
||||||
if fog_node:
|
|
||||||
fog_node.visible = value
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ var godray: PackedScene
|
|||||||
var environment_dust: ColorRect
|
var environment_dust: ColorRect
|
||||||
var blur: ColorRect
|
var blur: ColorRect
|
||||||
var environment_shadows: MeshInstance3D
|
var environment_shadows: MeshInstance3D
|
||||||
|
var fog: Node3D
|
||||||
|
|
||||||
var sun: DirectionalLight3D
|
var sun: DirectionalLight3D
|
||||||
var environment: WorldEnvironment
|
var environment: WorldEnvironment
|
||||||
@@ -53,7 +54,7 @@ var random_weather_restore_tween: Tween
|
|||||||
|
|
||||||
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||||
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
|
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
|
||||||
dust: ColorRect, blurr: ColorRect, envshadows: MeshInstance3D,
|
dust: ColorRect, blurr: ColorRect, thefog: Node3D, envshadows: MeshInstance3D,
|
||||||
thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig,
|
thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig,
|
||||||
thecamera: Camera3D, thecamerapivot: Node3D, thundersounds: Array[AudioStream], rainsounds: Array[AudioStream]) -> void:
|
thecamera: Camera3D, thecamerapivot: Node3D, thundersounds: Array[AudioStream], rainsounds: Array[AudioStream]) -> void:
|
||||||
particles_wind = wind
|
particles_wind = wind
|
||||||
@@ -64,6 +65,7 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
|||||||
sun = thesun
|
sun = thesun
|
||||||
environment_dust = dust
|
environment_dust = dust
|
||||||
blur = blurr
|
blur = blurr
|
||||||
|
fog = thefog
|
||||||
environment_shadows = envshadows
|
environment_shadows = envshadows
|
||||||
environment = theenvironment
|
environment = theenvironment
|
||||||
environment_config = environmentconfig
|
environment_config = environmentconfig
|
||||||
@@ -87,6 +89,7 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
|||||||
|
|
||||||
toggle_dust(environment_config.enable_dust)
|
toggle_dust(environment_config.enable_dust)
|
||||||
toggle_blur(environment_config.enable_blur)
|
toggle_blur(environment_config.enable_blur)
|
||||||
|
toggle_fog(environment_config.enable_fog)
|
||||||
|
|
||||||
#set camera pivot if available
|
#set camera pivot if available
|
||||||
if camera_pivot:
|
if camera_pivot:
|
||||||
@@ -104,6 +107,7 @@ func _ready() -> void:
|
|||||||
UIEvents.toggle_storm.connect(toggle_storm)
|
UIEvents.toggle_storm.connect(toggle_storm)
|
||||||
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_fog.connect(toggle_fog)
|
||||||
UIEvents.toggle_shadows.connect(toggle_shadows)
|
UIEvents.toggle_shadows.connect(toggle_shadows)
|
||||||
_emit_weather_event_label()
|
_emit_weather_event_label()
|
||||||
|
|
||||||
@@ -273,6 +277,23 @@ func _get_weather_anchor_position() -> Variant:
|
|||||||
return camera.global_position
|
return camera.global_position
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
func _get_weather_anchor_basis() -> Variant:
|
||||||
|
var source_basis: Basis
|
||||||
|
if camera_pivot and is_instance_valid(camera_pivot):
|
||||||
|
source_basis = camera_pivot.global_basis
|
||||||
|
elif camera and is_instance_valid(camera):
|
||||||
|
source_basis = camera.global_basis
|
||||||
|
else:
|
||||||
|
return null
|
||||||
|
|
||||||
|
var forward := -source_basis.z
|
||||||
|
forward.y = 0.0
|
||||||
|
if forward.length_squared() <= 0.0001:
|
||||||
|
return Basis.IDENTITY
|
||||||
|
forward = forward.normalized()
|
||||||
|
var right := forward.cross(Vector3.UP).normalized()
|
||||||
|
return Basis(right, Vector3.UP, -forward)
|
||||||
|
|
||||||
func _follow_camera() -> void:
|
func _follow_camera() -> void:
|
||||||
var cam_pos = _get_weather_anchor_position()
|
var cam_pos = _get_weather_anchor_position()
|
||||||
if cam_pos == null:
|
if cam_pos == null:
|
||||||
@@ -285,6 +306,12 @@ func _follow_camera() -> void:
|
|||||||
particles_wind.global_position = Vector3(cam_pos.x, cam_pos.y, cam_pos.z)
|
particles_wind.global_position = Vector3(cam_pos.x, cam_pos.y, cam_pos.z)
|
||||||
if particles_fireflies:
|
if particles_fireflies:
|
||||||
particles_fireflies.global_position = Vector3(cam_pos.x, particles_fireflies.position.y, cam_pos.z)
|
particles_fireflies.global_position = Vector3(cam_pos.x, particles_fireflies.position.y, cam_pos.z)
|
||||||
|
if fog:
|
||||||
|
fog.global_position = Vector3(cam_pos.x, fog.global_position.y, cam_pos.z)
|
||||||
|
#used to follow camera pivot or camera
|
||||||
|
var anchor_basis = _get_weather_anchor_basis()
|
||||||
|
if anchor_basis != null:
|
||||||
|
fog.global_basis = anchor_basis
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Fireflies
|
#region Fireflies
|
||||||
@@ -809,6 +836,10 @@ func toggle_blur(value: bool) -> void:
|
|||||||
|
|
||||||
ApplyPostProcessBlurConfig()
|
ApplyPostProcessBlurConfig()
|
||||||
|
|
||||||
|
func toggle_fog(value: bool) -> void:
|
||||||
|
if fog:
|
||||||
|
fog.visible = value
|
||||||
|
|
||||||
func toggle_shadows(value: bool) -> void:
|
func toggle_shadows(value: bool) -> void:
|
||||||
if environment_shadows:
|
if environment_shadows:
|
||||||
environment_shadows.visible = value
|
environment_shadows.visible = value
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ extends Resource
|
|||||||
@export var enable_dust: bool = false #Floating dust particles overlay
|
@export var enable_dust: bool = false #Floating dust particles overlay
|
||||||
@export var enable_blur: bool = true #Screen blur effect
|
@export var enable_blur: bool = true #Screen blur effect
|
||||||
@export var enable_environment_shadows: bool = true #Cloud shadow projection on terrain
|
@export var enable_environment_shadows: bool = true #Cloud shadow projection on terrain
|
||||||
@export var enable_fog: bool = true #Enable fog around the train
|
@export var enable_fog: bool = false #Enable fog around the train
|
||||||
@export var blur_amount: float = 0.6
|
@export var blur_amount: float = 0.6
|
||||||
|
|
||||||
@export_group("Dust")
|
@export_group("Dust")
|
||||||
|
|||||||
Reference in New Issue
Block a user