Bash.tv → GitHub → itch.io

Optimize GPU rendering in WebGL, three.js, Pixi and Phaser games. Measure draw calls, triangles, textures and frame time in the viewer's browser (never the sandbox), then reduce draw calls (instancing, merging, atlases, fewer materials), fill rate (pixel ratio, overdraw, transparent layers, post-processing), shader cost, shadow cost, texture memory (sizes, compression, mipmaps), avoid CPU-GPU s...

Download skill (.zip) Files on GitHub

WebGL performance

Measure in the viewer’s browser (look_at_preview, read_preview_console) or with check_gpu_render. The sandbox browser has no GPU and must not load these pages.

Measure

// three.js: log once per second (or show in a debug overlay)
const i = renderer.info;
console.log(`[gpu] calls ${i.render.calls} · tris ${i.render.triangles} · geos ${i.memory.geometries} · tex ${i.memory.textures} · programs ${i.programs.length}`);

Add game-performance-profiling’s perf-probe.js for fps and frame times. Find out which side is slow: halve the pixel ratio. If fps jumps, you’re fill-bound (pixels). If not, you’re draw-call / CPU bound.

Budget (mid phone) Target
Draw calls < 100–200
Triangles < 300k–500k
Pixel ratio ≤ 1.5–2
Texture memory < 150–256 MB
Shadow-casting lights 1

Fewer draw calls

Fewer pixels (fill rate)

Cheaper shading

Textures and memory

Hitches and stalls

Context loss

Phones drop WebGL contexts under memory pressure. Listen for webglcontextlost (preventDefault) and webglcontextrestored; at minimum show “Tap to reload” instead of a frozen frame.

Report

“Draw calls 1,240 → 96 (instanced trees and coins, merged level); pixel ratio 2 → 1.5 on phones; 34 → 60 fps in your preview.”