Skip to content

Commit 9ee6a48

Browse files
authored
Enhance LED emitter visibility and glow effects
2 parents b367bcb + 655374d commit 9ee6a48

4 files changed

Lines changed: 39 additions & 32 deletions

File tree

App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const SHADER_GROUPS = {
4949
};
5050

5151
function App() {
52-
const [shaderFile, setShaderFile] = useState<string>('patternv0.40.wgsl');
52+
const [shaderFile, setShaderFile] = useState<string>('patternv0.50.wgsl');
5353
const [volume, setVolume] = useState<number>(0.5);
5454
const [pan, setPan] = useState<number>(0.0);
5555

hooks/useAudioGraph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export async function startAudioPlayback(
175175
volume: data.channelVU[c] || 0,
176176
pan: existing?.pan ?? 128,
177177
freq: existing?.freq ?? 0,
178-
trigger: (data.channelVU[c] || 0) > 0.5 ? 1 : 0,
178+
trigger: (data.channelVU[c] || 0) > 0.05 ? 1 : 0,
179179
noteAge: existing?.noteAge ?? 0,
180180
activeEffect: existing?.activeEffect ?? 0,
181181
effectValue: existing?.effectValue ?? 0,

public/shaders/patternv0.49.wgsl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
289289
let rowDist = min(rowDistRaw, 64.0 - rowDistRaw);
290290
let playheadActivation = 1.0 - smoothstep(0.0, 1.5, rowDist);
291291

292-
// Hardware Layering: Discard pixels over UI — SAFE HERE after playheadActivation computed
293-
if (in.position.y > uniforms.canvasH * 0.88) {
294-
discard;
295-
}
296-
297292
// CHANNEL 0 is the Indicator Ring (padTopChannel shifts music to 1-32)
298293
if (in.channel == 0u) {
299294
let onPlayhead = playheadActivation > 0.5;
@@ -354,9 +349,9 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
354349
var topIntensity = 0.0;
355350
if (!isMuted) {
356351
if (ch.trigger > 0u) {
357-
topIntensity = 1.0 + bloom;
352+
topIntensity = 2.5;
358353
} else if (playheadActivation > 0.5) {
359-
topIntensity = playheadActivation * 0.6;
354+
topIntensity = playheadActivation * 1.2;
360355
}
361356
}
362357

@@ -381,7 +376,7 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
381376
let amberColor = vec3<f32>(1.0, 0.55, 0.1);
382377
var botIntensity = 0.0;
383378
if (!isMuted && hasExpression) {
384-
botIntensity = 0.8 + bloom;
379+
botIntensity = 2.0;
385380
}
386381

387382
// --- RENDER UNIFIED GLASS LENS ---
@@ -398,14 +393,21 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
398393

399394
finalColor = mix(finalColor, lens.rgb, lens.a);
400395

401-
// Add external glow when active
396+
// External glow — bloom-independent so LEDs are always visible
402397
if (topIntensity > 0.0 || botIntensity > 0.0 || midIntensity > 0.5) {
403398
let totalActivity = topIntensity + botIntensity + (midIntensity - 0.12);
404399
let glowColor = mix(midColor, blueColor, topIntensity * 0.5);
405400
let glowColor2 = mix(glowColor, amberColor, botIntensity * 0.5);
406-
let externalGlow = glowColor2 * totalActivity * bloom * 2.0 * exp(-length(p) * 4.0);
401+
let externalGlow = glowColor2 * totalActivity * (0.3 + bloom * 1.5) * exp(-length(p) * 4.0);
407402
finalColor += externalGlow;
408403
}
404+
// Direct LED glow independent of bloom
405+
if (!isMuted && ch.trigger > 0u) {
406+
finalColor += blueColor * 0.4 * exp(-length(p) * 3.5);
407+
}
408+
if (!isMuted && hasExpression) {
409+
finalColor += amberColor * 0.3 * exp(-length(p) * 3.5);
410+
}
409411
}
410412

411413
// Kick reactive glow

public/shaders/patternv0.50.wgsl

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,17 @@ fn drawUnifiedLensCap(
256256
// Top emitter scattering (Blue - note on)
257257
let distTop = length(uv - topPos - refractOffset * 0.3);
258258
let scatterTop = exp(-distTop * 5.0) * topEmitter.a;
259-
subsurfaceGlow += topEmitter.rgb * scatterTop * 0.8;
260-
259+
subsurfaceGlow += topEmitter.rgb * scatterTop * 3.5;
260+
261261
// Middle emitter scattering (Note color - steady)
262262
let distMid = length(uv - midPos - refractOffset * 0.5);
263263
let scatterMid = exp(-distMid * 4.0) * midEmitter.a;
264-
subsurfaceGlow += midEmitter.rgb * scatterMid * 1.5;
265-
264+
subsurfaceGlow += midEmitter.rgb * scatterMid * 5.0;
265+
266266
// Bottom emitter scattering (Amber - control)
267267
let distBot = length(uv - botPos - refractOffset * 0.3);
268268
let scatterBot = exp(-distBot * 5.0) * botEmitter.a;
269-
subsurfaceGlow += botEmitter.rgb * scatterBot * 0.8;
269+
subsurfaceGlow += botEmitter.rgb * scatterBot * 3.5;
270270

271271
let totalGlow = topEmitter.a + midEmitter.a + botEmitter.a;
272272
let diffusion = exp(-radial * 3.0) * totalGlow * 0.3;
@@ -285,10 +285,11 @@ fn drawUnifiedLensCap(
285285
// Edge alpha
286286
let edgeAlpha = smoothstep(0.0, aa * 2.0, -dBox);
287287

288-
// Glass transparency
288+
// Glass transparency — reduce opacity when active emitters are lit
289289
let diodeVisibility = diodeMask * 0.55;
290290
let baseAlpha = 0.72 + 0.28 * fresnel;
291-
let alpha = mix(baseAlpha, 0.32, diodeVisibility) * edgeAlpha;
291+
let emitterLift = clamp(topEmitter.a * 0.4 + botEmitter.a * 0.4, 0.0, 0.7);
292+
let alpha = mix(baseAlpha, 0.32, min(diodeVisibility + emitterLift, 0.9)) * edgeAlpha;
292293

293294
// Directional lighting
294295
let lightDir = vec3<f32>(0.4, -0.7, 0.6);
@@ -303,7 +304,7 @@ fn drawUnifiedLensCap(
303304
let diodeBlend = diodeMask * (1.0 - alpha * 0.65);
304305
finalColor = mix(finalColor, combinedDiode, diodeBlend);
305306
finalColor = mix(finalColor, litGlassColor, alpha);
306-
finalColor += subsurfaceGlow * 2.0;
307+
finalColor += subsurfaceGlow * 5.0;
307308

308309
// Concentrated glow around active emitters
309310
if (midEmitter.a > 0.05) {
@@ -342,11 +343,6 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
342343
let kick = uniforms.kickTrigger;
343344
let beat = uniforms.beatPhase;
344345

345-
// Hardware Layering: Discard pixels over UI
346-
if (in.position.y > uniforms.canvasH * 0.88) {
347-
discard;
348-
}
349-
350346
// Smooth playhead position
351347
let playheadStep = uniforms.playheadRow - floor(uniforms.playheadRow / 64.0) * 64.0;
352348
let rowDistRaw = abs(f32(in.row % 64u) - playheadStep);
@@ -414,12 +410,12 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
414410
var topIntensity = 0.0;
415411
if (!isMuted) {
416412
if (ch.trigger > 0u) {
417-
topIntensity = 1.0 + bloom;
413+
topIntensity = 2.5;
418414
} else if (playheadActivation > 0.5) {
419-
topIntensity = playheadActivation * 0.6;
415+
topIntensity = playheadActivation * 1.2;
420416
}
421417
}
422-
let topColor = blueColor * (1.0 + bloom * 2.0);
418+
let topColor = blueColor * (1.5 + bloom * 2.0);
423419

424420
// EMITTER 2 (MIDDLE): Steady Note Color
425421
// Shows pitch color steadily whenever there's a note (does NOT blink)
@@ -443,9 +439,9 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
443439
let amberColor = vec3<f32>(1.0, 0.55, 0.1);
444440
var botIntensity = 0.0;
445441
if (!isMuted && hasExpression) {
446-
botIntensity = 0.8 + bloom;
442+
botIntensity = 2.0;
447443
}
448-
let botColor = amberColor * (1.0 + bloom * 2.0);
444+
let botColor = amberColor * (1.5 + bloom * 2.0);
449445

450446
// --- DRAW UNIFIED LENS CAP ---
451447
let lensUV = btnUV - vec2<f32>(0.5, 0.5);
@@ -461,10 +457,19 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
461457

462458
finalColor = mix(finalColor, unifiedLens.rgb, unifiedLens.a);
463459

464-
// External glow when note is playing
460+
// External glow when note is playing on playhead
465461
if (playheadActivation > 0.5 && hasNote) {
466462
let pulseColor = mix(blueColor, amberColor, 0.5 + 0.5 * sin(beat * 6.2832));
467-
finalColor += pulseColor * playheadActivation * 0.15;
463+
finalColor += pulseColor * playheadActivation * 0.4;
464+
}
465+
466+
// Blue LED: bloom-independent external glow for active channels
467+
if (!isMuted && ch.trigger > 0u) {
468+
finalColor += blueColor * 0.4 * exp(-length(p) * 3.5);
469+
}
470+
// Amber LED: bloom-independent external glow for expression data
471+
if (!isMuted && hasExpression) {
472+
finalColor += amberColor * 0.3 * exp(-length(p) * 3.5);
468473
}
469474
}
470475

0 commit comments

Comments
 (0)