Files
qbz/src/lib/immersive/shaders/ambient.frag
T
vicrodh 9d3f05025a fix(immersive): preserve blue colors and improve lyrics readability
Shader:
- Fixed luminance formula that was killing blue (30% blend instead of 100%)

Lyrics:
- Added Oswald font for immersive lyrics
- Increased font size by 2pt (26px inactive, 28px active)
- Active lines now pure white with higher weight for clarity
2026-02-01 11:58:47 -06:00

67 lines
2.1 KiB
GLSL

#version 300 es
/**
* Ambient Post-Process Shader
*
* Displays a PRE-BLURRED texture with subtle ambient motion.
* Additional GPU-side smoothing via multi-sample.
*
* Effects:
* - Multi-sample blur (4 corners averaged)
* - Luminance preservation over saturation
* - Gradient tint (cool top, warm bottom)
* - Slow UV drift
* - Subtle zoom breathing
*/
precision mediump float;
in vec2 v_texCoord;
out vec4 fragColor;
uniform sampler2D u_texture;
uniform float u_time;
uniform float u_intensity;
void main() {
vec2 uv = v_texCoord;
vec2 center = vec2(0.5);
// Slow UV drift
float driftX = sin(u_time * 0.1) * 0.04 * u_intensity;
float driftY = cos(u_time * 0.08) * 0.03 * u_intensity;
uv += vec2(driftX, driftY);
// Subtle zoom breathing
float zoom = 1.0 + sin(u_time * 0.06) * 0.03 * u_intensity;
uv = center + (uv - center) / zoom;
// Clamp to valid range
uv = clamp(uv, 0.0, 1.0);
// Multi-sample blur (4 corners averaged for extra smoothing)
float offset = 0.01;
vec3 c1 = texture(u_texture, uv + vec2( offset, offset)).rgb;
vec3 c2 = texture(u_texture, uv + vec2(-offset, offset)).rgb;
vec3 c3 = texture(u_texture, uv + vec2( offset, -offset)).rgb;
vec3 c4 = texture(u_texture, uv + vec2(-offset, -offset)).rgb;
vec3 color = (c1 + c2 + c3 + c4) * 0.25;
// Gentle luminance-aware adjustment (preserves color, reduces harsh contrast)
float luma = dot(color, vec3(0.2126, 0.7152, 0.0722));
// Mix original color with luminance-adjusted version (30% adjustment, 70% original)
vec3 lumaColor = color * (luma / max(length(color), 0.001));
color = mix(color, lumaColor, 0.3);
// Gradient tint (cool top, warm bottom) - anti-flat
vec3 tintTop = vec3(0.95, 0.97, 1.0); // Cool/blue
vec3 tintBottom = vec3(1.0, 0.96, 0.92); // Warm/orange
float t = v_texCoord.y; // Use original UV for gradient
color *= mix(tintBottom, tintTop, t);
// Subtle brightness breathing
float breath = 1.0 + sin(u_time * 0.12) * 0.06 * u_intensity;
color *= breath;
fragColor = vec4(color, 1.0);
}