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

16 lines
675 B
GDScript3
Raw Permalink Normal View History

2020-07-12 15:27:55 +00:00
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))