Understanding the wavy-like shape in alpha-testing magnification for text rendering

Started by
11 comments, last by JoeJ 2 weeks, 1 day ago

Okay so after looking at all those hints, I think I finally got it, (though, not 100% since there are some edge cases I am not sure about), but basically, it seems to me, as @JoeJ showed, it comes from bilinear filtering, so, assuming we are solving trying to test whether an alpha greater-equal some threshold (0.5 for example) for a particular square square, we have this equation:

 Mix(Mix(A0, A1, X), Mix(A2, A3, X), Y)

Which is the standard bilinear formula, where Ai is the alpha value and X,Y are the coordinates (or the coordinates fraction, with accounting to 0.5 pixel-center shift), This when expanded we get something like this:

aX + bY + cXY + d = FinalAlphaValue

which if we set FinalAlphaValue to 0.5, we get an equation of a hyperbola. which (I believe) matches the trace of the waviness in the images. for a particular pixel sampling, a,b,c,d depends on the alpha value so they are constant, and will only change when they we sample at another pixel, which make sense that it is repetitive, and it is identical. What I don't get about it, is why does it only happen on diagonal edges or so it seems? Like this equation would be causing waviness on all edges, but in the Valve's picture, it seems to be only causing this on a diagonal line.

None

Advertisement

AliAbdulKareem said:
What I don't get about it, is why does it only happen on diagonal edges or so it seems?

If the edge is aligned to the grid axis, either X or Y remain constant. So if we sample along the edge we stay always at the same ‘error’. We're still on a hyperbola as you've figured out, but we don't notice the curve slope since we don't move.

If the edge has some rotation but we still sample along, both X and Y oscillate linearly, but the projection on the hyperbola exposes the non linear, curvy weights causing the waves.

This still happens with SDF as well, but because the 4 sampled corners all agree on the result no waves show up.
With density the samples don't agree, due to the clipping.

Advertisement