Manually antialiased primitives using texturing

Sage
Posts: 1,232
Joined: 2002.10
Post: #16
DoG Wrote:You said you use mipmapping, but why?

For triangles, you're right. You inset the border 0.5 px and draw strips around it which outset 0.5 px as well (currently that's not what I'm doing, but I ought to be.) That gets you a 1 px strip fading from full to zero alpha.

But, what if you don't want a 1 px strip? What if you want 17 px? or 59.034 px? How big is your texture then? What if you don't want a linear fade on the strip?

Just look at the point case. How do you draw a 3 px point? I do it with trilinear mipmapping, so it blends the 4 px and 2 px mipmaps. There is some blur as I mention on the page but this is cheaper and easier algorithmically than keeping textures for sizes 1..N. (I did try it that way too, at first.)

The implementation details will be up in a while. The details are actually not as simple as you'd think-- there are a lot of edge cases to consider. Think about what happens to the 0.5 px inset when the triangle is only 0.9 px wide.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #17
arekkusu Wrote:For triangles, you're right. You inset the border 0.5 px and draw strips around it which outset 0.5 px as well (currently that's not what I'm doing, but I ought to be.) That gets you a 1 px strip fading from full to zero alpha.

But, what if you don't want a 1 px strip? What if you want 17 px? or 59.034 px? How big is your texture then? What if you don't want a linear fade on the strip?

I assume, that since anti-aliasing is considered, the border strip is always 1px, and you always want a linear fade. I don't see where you would use other widths, because it would just blur. And besides, if you can generate a 1px border, you can also do 17px or whatever.

arekkusu Wrote:Just look at the point case. How do you draw a 3 px point? I do it with trilinear mipmapping, so it blends the 4 px and 2 px mipmaps. There is some blur as I mention on the page but this is cheaper and easier algorithmically than keeping textures for sizes 1..N. (I did try it that way too, at first.)

I would personally draw a point by drawing a polygon disk with the mentioned 1px border around the disk. Maybe not as fast as a textured quad, but guaranteed more accurate.

In fact, I would draw lines the same way, by making them polygons, not by using textures.

arekkusu Wrote:The implementation details will be up in a while. The details are actually not as simple as you'd think-- there are a lot of edge cases to consider. Think about what happens to the 0.5 px inset when the triangle is only 0.9 px wide.

Of course, you could use a general bordering algorithm which is basically independent of border and inset width (but you set it to 1px anyway), and can deal with degenerate cases, where the border has to be changed as int the above case. All I can say is Voronoi spaces. I am fairly certain it would not be hard even to come up with such an algorithm and less so to implement it.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #18
DoG Wrote:I would personally draw a point by drawing a polygon disk with the mentioned 1px border around the disk. In fact, I would draw lines the same way, by making them polygons, not by using textures.

That works, just using a 1 px texture everywhere. But my original intention is to use these antialiased shapes in a paint program. So I decided to turn the workaround for lack of antialiasing into another feature... using variable sized textures allows fuzzy shapes with spherical falloff:

[Image: AA_fuzzy.png]

(note triangle bogosity)
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #19
arekkusu Wrote:After spending a day testing 12 different video cards, I can tell you that you're wrong on both counts. The FSAA on the 9800 pro looks identical to the 9600 (x2 = 1 shade, x4 = 3 shades, x6 = 5 shades...)

It still eats fillrate too. Here's some meaningless numbers applicable only to my limited test app (thousands of points/lines/triangles drawn per second):

Code:
ALIASED         HARDWARE AA     FSAA X2         FSAA X4         FSAA X6         SOFTWARE AA
Radeon9800Pro    420/540/75    420/539/75    420/298/60    420/150/38    420/121/33    55/11/0

You can see the steady drop in line/triangle throughput as the FSAA buffers increase.

That said, the 9800 Pro was the fastest card of the 12...

Check some comparison pictures. (warning, graphics-heavy)
You neglect to mention SmoothVision 2.1 which the 9800 has and the 9600 has not. SV2.1 makes a helluvalot of performance difference, and if you didn't test with it your results are skewed. Go figure out how to turn it on before making broad statements about 9800 and 9600 Radeons.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How to render points manually NCarter 9 5,782 Jan 13, 2003 05:22 PM
Last Post: henryj