improve snow
This commit is contained in:
@@ -3,7 +3,7 @@ extends Node3D
|
||||
|
||||
const NOISE_TEXTURE: Texture2D = preload("res://core/daynight/noise.tres")
|
||||
const WEATHER_SHADER: Material = preload("res://core/daynight/weather_overlay.tres")
|
||||
const DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME: int = 2 #how many update of the environment (apply materials) will be done per frame
|
||||
const DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME: int = 32 #how many update of the environment (apply materials) will be done per frame
|
||||
|
||||
@export var environment_config: EnvironmentConfig
|
||||
|
||||
@@ -80,6 +80,9 @@ func _ready() -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
_process_pending_environment_nodes()
|
||||
|
||||
func flush_pending_environment_nodes() -> void:
|
||||
_process_pending_environment_nodes(-1)
|
||||
|
||||
func _on_tree_node_added(node: Node) -> void:
|
||||
if node.is_in_group("wind_node") or node.is_in_group("weather_node") or node.is_in_group("weather_vegetables_node"):
|
||||
_queue_dynamic_environment_node(node)
|
||||
@@ -108,10 +111,10 @@ func _queue_dynamic_environment_node(node: Node) -> void:
|
||||
|
||||
pending_environment_nodes[node.get_instance_id()] = node
|
||||
|
||||
func _process_pending_environment_nodes() -> void:
|
||||
func _process_pending_environment_nodes(max_nodes: int = DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME) -> void:
|
||||
var processed = 0
|
||||
for node_id in pending_environment_nodes.keys():
|
||||
if processed >= DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME:
|
||||
if max_nodes >= 0 and processed >= max_nodes:
|
||||
break
|
||||
|
||||
var node = pending_environment_nodes[node_id]
|
||||
|
||||
Reference in New Issue
Block a user