environment.gd 529 B

12345678910111213
  1. extends WorldEnvironment
  2. # This script controls fog based on the VoxelWorld's effective render distance.
  3. @onready var voxel_world: Node = $"../VoxelWorld"
  4. func _process(delta: float) -> void:
  5. environment.fog_enabled = Settings.fog_enabled
  6. var target_distance := clampi(voxel_world.effective_render_distance, 2, voxel_world.render_distance - 1) * Chunk.CHUNK_SIZE
  7. var rate := delta * 4
  8. Settings.fog_distance = move_toward(Settings.fog_distance, target_distance, rate)
  9. environment.fog_density = 0.5 / Settings.fog_distance