Skip to content

Commit fd95b51

Browse files
committed
refactor: decrease background image opacity and accelerate shader transition timings
1 parent b6eb6bb commit fd95b51

2 files changed

Lines changed: 30 additions & 26 deletions

File tree

js/bg-shader.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,62 +121,66 @@ function initBgShader() {
121121
122122
// ── Spacious fluid scale ─────────────────────────────
123123
// Lower = more zoomed out = more spacious/airy
124-
vec2 base = st * 0.5;
124+
vec2 base = st * 0.45; // slightly wider
125125
126126
// ── Slow breathing pulse ─────────────────────────────
127-
float breath = sin(t * 0.3) * 0.15 + 1.0;
127+
float breath = sin(t * 0.25) * 0.15 + 1.0;
128128
129129
// ── Single-layer domain warping (clean, not cluttered) ──
130130
vec2 q = vec2(
131-
fbm(base + vec2(t * 0.025, t * 0.015)),
132-
fbm(base + vec2(-t * 0.02, t * 0.03))
131+
fbm(base + vec2(t * 0.02, t * 0.01)),
132+
fbm(base + vec2(-t * 0.015, t * 0.025))
133133
);
134134
135-
// Gentle warp — lower multiplier = less merging
136-
float flow = fbm(base + 2.0 * q);
135+
// Gentle warp
136+
float flow = fbm(base + 1.8 * q);
137137
138138
// ── Colour palette ─────────────────────────────────────
139-
vec3 col1 = vec3(0.980, 0.976, 0.965); // off-white
140-
vec3 col2 = vec3(0.557, 0.792, 0.902); // brand blue
141-
vec3 col3 = vec3(0.920, 0.960, 0.980); // soft sky
142-
vec3 col4 = vec3(0.350, 0.620, 0.820); // deeper accent
139+
vec3 brandBlue = vec3(0.20, 0.65, 0.90); // strong brand blue
140+
vec3 skyBlue = vec3(0.40, 0.75, 0.95); // bright sky
141+
vec3 deepBlue = vec3(0.10, 0.45, 0.80); // rich deep accent
143142
144-
// Gentle, spacious colour blending
143+
// Calculate how "fluid" this pixel is
145144
float f = flow * breath;
145+
float fluidIntensity = smoothstep(-0.2, 0.8, f);
146146
147-
// Wide, soft gradient — not sharp transitions
148-
vec3 color = mix(col1, col3, smoothstep(-0.5, 0.6, f));
147+
// Base color is sky blue
148+
vec3 color = skyBlue;
149149
150-
// Subtle blue accent — reduced intensity to avoid "merging" look
151-
color = mix(color, col2, smoothstep(0.2, 1.0, q.x + q.y) * 0.35);
152-
color = mix(color, col4, smoothstep(0.6, 1.4, q.x * q.y + 0.5) * 0.15);
150+
// Mix in brand blue and deep blue based on the warp
151+
color = mix(color, brandBlue, smoothstep(0.2, 1.1, q.x + q.y));
152+
color = mix(color, deepBlue, smoothstep(0.5, 1.5, q.x * q.y + 0.4));
153153
154154
#ifndef IS_MOBILE
155155
// Subtle film grain (desktop only)
156-
float grain = fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453) * 0.02;
156+
float grain = fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453) * 0.025;
157157
color -= grain;
158158
159159
// Mouse hover — soft gradient pull
160160
vec2 mouse = u_mouse / u_resolution;
161161
mouse.x *= aspect;
162162
mouse.y = 1.0 - mouse.y;
163163
float mDist = distance(st, mouse);
164-
float hover = smoothstep(0.5, 0.0, mDist) * 0.15;
165-
color = mix(color, col2, hover);
164+
float hover = smoothstep(0.6, 0.0, mDist) * 0.2;
165+
color = mix(color, skyBlue, hover);
166166
167167
// Ripple colour bloom
168168
float bloom = exp(-tDist * 8.0) * strength;
169169
color = mix(color, vec3(1.0), bloom * 0.3);
170-
color = mix(color, col4, bloom * 0.4);
170+
color = mix(color, skyBlue, bloom * 0.5);
171171
#endif
172172
173173
// ── Vertical alpha fade ────────────────────────────────
174-
float alpha = smoothstep(0.0, 0.5, v_uv.y + 0.15);
174+
// Base transparency is the fluid intensity (so background shows through)
175+
float alpha = fluidIntensity;
176+
177+
// Fade out near the bottom
178+
float fade = smoothstep(0.0, 0.6, v_uv.y + 0.1);
175179
176180
#ifdef IS_MOBILE
177-
gl_FragColor = vec4(color, alpha * 0.9);
181+
gl_FragColor = vec4(color, alpha * fade * 0.6); // 60% opacity max on mobile
178182
#else
179-
gl_FragColor = vec4(color, alpha * 0.75);
183+
gl_FragColor = vec4(color, alpha * fade * 0.5); // 50% opacity max on desktop
180184
#endif
181185
}
182186
`;

js/shader-upgrade.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ function initHighResUpgrade(img) {
141141
if (!gl) { fallbackSwap(); return; }
142142

143143
var CONSTANTS = {
144-
imageOpacity: '0.60',
145-
cssTransitionMs: 500,
146-
shaderDurationMs: 3500
144+
imageOpacity: '0.40', // Reduced opacity so it doesn't cover the images too heavily
145+
cssTransitionMs: 300, // Faster fade
146+
shaderDurationMs: 1500 // Faster overall transition (was 3500)
147147
};
148148

149149
var dpr = window.devicePixelRatio || 1;

0 commit comments

Comments
 (0)