feat(theme): Implement comprehensive CRT Filter (scanlines, vignette, noise)

This commit is contained in:
2026-03-09 01:19:16 -04:00
parent 9facecb7a5
commit e635c2925d
3 changed files with 88 additions and 28 deletions

View File

@@ -131,7 +131,8 @@ class App:
self._token_stats: dict[str, Any] = {}
self._token_stats_dirty: bool = True
self.perf_history: dict[str, list] = {"frame_time": [0.0] * 100, "fps": [0.0] * 100}
self._nerv_scanlines = theme_fx.ScanlineOverlay()
self._nerv_crt = theme_fx.CRTFilter()
self.ui_crt_filter = True
self._nerv_alert = theme_fx.AlertPulsing()
self._nerv_flicker = theme_fx.StatusFlicker()
@@ -307,9 +308,8 @@ class App:
ws = imgui.get_io().display_size
self._nerv_alert.update(self.ai_status)
self._nerv_alert.render(ws.x, ws.y)
self._nerv_scanlines.render(ws.x, ws.y)
pushed_prior_tint = False
self._nerv_crt.enabled = self.ui_crt_filter
self._nerv_crt.render(ws.x, ws.y)
if self.perf_profiling_enabled: self.perf_monitor.start_component("_gui_func")
if self.is_viewing_prior_session:
imgui.push_style_color(imgui.Col_.window_bg, vec4(50, 40, 20))
@@ -2895,17 +2895,21 @@ def hello():
ch_ct, ctrans = imgui.slider_float("##ctrans", theme.get_child_transparency(), 0.1, 1.0, "%.2f")
if ch_ct:
theme.set_child_transparency(ctrans)
self._flush_to_config()
models.save_config(self.config)
imgui.separator()
bg = bg_shader.get_bg()
ch_bg, bg.enabled = imgui.checkbox("Animated Background Shader", bg.enabled)
if ch_bg:
gui_cfg = self.config.setdefault("gui", {})
gui_cfg["bg_shader_enabled"] = bg.enabled
self._flush_to_config()
models.save_config(self.config)
ch_crt, self.ui_crt_filter = imgui.checkbox("CRT Filter", self.ui_crt_filter)
if ch_crt:
gui_cfg = self.config.setdefault("gui", {})
gui_cfg["crt_filter_enabled"] = self.ui_crt_filter
self._flush_to_config()
models.save_config(self.config)
self._flush_to_config()
models.save_config(self.config)
imgui.end()
if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_theme_panel")

View File

@@ -1,8 +1,9 @@
import time
import math
import random
from imgui_bundle import imgui
class ScanlineOverlay:
class CRTFilter:
def __init__(self):
self.enabled = True
@@ -10,9 +11,28 @@ class ScanlineOverlay:
if not self.enabled:
return
draw_list = imgui.get_foreground_draw_list()
color = imgui.get_color_u32((0.0, 0.0, 0.0, 0.06))
# Scanlines
scanline_color = imgui.get_color_u32((0.0, 0.0, 0.0, 0.06))
for y in range(0, int(height), 2):
draw_list.add_line((0.0, float(y)), (float(width), float(y)), color, 1.0)
draw_list.add_line((0.0, float(y)), (float(width), float(y)), scanline_color, 1.0)
# Subtle Vignette
v_steps = 15
for i in range(v_steps):
alpha = (i / v_steps) ** 2.0 * 0.15
v_color = imgui.get_color_u32((0.0, 0.0, 0.0, alpha))
inset = (v_steps - i) * 6.0
if width > inset * 2.0 and height > inset * 2.0:
draw_list.add_rect((inset, inset), (width - inset, height - inset), v_color, 40.0, 0, 10.0)
# Subtle Random Noise
for _ in range(30):
nx = random.uniform(0.0, width)
ny = random.uniform(0.0, height)
n_alpha = random.uniform(0.01, 0.03)
n_color = imgui.get_color_u32((1.0, 1.0, 1.0, n_alpha))
draw_list.add_rect_filled((nx, ny), (nx + 1.0, ny + 1.0), n_color)
class StatusFlicker:
def get_alpha(self) -> float: