What a field actually costs
A 2D distance field has no raymarch loop to blame. The cost is simply the whole scene function, evaluated once per pixel, for every pixel on screen. Which means the naive version scales with primitive count times resolution, and nothing about it gets cheaper when the object is off in a corner.
Left is uniformly hot, because it is uniformly expensive: a pixel in empty space does exactly the same work as a pixel in the middle of the busiest blend. Right is cold almost everywhere and only pays near the geometry.
Why you can skip, and why you still have to return something
A blob influences the blended field only within its radius plus roughly the blend
radius. Past that its contribution to smin is smaller than the float can
represent, so evaluating it changes nothing.
But you cannot simply continue and return a wrong distance. The field
still has to be a valid lower bound everywhere, or anything that consumes it breaks:
a march oversteps, a glow gets the wrong width, an outline lands in the wrong place.
The distance to the bounding circle is exactly such a bound, and it is one
length:
float toC = length(p - c);
if (toC > r + k*2.5) {
d = min(d, toC - r); // conservative, still correct
continue; // skip the real evaluation
}
The honest accounting
The branch is not free. GPUs execute in lockstep across a group of pixels, so a group straddling the boundary pays for both paths, and the win only appears when whole groups skip together. That is why this works well for scattered blobs and poorly for thin structures spread across the frame: coherence is what you are actually buying.
Which also means the counter in this demo is optimistic. It counts evaluations per pixel, and the hardware charges per group. Treat the heatmap as showing where the opportunity is, not as a frame time.
Rules of thumb
- Cost is primitives times pixels. Neither factor cares where the object is until you make it care.
- Every early-out must still return a conservative lower bound, never a wrong one.
- Bound by radius plus blend radius. Forgetting the blend term clips the fillet and it shows.
- Wins come from whole groups skipping together, so scattered clusters beat thin spread-out structures.
- Measure with a heatmap before optimizing. The expensive pixels are rarely where they feel like they are.
One email when something new goes up. No newsletter, no schedule, nothing else.
Double opt-in, so watch for a confirmation email. Unsubscribe any time.