GPU Optimization • WebGL 2.0 • Real-Time Systems

Zero-Dependency WebGL Shader & Texture Memory Optimization Pipeline

Engineered a web-based, real-time asset optimization pipeline that automates texture channel packing, executes custom WebGL fragment shader passes, and reduces browser VRAM footprint by up to 75% while locking rendering at 60 FPS.

Live Telemetry & Benchmark Metrics

VRAM Reduction
75.0%
56.8 MB → 14.2 MB
Frame Stability
60.0 FPS
16.6 ms frame budget
Sampler Overhead
-75%
4 units → 1 unit
Pass Latency
<0.4 ms
Direct in-browser execution

Key Engineering Architecture

1. RGBA Channel Packing & Coalescing

Discrete grayscale PBR material maps (Roughness, Metallic, Ambient Occlusion, and Height) are consolidated into a single 32-bit RGBA texture. This compresses memory footprint and removes memory fragmentation on the GPU.

2. Single-Pass Sampler Elimination

Replaces 4 independent texture lookups in the fragment shader with a single vectorized sample (texture2D(u_packedPBR, vUv)), eliminating texture unit stalls and reducing memory bus pressure.

3. Zero-Dependency Client Execution

Runs 100% client-side via raw WebGL 2.0 and HTML5 Canvas with sub-second TTFB, requiring zero backend servers, Docker containers, or expensive cloud GPU processing clusters.

4. Embedded Telemetry Profiler HUD

Direct on-canvas monospace overlay HUD computing exponential moving average FPS, delta frame times, draw calls, and dynamic VRAM byte delta calculations in real time.

GLSL Shader Sampling Pipeline

// 1. Uniform Declaration (1 Combined RGBA Texture instead of 4)
uniform sampler2D u_packedPBR; 

// 2. Fragment Shader Sampling (Single Texture Lookup)
void main() {
    vec4 pbrSample = texture2D(u_packedPBR, vUv);
    
    float roughness = pbrSample.r; // Red Channel
    float metallic  = pbrSample.g; // Green Channel
    float ao        = pbrSample.b; // Blue Channel
    float height    = pbrSample.a; // Alpha Channel (Displacement)

    // Standard PBR BRDF evaluation with 1/4th the texture sampler pressure
    vec3 directLight  = evaluatePBR(vNormal, vViewDir, roughness, metallic);
    vec3 ambientLight = u_ambientColor * ao;
    
    gl_FragColor = vec4(directLight + ambientLight, 1.0);
}

Tech Stack & APIs

WebGL 2.0GLSL ShadersTypeScriptHTML5 Canvas APIPBR RenderingVRAM Profiling

Experience the Live Optimization Pipeline

Inspect channel assignments, test live packing, and examine real-time WebGL shader rendering directly in your browser.