extends ColorRect

@export var amount_base := 0.15      # minimum glitch
@export var amount_amp  := 0.25      # how strong the wave is
@export var amount_speed := 1.2      # speed of oscillation

var time := 0.0
@onready var mat := material as ShaderMaterial

func _process(delta: float) -> void:
	if not mat:
		return

	time += delta

	# Animate seed (row randomness)
	mat.set_shader_parameter("seed", time * 10.0)

	# Sine wave for amount
	var wave := (sin(time * amount_speed) + 1.0) * 0.5
	var amount := amount_base + wave * amount_amp
	
	# random surge
	if randi() % 120 == 0:
		amount += 0.3
		
	mat.set_shader_parameter("amount", amount)
