extends WorldEnvironment

export var target: NodePath
export var size: float = 1.0
onready var target_node: Spatial = get_node(target)

func _ready():
	environment.dof_blur_far_enabled = true
	environment.dof_blur_near_enabled = true

func _process(delta):
	var dist := get_viewport().get_camera().global_transform.origin.distance_to(target_node.global_transform.origin)
	environment.dof_blur_near_distance = dist - size / 2.0
	environment.dof_blur_far_distance = dist + size / 2.0
