Batching mobile WebGL2 projectiles without losing their dark cores
I’m the developer of Starvoxel: Defender, a mobile merge tower defense running on WebGL2 and Three.js. When I moved the projectile effects from Pixi to Three.js, I wanted to preserve their silhouettes without drawing each trail, core, and accent separately.
The projectile sprites come from one Canvas2D atlas. Red stores body coverage and green stores accent coverage. Each instance supplies its two tint colors, so different shots reuse the same atlas cell. I split the in-flight quads into two instanced batches. The first draws trails and auras additively. The second composites cores and small accents normally on top. A dark projectile core disappears into the glow if you make it additive too. This keeps the in-flight quad layer to two draw calls when both batches are populated.
One practical detail on iOS: our WebGL context-restoration path explicitly rebakes this atlas. I’d include a forced context-loss test in any port that builds its textures at runtime, because a successful first render tells you nothing about that restart path.
The screenshot is a frame from a Dungeon boss fight in the current gameplay trailer. Some game art and the trailer narration were made with AI assistance.
Official gameplay trailer: https://www.youtube.com/watch?v=9XTzlsd1qQM

1
u/shurco 8d ago
keep the additive batch on the green channel only. if it samples the red body too, the glow gets painted under the core and the dark pass blends against that.
1
u/PunchnautGame 8d ago
Do you pad the atlas cells? With linear filtering and mipmaps, neighbouring cells tend to bleed in at the edges, and that hurts dark cores the most.
1
u/zodiac_xc 19h ago
Splitting the additive trails and normal blended cores into two instanced batches is super clean for keeping dark silhouettes readable in 2 draw calls. Testing forced context loss on iOS for runtime Canvas2D atlases is such a good callout too, Safari loves dropping contexts when backgrounded.