From 30ad5fbeaedf655e34d73bc001398d5caae3bd3e Mon Sep 17 00:00:00 2001 From: mikael-lovqvists-claude-agent Date: Sun, 29 Mar 2026 19:31:09 +0000 Subject: [PATCH] Fix no-signal noise: wrap time to [0,1000) to preserve float32 precision CLOCK_MONOTONIC returns seconds since boot (~50000+s on a running system). At that magnitude, float32 loses fractional precision in the hash function and all cells evaluate to near-zero, producing a black screen instead of noise. Wrapping to fmod(now, 1000.0) keeps the value small enough for the shader. Co-Authored-By: Claude Sonnet 4.6 --- src/node/Makefile | 2 +- src/node/main.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node/Makefile b/src/node/Makefile index 9e60899..b35a45d 100644 --- a/src/node/Makefile +++ b/src/node/Makefile @@ -23,7 +23,7 @@ $(NODE_BUILD)/video-node: $(MAIN_OBJ) \ $(COMMON_OBJ) $(MEDIA_OBJ) $(V4L2_OBJ) $(SERIAL_OBJ) \ $(TRANSPORT_OBJ) $(DISCOVERY_OBJ) $(CONFIG_OBJ) $(PROTOCOL_OBJ) \ $(RECONCILER_OBJ) $(INGEST_OBJ) $(XORG_OBJ) - $(CC) $(CFLAGS) -o $@ $^ -lpthread $(PKG_LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ -lpthread -lm $(PKG_LDFLAGS) $(MAIN_OBJ): main.c | $(NODE_BUILD) $(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $< diff --git a/src/node/main.c b/src/node/main.c index c387edd..0c66865 100644 --- a/src/node/main.c +++ b/src/node/main.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -533,7 +534,8 @@ static void display_loop_tick(struct Node *node) double now = (double)ts.tv_sec + (double)ts.tv_nsec * 1e-9; double interval = 1.0 / (double)(d->no_signal_fps > 0 ? d->no_signal_fps : 15); if (now - d->last_no_signal_t >= interval) { - xorg_viewer_render_no_signal(d->viewer, (float)now, 80.0f); + /* Wrap to [0, 1000) to preserve float32 fractional precision in shader */ + xorg_viewer_render_no_signal(d->viewer, (float)fmod(now, 1000.0), 80.0f); d->last_no_signal_t = now; } }