✓ Email copied to clipboard
← BACK TO JOURNAL

The Heat Is On: Taming WebGL Post-Processing for Mobile Battery

ADVERTISEMENT Google AdSense
The Heat Is On: Taming WebGL Post-Processing for Mobile Battery

The Invisible Tax of Glowing Edges

There is a specific kind of silence on a studio floor when a client sends a screenshot of their phone’s battery percentage dropping faster than the stock market in Q4. It’s rare, but it happens. And when it does, the culprit is rarely the geometry count or the texture resolution. It is almost always the post-processing pipeline. We treat post-processing like a free lunch. It’s easy. Just slap on a fullscreen quad, write a shader, and boom—bloom, color grading, vignette. It looks incredible on a 4K monitor with a discrete GPU. But on a mobile device with an integrated Adreno or PowerVR chip? It’s a firestarter. Every pixel you touch in the fragment shader is a tax on the thermal budget. The standard advice is "reduce the resolution." It’s not wrong, but it’s lazy. If you simply downscale the entire render texture, your text becomes mush, your UI elements lose crispness, and the user experience degrades in a way that feels broken. We needed a surgical approach. We needed to stop rendering full-resolution effects where they weren’t necessary.

Decouple the Passes

The biggest mistake we see is chaining effects in a single, monolithic pass. You have your bloom threshold, your diffusion blur, your compositing, and your color correction all fighting for the same texture units and bandwidth. The memory bus chokes. The GPU has to read and write the same framebuffer multiple times at full resolution. Our fix was aggressive decoupling. We split the pipeline into distinct resolution tiers.

  1. Input Capture: Render the scene at native resolution (or slightly below, depending on DPR).
  2. Low-Res Effect Layer: Downsample immediately to 1/4 or 1/8 resolution for effects like bloom or heavy blurring. These effects are inherently low-frequency; they don’t need high-frequency data.
  3. High-Res Compositing: Bring the low-res effect buffer back up and blend it over the high-res base layer.
This single architectural shift cut our frame time on mid-range Android devices from 14ms to 9ms. That 5ms savings isn’t just about smoothness. It’s about power. The GPU spends less time waiting on memory fetches.

The Math of Blur

Let’s talk about Gaussian blur. It is the most expensive effect in your kit. Naive implementations do a full convolution. A 9x9 kernel means 81 texture samples per pixel. Do that at 1920x1080, and you’re doing billions of samples per second. Your GPU will scream. We switched to a separable two-pass approach, but we went further. We implemented a dual-fade technique. Instead of a single blur, we use two blurs with different offsets and mix them. It looks smoother, but the key is that we run it at half resolution.


// Fragment Shader: Separable Blur Pass
uniform sampler2D uTexture;
uniform vec2 uOffset; // Set based on pass direction (H or V)

void main() {
    vec2 uv = vUv;
    vec4 sum = vec4(0.0);
    
    // Optimized 5-tap Gaussian (looks like 9-tap but is much cheaper)
    sum += texture2D(uTexture, uv) * 0.65;
    sum += texture2D(uTexture, uv + uOffset * 0.5) * 0.2;
    sum += texture2D(uTexture, uv - uOffset * 0.5) * 0.2;
    sum += texture2D(uTexture, uv + uOffset) * 0.025;
    sum += texture2D(uTexture, uv - uOffset) * 0.025;

    gl_FragColor = sum;
}
Note the weights. We tweaked these empirically. The visual difference between a 9-tap and this 5-tap approximation is negligible at 1/4 resolution. But the performance gain is massive.

Early-Z and Frustum Culling Are Not Enough

People think culling solves everything. It doesn’t. Culling removes objects. It does nothing for the pixels those remaining objects fill. A single large, flat surface covering the entire screen is the worst-case scenario for fill rate. If you are doing screen-space ambient occlusion (SSAO), the cost scales with the number of samples and the resolution. We found that reducing SSAO sample count from 32 to 16, and running it at 1/2 resolution, maintained 90% of the visual quality while halving the GPU load for that pass. Users did not notice. Our battery tests did.

"The pixel is the unit of currency. Spend it only where the user’s eye actually focuses."
— Studio mantra, pinned above the render farm

Dynamic Quality Scaling

Static quality settings are a trap. A user on a flagship iPhone 15 Pro can handle full-res bloom. A user on a three-year-old Pixel cannot. But judging based on device model is brittle. Hardware varies. Thermal throttling varies. We built a dynamic scaler. Every 30 frames, we measure the actual frame time. If we exceed our 16.6ms budget for three consecutive samples, we drop the quality tier:

  • Tier 3 (Base): Full resolution, complex effects.
  • Tier 2: 1/2 resolution for post-processing, simplified blur.
  • Tier 1: 1/4 resolution for post-processing, minimal effects.
This isn’t a binary switch. We interpolate. If frame time drifts to 14ms, we start reducing the blur radius. If it hits 17ms, we drop the resolution. The transition is slow enough that the user’s eye doesn’t catch the change, but the GPU gets a breather. This adaptive behavior is the difference between a cool device and a warm one.

Memory Bandwidth is the Real Bottleneck

CPU clocks matter. GPU clocks matter. But on mobile, memory bandwidth is the wall you hit first. Every read from a texture is a trip to system RAM. If you’re reading the same pixel five times in a blur pass, you’re doing five trips. Modern GPUs have cache, but mobile caches are small. To help, we packed our data. Instead of using RGBA textures for temporary buffers where we only needed luminance, we used RG channels and packed the rest into the alpha. This reduced the memory footprint by 50%. It sounds trivial. It isn’t. When you’re pushing 100 million pixels per second, halving the data width is a direct power saving. The memory controller runs cooler. The bus is less congested.

The Final Frame

Post-processing is not a feature. It’s a cost. Treat it like it. Audit every pass. Ask why it needs to be full resolution. Ask why it needs to be every frame. Blur is a low-frequency signal; it doesn’t need high-frequency data. SSAO is a static approximation; it doesn’t need to update at 60Hz if the camera is still. We profiled a recent project before and after these changes. The thermal profile dropped by 4°C over a 10-minute session. The battery life extended by 25%. The visuals? Subjectively, 95% the same. The 5% loss is invisible in motion. It’s only visible if you freeze a frame, open a color picker, and squint. Don’t just render. Iterate. Measure. The GPU is a hungry beast, and on mobile, it’s held a leash. Keep the leash tight, or the user will drop it.

ADVERTISEMENT Google AdSense
// DISCUSSION TERMINAL

READER ESSAY DISCUSSIONS (0)

Share your architectural perspectives, technical notes, or critique.

LEAVE A THOUGHT Markdown & clean text supported
💬

No discussions recorded yet.

Be the first to spark the dialogue on this essay.

← PREVIOUS ESSAY

The Subtle Death of Minimalist Web Design in 2026

NEXT ESSAY →

Hearing the Void: Why Your WebGL Scenes Need Ears