diff --git a/tron-room-demo/README.md b/tron-room-demo/README.md index 23537b8..88d070e 100644 --- a/tron-room-demo/README.md +++ b/tron-room-demo/README.md @@ -26,9 +26,8 @@ push, which on the device ships the 565 buffer as-is). - `#` walls, `o` cover crates, the `+` blast door and the `T` terminal as solid shaded boxes: backface culling, painter's-algorithm depth sort, lambert lighting from above, bright top rims, and depth fog — - geometry fades toward a steel haze color with camera distance - (aerial perspective), so the far deck dissolves atmospherically - instead of just darkening. + geometry blends toward the background color with camera distance, so + the far deck dissolves seamlessly into the void. - Floor tiles as lit quads with a subtle checker. - The demo map's **network graph** as glowing pylons with teal link lines and cyan packets traveling along the edges. diff --git a/tron-room-demo/RoomViewCore.h b/tron-room-demo/RoomViewCore.h index f770642..527d101 100644 --- a/tron-room-demo/RoomViewCore.h +++ b/tron-room-demo/RoomViewCore.h @@ -70,11 +70,10 @@ static inline uint16_t shade565(uint16_t c, int f32) { return (uint16_t)((r << 11) | (g << 5) | b); } -// --- Depth fog (aerial perspective) ------------------------------------------- -// Geometry fades toward a haze color with camera distance, instead of -// merely darkening: near surfaces stay crisp and saturated, the far deck -// dissolves into the haze. Integer fixed-point on the 5/6/5 channels. -static const uint16_t COL_FOG = 0x4AAD; // cool steel haze (76,88,104) +// --- Depth fog (fade into the void) ------------------------------------------- +// Geometry blends toward the background color with camera distance, so the +// far deck dissolves seamlessly into the void instead of merely darkening. +// Integer fixed-point on the 5/6/5 channels. static const float FOG_NEAR = 16.0f; // distance where fog starts static const float FOG_FAR = 50.0f; // distance of full fog @@ -86,15 +85,18 @@ static inline int fogAmt(float d) { return f; } -// Blend a native 565 color toward the fog color by a 0..32 fixed-point amount. +// Blend a native 565 color toward the background color by a 0..32 +// fixed-point amount. Weighted-average form (all terms positive), so it +// is exact at both ends: f32=0 returns c, f32=32 returns COL_BG. static inline uint16_t fogMix(uint16_t c, int f32) { if (f32 <= 0) return c; if (f32 > 32) f32 = 32; + int inv = 32 - f32; int r = (c >> 11) & 31, g = (c >> 5) & 63, b = c & 31; - int fr = (COL_FOG >> 11) & 31, fg = (COL_FOG >> 5) & 63, fb = COL_FOG & 31; - r += ((fr - r) * f32 + 16) >> 5; - g += ((fg - g) * f32 + 32) >> 6; - b += ((fb - b) * f32 + 16) >> 5; + int fr = (COL_BG >> 11) & 31, fg = (COL_BG >> 5) & 63, fb = COL_BG & 31; + r = (r * inv + fr * f32 + 16) >> 5; + g = (g * inv + fg * f32 + 32) >> 6; + b = (b * inv + fb * f32 + 16) >> 5; return (uint16_t)((r << 11) | (g << 5) | b); }