Building a Real-Time Optical Voice Orb in C++20, Qt 6, and GLSL

Share:

Most of my career has been platform engineering, cloud, and Kubernetes. I don't write fragment shaders or design motion graphics. Most of the animated voice orbs you see online are pre-rendered in After Effects or Cinema 4D, and I wanted to know whether I could build one in real time: real glass optics and conversational sound waves in a single GLSL 440 fragment shader, running at 60 to 120fps inside a C++20 + Qt 6.11 studio app on macOS Metal.

The idea came from @minimalnerd's minimalist orb concept, and I built it in an interactive visual loop with Google Antigravity and Gemini 4 Neon. ART-02 renders a clear glass sphere with animated spectral waveforms inside it. An isotropic bubble-zoom transition then releases them into four overlapping voice lobes. It works on a pure #000000 dark background and on a light studio background.

Three stages of the ART-02 real-time Qt 6 Metal shader: clear glass sphere with Snell refraction, isotropic bubble-zoom release, and four additive conversational voice waves.

1. Ray-sphere refraction with Snell's law and Cauchy dispersion

My early prototypes faked the orb by painting gradients inside a circle, and they looked flat. Switching to Snell refraction gave the sphere depth and produced the chromatic rim caustics, in six lines of GLSL.

For each pixel on the front hemisphere, the shader computes the surface normal N, refracts the view ray -V into glass with IOR = 1.46, and intersects the equatorial plane (z = 0) where the four waveforms live:

vec2 refractSphereEq(vec2 sPos, float z, float ior) {
    vec3 V = vec3(0.0, 0.0, 1.0);
    vec3 N = normalize(vec3(sPos.x, sPos.y, max(z, 0.02)));
    vec3 R = refract(-V, N, 1.0 / ior);
    float tHit = -z / min(R.z, -0.14);
    return (sPos + R.xy * tHit) * 1.08;
}

The shader calls refractSphereEq three times with slightly different Cauchy indices: 1.41 for red, 1.46 for green, and 1.51 for blue. That gives rainbow dispersion along the curved walls without any hand-tuned color. A tight Schlick Fresnel rim at grazing angles (pow(1.0 - z, 7.5)) keeps the inside of the sphere clear, so it reads as hollow.

2. Four filled additive lobes

An easy mistake when recreating voice waveforms is to draw thin, fuzzy Gaussian strokes. Overlapping light ribbons look more like filled translucent sheets, with sharp edges that the Fresnel term brightens.

In intelligence_orb.frag, each lobe (ruby red, cobalt blue, emerald-cyan, and warm amber) sits between a lower cradle curve and an upper bell curve. Both taper smoothly to zero at the horizontal tips (u = ±1), so each waveform has a clean lens silhouette and nothing clips at the edges:

float opticalRibbonBand(float u, float y, float yLo, float yHi, float aa, float tipFade) {
    float lo = min(yLo, yHi);
    float hi = max(yLo, yHi);
    float fill = smoothstep(lo - aa, lo + aa, y)
               * (1.0 - smoothstep(hi - aa, hi + aa, y));
    float tNorm = clamp((y - lo) / max(hi - lo, 0.0001), 0.0, 1.0);
    float crestShade = 0.48 + 0.42 * pow(abs(tNorm * 2.0 - 1.0), 1.6);
    float rimW = max(aa * 1.8, 0.004);
    float crestRim = (exp(-abs(y - hi) / rimW) * 0.42 + exp(-abs(y - lo) / rimW) * 0.28)
                   * smoothstep(0.002, 0.018, hi - lo);
    return (fill * crestShade + crestRim) * tipFade;
}

The four lobes are summed additively with a highlight shoulder that preserves color, so the secondary colors appear on their own. Red and blue mix into violet in the center, red and amber warm the left shoulder, and where all four meet along the lower crest the light blooms to #FFFFFF.

To make the motion feel conversational, each lobe gets its own vocal-formant envelope built from integer harmonics of a 5.0-second loop phase. The lobes swell like syllables, and because every harmonic divides the loop evenly, the loop is exactly seamless.

3. The bubble-zoom release

I didn't want to squash the sphere into an oval or cross-fade between two scenes. During the morph (uMorph: 0 → 1), the orb behaves like a clear soap bubble expanding past the camera lens:

  • The sphere scales isotropically (sphereR = baseOrbR * (1.0 + pow(m, 1.15) * 1.65)) while its Fresnel rim thins out and disappears, with no particles and no distortion.
  • At the same time, the lens power relaxes from IOR = 1.46 to 1.00 (air), and the waves inside zoom out to 85% of the frame width.
  • On light backgrounds, the shader puts a dark crystal backing and a soft ground shadow behind the additive core, so the same physics stays readable and the waves don't wash out.

4. Ahead-of-time shaders and deterministic 60fps export in Qt 6

Qt 6 makes it easy to combine C++20, declarative QML, and portable GPU shaders. One CMake macro runs qsb at build time and compiles Vulkan-style GLSL 440 ahead of time into Apple Metal MSL, Vulkan SPIR-V, and Direct3D 12 HLSL:

qt_add_shaders(qt_demo_studio "art_shaders"
    PREFIX "/shaders"
    BASE shaders
    FILES
        shaders/liquid_glass.frag
        shaders/intelligence_orb.frag
)

IntelligenceOrb.qml drives the shader uniforms directly. During interactive preview it passes live FrameAnimation time. For export it switches automatically to a C++20 QML_SINGLETON (StudioCaptureController) that steps time at exactly dt = 1/60s and pipes each frame into ffmpeg, so the 60fps MP4 has no dropped frames. The Release build has zero qmllint warnings.

5. Moving from infrastructure into native UI with Antigravity and Gemini 4 Neon

If your day job is Kubernetes clusters, cloud architecture, and platform tooling, native UI and GPU shaders can feel like a different discipline. The concepts were usually manageable. Most of the friction came from weeks of unfamiliar boilerplate across CMake, QML binding rules, shader reflection layouts, and rendering math, all before you could judge whether a visual looked right.

Working in Antigravity with Gemini 4 Neon closed most of that gap, and I could still see and check what it was doing at each step.

The first version of this orb was wrong. The tips clipped vertically, the white belly was over-exposed, and the glass rim looked murky. I shared live screenshots and references inside Antigravity, and Gemini 4 Neon traced each artifact to the GLSL math behind it, refactored the Snell refraction and the additive curves, rebuilt the native binary, and ran all_qmllint in seconds. The time I saved came from that loop of looking and fixing; nothing came out right in one generation.

Platform engineers already know how to write clear specs, isolate boundaries, verify builds, and automate pipelines, and those habits carry straight over to UI work. With the tool handling the C++20, QML, and GLSL mechanics, I could spend my time on architecture, physical accuracy, and polish, from shader compilation through deterministic ffmpeg capture.

Engineers outside frontend or graphics teams no longer have to stop at a CLI or hand the visual work to someone else. You can prototype and ship native, GPU-accelerated interfaces yourself.

You can watch the rendered 60fps loop on Instagram Reels or X. If you want to explore or contribute to open-source Qt, start at contribute.qt-project.org.