extends ColorRect

var player = null
var occlusion_mask: ImageTexture = null
var occlusion_offset = Vector2.ZERO

onready var shader = (material as ShaderMaterial)

func _process(delta):
	if occlusion_mask != null:
		shader.set_shader_param("occlusion_mask", occlusion_mask)
		shader.set_shader_param("occlusion_rect", Color(occlusion_offset.x, occlusion_offset.y, occlusion_mask.get_width(), occlusion_mask.get_height()))
	var viewport_rect = get_viewport_rect()
	var camera_offset = player.camera.get_camera_position() - viewport_rect.size * 0.5
	shader.set_shader_param("viewport_rect", Color(camera_offset.x, camera_offset.y, viewport_rect.size.x, viewport_rect.size.y))
