From d4cfd14fc609449ec4e66962b3ceebf397453f31 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 1 Feb 2026 13:32:52 -0600 Subject: [PATCH] fix(immersive): prevent black from dominating in B&W artwork Problem: brightness(0.5) made whites gray while blacks stayed black, causing dark areas to dominate even in mostly-white artwork. Solution: - Increased brightness from 0.5 to 0.7 - Added shadow lift: maps 0-255 to 25-255 - Black now becomes dark gray (~10% brightness floor) - Whites remain visible and balanced Result: 'Panda/cow' effect - both light and dark areas visible. --- src/lib/immersive/utils/texture-loader.ts | 25 +++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/lib/immersive/utils/texture-loader.ts b/src/lib/immersive/utils/texture-loader.ts index 7ed47271c..1941d04c3 100644 --- a/src/lib/immersive/utils/texture-loader.ts +++ b/src/lib/immersive/utils/texture-loader.ts @@ -148,8 +148,8 @@ function applyExtremeBlur( /** * Apply color adjustments to create atmospheric mood. * - Boost saturation (preserve mood) - * - Reduce brightness (background use) - * - Reduce contrast (smooth gradients) + * - Moderate brightness reduction (keep whites visible) + * - Lift shadows (prevent pure black from dominating) */ function applyColorAdjustments( sourceCanvas: HTMLCanvasElement @@ -161,10 +161,27 @@ function applyColorAdjustments( const ctx = canvas.getContext('2d'); if (!ctx) return sourceCanvas; - // Saturation boost + brightness/contrast reduction - ctx.filter = 'saturate(1.4) brightness(0.5) contrast(0.85)'; + // First pass: moderate darkening with saturation boost + ctx.filter = 'saturate(1.5) brightness(0.7) contrast(0.9)'; ctx.drawImage(sourceCanvas, 0, 0); + // Second pass: lift shadows by blending with dark gray + // This prevents pure black from dominating + const imageData = ctx.getImageData(0, 0, size, size); + const data = imageData.data; + + // Shadow lift: map 0-255 to 25-255 (black becomes dark gray) + const shadowFloor = 25; // Minimum brightness (~10%) + const range = 255 - shadowFloor; + + for (let i = 0; i < data.length; i += 4) { + data[i] = shadowFloor + (data[i] / 255) * range; // R + data[i + 1] = shadowFloor + (data[i + 1] / 255) * range; // G + data[i + 2] = shadowFloor + (data[i + 2] / 255) * range; // B + } + + ctx.putImageData(imageData, 0, 0); + return canvas; }