This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Scenes/Rendering/SSLO.gd
2020-07-12 17:27:55 +02:00

15 lines
675 B
GDScript

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))