Files
Bullosseum/ps1_filter.gd
T
2026-07-30 15:12:22 +03:00

37 lines
1.2 KiB
GDScript

extends ColorRect
## Drives the fullscreen PS1/CRT post-process (ps1_filter.gdshader) from the DP
## registry so every uniform is live-tunable in the console. `show_ps1` toggles the
## whole overlay; the ps1_* floats feed the matching shader uniforms 1:1.
# DP param key → shader uniform name. Keys are registered in debug_params.gd with
# ranges that mirror the shader's hint_range, so nothing here can go out of bounds.
const _UNIFORMS := {
"ps1_pixel_scale": "pixel_scale",
"ps1_color_depth": "color_depth",
"ps1_dither_strength": "dither_strength",
"ps1_scanline_strength": "scanline_strength",
"ps1_roll_speed": "roll_speed",
"ps1_roll_strength": "roll_strength",
}
@onready var _mat: ShaderMaterial = material as ShaderMaterial
func _ready() -> void:
DP.any_changed.connect(_on_param_changed)
_apply_all()
# reset_all() fires with key "__all__"; a single edit fires with its own key. Either
# way just re-push everything — it's a handful of cheap uniform writes.
func _on_param_changed(_key: String, _value: Variant) -> void:
_apply_all()
func _apply_all() -> void:
visible = DP.b("show_ps1")
if _mat == null:
return
for key: String in _UNIFORMS:
_mat.set_shader_parameter(_UNIFORMS[key], DP.f(key))