diff --git a/public/app.js b/public/app.js index ef7daac..192d10c 100644 --- a/public/app.js +++ b/public/app.js @@ -744,28 +744,45 @@ } } + const isTransparentMode = (cfg.backgroundMode === 'transparent'); + if (pType === 'starfield') { const k = 400 / p.z; const px = p.x * k; const py = p.y * k; - const pSize = Math.max(0.5, p.radius * k); + const pSize = Math.max(0.75, p.radius * k); if (Math.abs(px) < width / 2 && Math.abs(py) < height / 2) { + let pAlpha = p.alpha * (1 - p.z / 1000); + if (isTransparentMode) { + // In transparent mode, skip ultra-faint distant particles to prevent lossy VP9 macroblock artifacts + if (pAlpha < 0.22 || p.z > 750) continue; + pAlpha = Math.max(0.5, pAlpha); + } targetCtx.fillStyle = cfg.colorParticle || '#ffffff'; - targetCtx.globalAlpha = Math.min(1.0, p.alpha * (1 - p.z / 1000)); + targetCtx.globalAlpha = Math.min(1.0, pAlpha); targetCtx.beginPath(); targetCtx.arc(px, py, pSize, 0, Math.PI * 2); targetCtx.fill(); } } else if (pType === 'dust') { + let pAlpha = p.alpha * 0.6; + if (isTransparentMode) { + if (pAlpha < 0.22) continue; + pAlpha = Math.max(0.5, pAlpha); + } targetCtx.fillStyle = cfg.colorParticle || '#ffffff'; - targetCtx.globalAlpha = p.alpha * 0.6; + targetCtx.globalAlpha = pAlpha; targetCtx.beginPath(); targetCtx.arc(p.x, p.y, p.radius, 0, Math.PI * 2); targetCtx.fill(); } else if (pType === 'sparks') { + let pAlpha = p.alpha * (0.8 + rawBassEnergy * 0.5); + if (isTransparentMode) { + pAlpha = Math.max(0.6, pAlpha); + } targetCtx.fillStyle = cfg.colorParticle || '#ffffff'; - targetCtx.globalAlpha = Math.min(1.0, p.alpha * (0.8 + rawBassEnergy * 0.5)); + targetCtx.globalAlpha = Math.min(1.0, pAlpha); targetCtx.beginPath(); targetCtx.arc(p.x, p.y, p.radius * 1.2, 0, Math.PI * 2); targetCtx.fill(); @@ -1202,10 +1219,18 @@ targetCtx.shadowColor = cfg.colorGrad1 || '#00f0ff'; targetCtx.shadowBlur = 14; } else { - targetCtx.shadowColor = 'rgba(0, 0, 0, 0.85)'; - targetCtx.shadowBlur = 6; - targetCtx.shadowOffsetX = 0; - targetCtx.shadowOffsetY = 2; + if (cfg.backgroundMode === 'transparent') { + // Never draw muddy black shadows into pure alpha channels + targetCtx.shadowColor = 'transparent'; + targetCtx.shadowBlur = 0; + targetCtx.shadowOffsetX = 0; + targetCtx.shadowOffsetY = 0; + } else { + targetCtx.shadowColor = 'rgba(0, 0, 0, 0.85)'; + targetCtx.shadowBlur = 6; + targetCtx.shadowOffsetX = 0; + targetCtx.shadowOffsetY = 2; + } } // Gather active elements @@ -1804,13 +1829,14 @@ renderCanvas.height = targetHeight; const renderCtx = renderCanvas.getContext('2d', { alpha: true, willReadFrequently: true }); - // Determine Bitrate based on Resolution & Mode - let videoBitrate = 20_000_000; // 20 Mbps default + // Determine Bitrate based on Resolution & Mode (High bitrates prevent alpha macroblocking) + let videoBitrate = 35_000_000; // 35 Mbps default if (options && options.returnBlobOnly) { - videoBitrate = (targetWidth >= 3840) ? 35_000_000 : (targetWidth <= 1280 ? 8_000_000 : 14_000_000); + videoBitrate = (targetWidth >= 3840) ? 60_000_000 : (targetWidth <= 1280 ? 15_000_000 : 28_000_000); } else { - if (targetWidth >= 3840) videoBitrate = 50_000_000; - else if (targetWidth <= 1280) videoBitrate = 10_000_000; + if (targetWidth >= 3840) videoBitrate = 80_000_000; + else if (targetWidth <= 1280) videoBitrate = 20_000_000; + else videoBitrate = 45_000_000; } // Verify WebCodecs support