GitHub
Translate

Opens Google Translate in a new tab. Website translation availability varies by region. Details

Color Science • WebGL2 Shader Guide

Additive Color Blending & Custom Colors

When a FluxFX WebGL2 shader draws on top of a background color (bgColor), the backdrop and the effect colors (color1, color2, color3) mathematically combine on every pixel to create new luminous or pigment tones. Understanding how this blending works lets you design your own custom look on demand.

1. What is Additive Color Blending (and Why a 3rd Color Appears)?

Every WebGL2 shader starts with a canvas background layer (uBgColor) and draws animated ribbons, waves, or ink plumes using your 3 effect colors (uColor1, uColor2, uColor3). Depending on the shader and backdrop brightness, FluxFX uses three optical blending equations:

Additive Light Blending

result = bgColor + (effectColor × intensity). Light energy adds together — dark/black backgrounds make colors glow vibrantly, and overlapping beams brighten toward white (e.g., aurora dark mode, fluid glowing dye, aetheria dark abyss, and specular rim glow).

Linear / Alpha Pigment Mixing

result = mix(bgColor, effectColor, mask). Smoothly interpolates between background and foreground color. Placing warm orange/pink over deep blue creates rich purple mid-tones cleanly without blowing out brightness.

Optical Absorption (Beer-Lambert)

result = bgColor × exp(-pigment × density). Used in aetheria light mode like real watercolor on paper: ink absorbs wavelengths from bgColor, so blue pigment over cream or yellow paper produces authentic teal/green tones.

Why does theme="auto" also shift colors? When you pass a single colors array without separate lightColors or darkColors, FluxFX checks whether the page background is light or dark. On bright light pages, neon hexes are automatically balanced into rich pigment shades so text stays readable; setting explicit bgColor + theme or lightColors / darkColors gives you exact pixel control.

2. How Core WebGL2 Effects Mix bgColor + colors

Effect bgColor Role colors: [C1, C2, C3] Role Blending Behavior
aurora Night sky or light silk canvas Primary curtain, secondary veil, high shimmer core Gaussian curtain waves blend C1↔C2↔C3; luminous lift on dark backgrounds, translucent silk wash on light backgrounds.
liquid-metal Ambient metallic basin tint Shadow metal base, ridge chrome body, specular/Fresnel highlight Trigonometric heightfield normals apply diffuse lighting over bgColor ↔ C2 plus additive specular & Fresnel rim glow from C3.
fluid Clean fluid tank backdrop Primary velocity dye, secondary splash dye, high-energy core glow Ping-Pong FBO advects dye; dark mode mixes dye and adds C3 + specular; light mode blends silky pigment onto bright paper.
ink Water / paper base Primary pigment plume, secondary ink stream, gradient filament rim Curl vorticity spreads ink with UV gradient refraction; mixes bgColor toward C1..C3 with crisp surface rim highlights.
aetheria Optical medium (paper or abyss) Plume A ink, Plume B ink, filament intersection dye Switches automatically between subtractive Beer-Lambert light absorption on bright bgColor and additive bioluminescence on dark bgColor.
spotlight Cyclorama room wall Wall tint wash, outer halo wash, intense core beam Dual Gaussian spotlight beams follow cursor movement smoothly and fade naturally into bgColor with anti-banding grain.

3. Interactive Color Blending Lab

Switch between shaders below and independently adjust Background Color vs Effect Colors (Color 1, Color 2, Color 3) to see how they blend in real time — and copy your custom configuration right below.

Blending Lab: aurora Independent BG + FG Color Mixing
Shader Effect
Background Color #050816
Effect Colors (C1 / C2 / C3)
Curated Recipes
Live Generated HTML (Your Custom Mix)
<section
  data-fx="aurora"
  data-fx-bg-color="#000000"
  data-fx-colors="#4f46e5, #06b6d4, #ec4899"
  style="min-height: 60vh;"
>
  <div style="position: relative; z-index: 1;">Your Content</div>
</section>

4. How to Build Your Own Color Palette (Step-by-Step)

  1. Pick your surface first (bgColor): Choose deep black/navy (#000000, #080a17) for additive neon light energy, warm off-white (#f8fafc, #f5f3ee) for editorial watercolor/silk washes, or 'transparent' to blend directly over a CSS gradient or photo.
  2. Follow the 3-Step Value Ladder for colors:
    • color1 (Shadow / Anchor): richest, deepest hue in your brand palette.
    • color2 (Body / Transition): vibrant mid-tone that bridges color1 and color3 without muddy grey crossover (keep neighboring hues within ~60–120° on the color wheel for silky transitions).
    • color3 (Core / Specular): brightest tint or contrasting spark for ridges, intersections, and Fresnel rims.
  3. Separate Light & Dark Sites cleanly: Pass both lightColors and darkColors whenever your app has a dark/light toggle so FluxFX smoothly tweens between two tailored palettes instead of auto-scaling one.
Dual-Theme Palette Recipe • ts
FluxFX.apply(el, 'aurora', {
  theme: 'auto',
  lightColors: ['#6366f1', '#0ea5e9', '#ec4899'], // Crisp silk over bright sections
  darkColors:  ['#312e81', '#06b6d4', '#f472b6'], // Deep neon glow on dark sections
});