Skip to content

Commit 372634e

Browse files
committed
calculate coverage
1 parent 6cdba24 commit 372634e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

_posts/2022-10-24-the-trouble-with-anti-aliasing.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,29 @@ The CIE L\*a\*b\* color space has a perceptional uniform lightness in one axis a
8787
perceptional uniform color plane. The CIE L\*a\*b\* color space may be a valid color space
8888
to do anti-aliasing in, but it is computational expensive.
8989

90+
Do: Properly calculate coverage for sub-pixels
91+
----------------------------------------------
92+
We sample the signed distance from the center over each sub-pixel.
93+
Since we only have a distance and not an angle, we measure the coverage
94+
of a plane and a circle. The SDF measures the plane's edge from the
95+
centre of the circle, when the signed-distance is negative the
96+
plane intersects with the centre of the circle, while positive it
97+
doesn't.
98+
99+
The circle's area should match the area of the pixel which is 1.0 x 1.0 = 1.0,
100+
this makes: r = sqrt(1/π) = 0.5641895835.
101+
102+
d = signed distance
103+
104+
r = radius of sample circle
105+
106+
x = d / r (-1 <= x <= 1)
107+
108+
f(x) = (1/π) * (acos(x) − x*sqrt(1 - x*x))
109+
110+
111+
Perceptional uniform anti-aliasing
112+
90113
Do: Convert coverage to alpha with perceptional compensation
91114
------------------------------------------------------------
92115
Lets try something cheaper.

0 commit comments

Comments
 (0)