Render text in a different viewport, apply the outline shader only to the normal one
This commit is contained in:
parent
ca40ca4207
commit
eaf9edfd53
9 changed files with 109 additions and 34 deletions
|
@ -22,6 +22,7 @@ class Entrypoint extends Object:
|
|||
self.initial_velocity = initial_velocity_
|
||||
|
||||
const SCENES = {
|
||||
"menu": "uid://bqmpoix37kutp",
|
||||
"intro": "uid://c6w7lrydi43ts",
|
||||
"test": "uid://dqf665b540tfg",
|
||||
}
|
||||
|
@ -38,7 +39,10 @@ var current_scene_name: String = ""
|
|||
|
||||
func _pre_load_checks() -> bool:
|
||||
if NodeRegistry.level_root_container == null:
|
||||
push_error("Can't load level, level_root is not registered yet.")
|
||||
push_error("Can't load level, level_root_container is not registered yet.")
|
||||
return false
|
||||
if NodeRegistry.level_text_root_container == null:
|
||||
push_error("Can't load level, level_text_root_container is not registered yet.")
|
||||
return false
|
||||
if NodeRegistry.player == null:
|
||||
push_error("Can't load entrypoint, player is not registered yet.")
|
||||
|
@ -55,14 +59,20 @@ func load_scene(scn_name: String, force_reload: bool = false) -> bool:
|
|||
push_error("Level " + scn_name + " doesn't exist.")
|
||||
return false
|
||||
unload_scene()
|
||||
var scn = load(SCENES[scn_name])
|
||||
NodeRegistry.level_root_container.add_child(scn.instantiate())
|
||||
var scn: Node2D = load(SCENES[scn_name]).instantiate()
|
||||
NodeRegistry.level_root_container.add_child(scn)
|
||||
for t in get_tree().get_nodes_in_group("text_viewport"):
|
||||
t.reparent(NodeRegistry.level_text_root_container)
|
||||
return true
|
||||
|
||||
func unload_scene():
|
||||
if NodeRegistry.level_root_container != null:
|
||||
for c in NodeRegistry.level_root_container.get_children():
|
||||
c.queue_free()
|
||||
for container in [
|
||||
NodeRegistry.level_root_container,
|
||||
NodeRegistry.level_text_root_container
|
||||
]:
|
||||
if container != null:
|
||||
for c in container.get_children():
|
||||
c.queue_free()
|
||||
|
||||
func load_entrypoint(ep_name: String) -> bool: # returns true on success
|
||||
if not ep_name in ENTRYPOINTS:
|
||||
|
@ -86,6 +96,5 @@ func load_menu():
|
|||
if not _pre_load_checks():
|
||||
return false
|
||||
unload_scene()
|
||||
NodeRegistry.level_root_container.add_child(MENU_SCENE.instantiate())
|
||||
NodeRegistry.player.position = mainmenu_player_pos
|
||||
return true
|
||||
return load_scene("menu", true)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
extends Node
|
||||
|
||||
var player: CharacterBody2D
|
||||
var level_root_container: Node
|
||||
var level_root_container: Node2D
|
||||
var level_text_root_container: Node2D
|
||||
|
|
|
@ -23,7 +23,11 @@ void fragment() {
|
|||
rgb_distortion_v_min,
|
||||
rgb_distortion_v_max
|
||||
);
|
||||
COLOR.r = textureLod(screen_texture, SCREEN_UV - (v_ * 0.01), v).r;
|
||||
COLOR.g = textureLod(screen_texture, SCREEN_UV + (v_ * 0.01), v).g;
|
||||
COLOR.b = textureLod(screen_texture, SCREEN_UV, v).b;
|
||||
vec2 screen_uv_r = SCREEN_UV - (v_ * 0.01);
|
||||
vec2 screen_uv_g = SCREEN_UV + (v_ * 0.01);
|
||||
vec2 screen_uv_b = SCREEN_UV;
|
||||
COLOR.r = textureLod(screen_texture, screen_uv_r, v).r;
|
||||
COLOR.g = textureLod(screen_texture, screen_uv_g, v).g;
|
||||
COLOR.b = textureLod(screen_texture, screen_uv_b, v).b;
|
||||
COLOR.a = 1.0;
|
||||
}
|
||||
|
|
5
core/shadowing_camera_2d.gd
Normal file
5
core/shadowing_camera_2d.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
extends Camera2D
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
var orig_camera: Camera2D = NodeRegistry.player.camera
|
||||
self.global_position = -orig_camera.get_viewport_transform().origin
|
Reference in a new issue