A Pure D3D11 Frosted Glass Effect for Win32, with Zero Dependencies
Adding a modern frosted-glass UI to a native Win32 app has typically meant dragging in a heavy runtime like UWP, WinUI, Qt, or Electron. This library gives C++ desktop applications a lightweight, framework-free path to the same effect, with full control over the rendering pipeline and no dependency tax.
A new open-source library, WindowsLiquidGlass, brings macOS-style frosted glass to Win32 applications through a pure D3D11 and HLSL implementation. It requires only three source files and a chainable C++ API to add real-time Gaussian blur, rounded corners, saturation control, refractive distortion, and chromatic dispersion to any window. The effect runs on Windows 10 and 11 with a GPU supporting D3D11 Feature Level 11.0.
Each frame is built from five render passes: background capture, a separable 31-tap Gaussian blur split into horizontal and vertical passes, an SDF-based drop shadow, the core glass body with refraction and dispersion, and final alpha compositing. The blur weights are precomputed on the CPU to avoid millions of GPU-side exponential calculations per frame. Refraction uses a circleMap function to mimic a convex lens, and chromatic dispersion splits a single texture sample into seven offset samples with per-channel energy-conserving weights.
The implementation surfaced several sharp-edged D3D11 realities. HLSL constant-buffer alignment rules caused a 16-element float array to balloon from 64 to 256 bytes, misaligning all subsequent data. The `sign(0) = 0` edge case produced NaN gradients and white artifacts, but only when the glass rectangle had odd pixel dimensions. And D3D11's silent nulling of a shader resource view when a resource is still bound as a render target caused mysterious black-frame bugs.
The project's real contribution is not the visual effect itself — which is well-understood — but packaging it into a three-file, zero-dependency library that sidesteps the entire UWP/WinUI stack for native Win32 applications.
The chainable API design (`.Blur().Radius().Saturation()`) mirrors modern graphics-library ergonomics and makes the effect trivially adoptable in existing codebases.
The sign(0) bug that only manifests at odd pixel dimensions is a classic graphics gotcha: a mathematically correct edge case that becomes a visual artifact only under specific, non-obvious conditions, making it extremely hard to reproduce and diagnose.
Precomputing Gaussian weights on the CPU is a pragmatic optimization that acknowledges GPU compute is better spent on sampling and blending than on transcendental math, even though modern GPUs could handle the exp() calls.