Frame order
Compute
Section titled “Compute”- Particle simulation. Reads the original positions, writes the current ones. Skipped entirely when scene speed is zero.
- Grid clear and insert, merged into one pass. See The spatial grid.
Pass 1 — the background
Section titled “Pass 1 — the background”The swapchain texture is acquired once, before this pass, and every pass that draws to the screen reuses it — see Two rules from iOS Safari.
In order: particles, then any extra particle layers, then axes, then text.
Text draws here deliberately, so it lands in the background copy and refracts behind glass.
The split, and when it does not happen
Section titled “The split, and when it does not happen”With no glass in the scene, there is no split. Everything continues in the
same render pass — one beginRenderPass, no texture copy.
When glass is present, pass 1 ends and the swapchain is copied into the background texture. Then, in order:
- Shape pre-pass — opt-in, only when
enableReflectionorenableRefractionis set and a non-glass shape is visible. Draws the non-glass SDF shapes into their own texture and depth target atprepassScale× the canvas, so glass can sample them: fast shapes, the<Fast>halo with its depth when a wrapper has one, the effect shapes’ depth, then the effect shapes. Both flags share this one pass, and it runs on the flag alone, whether or not a glass shape reads it. - Mip generation — up to two chains, each built only if something reads a
level above zero. The background chain runs for
roughness,anisotropyoranisotropyBluron a glass material. The shape chain runs after the pre-pass, forreflectionRoughness, or for that same blur whenenableRefractionis on. - Back-face position pre-pass — mesh glass only, to find where a ray exits the model.
- Pass 2 begins, clearing depth rather than loading it — see Two rules from iOS Safari.
Pass 2 — the scene
Section titled “Pass 2 — the scene”Fast SDFs → mesh → glass SDFs → the <Fast> halo → effect SDFs → the rig
gizmo, against one shared depth attachment. See
Depth and z-sort.
What this costs
Section titled “What this costs”The split, the copy, the pre-pass and each mip chain are all conditional. A scene with no glass pays for none of them. A scene with glass but neither reflection nor refraction pays for the copy but not the pre-pass. Turning on both flags costs barely more than turning on one, because they share the pass.