scene_gap(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– scene_gap(3) β€” the Allegro manual, but make it make sense πŸ’–

okay bestie, we're in the Allegro manual, section 3, and today's main character is scene_gap. It's a global variable, it's a float, and it decides how your scene's z-sorting algorithm behaves. That's it, that's the whole vibe. Let's get into it πŸ¦‹


✨ SYNOPSIS ✨

#include <allegro.h>

extern float scene_gap;

🌸 DESCRIPTION 🌸

So. This number β€” and its default value = 100.0 β€” is the little dial that controls how the z-sorting algorithm acts. Here's the situation: when an edge gets very close to another polygon's plane, there's this whole interval of uncertainty where you genuinely cannot tell which object is visible (aka which z is smaller). Why? Because of cumulative numerical errors on edges that have gone through a LOT of transformations and interpolations. It's giving ✨floating point chaos✨, no cap.

Here's what the default value actually means: if the 1/z values (in projected space) differ by only 1/100 β€” that's one percent β€” then they get treated as equal, and the x-slopes of the planes are used to figure out which plane is getting closer as we move to the right. periodt.

Now, the tuning tea β˜•:

  • Larger values mean narrower margins, and that means an increasing chance of missing true adjacent edges/planes. πŸ’€
  • Smaller values mean larger margins, and that means an increasing chance of mistaking close polygons for adjacent ones. 😭

The value of 100 is close to the optimum. However β€” and this is important β€” the optimum shifts slightly with resolution, and it may be application-dependent. So it's literally here for you to fine-tune. slay 🫢

ngl bestie, don't just assume 100.0 is the answer for every single project. It's close to optimal, not guaranteed optimal. Go fine-tune it, you got this πŸ‘‘

πŸ‘€ SEE ALSO πŸ‘€


that's the whole page, bestie, go forth and z-sort responsibly πŸ’…βœ¨

this little love letter comes to you from Allegro, version 4.4.3 β€” mwah, talk soon πŸŽ€πŸ’–

πŸ“¦ where this page comes from