-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblack_frame.gd
55 lines (39 loc) · 1.44 KB
/
black_frame.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
extends CanvasLayer
## If `true`, enables black frame insertion (BFI).
var bfi_enabled := true
## The opacity of each black frame.
## Higher values result in less ghosting at the cost of more flickering.
var bfi_intensity := 0.5
## The number of black frames to display.
## Higher values result in less ghosting at the cost of more flickering.
var bfi_frames := 1
func _ready() -> void:
update_label()
func _process(_delta: float):
if bfi_enabled:
%BlackFrame.modulate.a = bfi_intensity if Engine.get_process_frames() % (bfi_frames + 1) >= 1 else 0.0
else:
%BlackFrame.modulate.a = 0.0
func _input(event: InputEvent):
if event.is_action_pressed("bfi_toggle"):
bfi_enabled = not bfi_enabled
update_label()
if event.is_action_pressed("bfi_increase_intensity"):
bfi_intensity = clamp(bfi_intensity + 0.1, 0.0, 1.0)
update_label()
if event.is_action_pressed("bfi_decrease_intensity"):
bfi_intensity = clamp(bfi_intensity - 0.1, 0.0, 1.0)
update_label()
if event.is_action_pressed("bfi_increase_frames"):
bfi_frames = clamp(bfi_frames + 1, 1, 2)
update_label()
if event.is_action_pressed("bfi_decrease_frames"):
bfi_frames = clamp(bfi_frames - 1, 1, 2)
update_label()
func update_label() -> void:
%Label.text = "Black Frame Insertion: %s" % ("Enabled" if bfi_enabled else "Disabled")
if bfi_enabled:
%Label.text += \
"""
BFI Strength: %d%%
BFI Frame Interval: %d/%d""" % [round(bfi_intensity * 100), bfi_frames, bfi_frames + 1]