   Anti-aliasing - gpu does better job than me
  Hi there,Please have a look at this picture:http://www.topdesk.com/assets/images/aaproblem.pngIt shows two times a boundary of a triangle and background (grey), four times anti-aliased. The first one is rendered by my graphics-card (not sure even, Ati I thought), and the second one by my raytracer. The raytracer is using a square, 2x2 sampling method.As you can see, the top one looks much better, although the bottom one is theoretically correct if I'm not mistaken. This makes me believe the graphics card is using a different method to calculate AA but I'm really not sure what the problem is. I thought the graphics card might rotate the square before sampling or something?Any help would be great, thanks   
  No modern hardware uses ordered grid sampling for MSAA any more as it produces notoriously poor results (as you've found out). If I remember correctly, popular methods include rotated-grid (so your square becomes a diamond) or sparse sampling.I don't recall the exact specifics of sparse sampling, but if memory serves it works on solutions to the N-Queen problem. That is, for 4xAA, break up your pixel into a 4x4 grid and ensure that no two samples lie on the same line.   ;  in the old days of no hardware AA, we did it with accumulation buffers and there were some "perfect" jitter pattern for that, check out:http://www.opengl.org/resources/code/samples/advanced/advanced97/notes/node63.htmlperfect means, if you'd do a veroni diagram, every sample would get an equal area. you will, especially with those low sample counts, get random quality results. sometimes it's better to have ordered grid, sometimes rotated, sometimes one of the linked pattern is superior. it's image dependant.if common way to increase quality is to add noise, this can be done easily for a raytracer by randomly rotate the pattern. from near this might not look as good, but from normal view dithering often hides ugly artefacts (like aliasing).;  thanks. So how would I implement this rotated grid? The example you provide appears to be not exactly diamond (which makes sense) and how would this extend to 8 samples and more?Any example implementations maybe?EDIT: I found this, which looks helpful but there's not really any theory coming with it:http://www.gamedev.net/community/forums/topic.asp?topic_id=337126[Edited by - garma83 on June 16, 2009 2:21:03 AM];  For our PCF implementation we did a simple N-Queen approach: we spread 8 taps on an 8x8 grid so that each tap is alone on its row and its column. Start like this:X........X........X........X........X........X........X........Xand begin swapping rows or swapping columns until you arrive at a pattern like this..X..........X.........X...X....X.............X..X..........X...It's handmade, so it's not statistically optimal, but at least for nearly horizontal or vertical edges it works great. For further improvement, rotate or mirror the pattern for every second pixel, for example.Bye, Thomas   ;  That looks interesting, thanks! I would prefer a statistically optimal method, but this looks like it would work as well. I'm gonna use that if I dont find anything else.Look at this picture:http://www.gamedev.net/community/forums/topic.asp?topic_id=337126What is the method behind this?   ;  ..X..........X.........X...X....X.............X..X..........X...reminds me of the puzzle (8 queens on the chessboard), the above isnt a solution though, perhaps try a solutionit may look better   ;Quote:Original post by garma83thanks. So how would I implement this rotated grid? The example you provide appears to be not exactly diamond (which makes sense) and how would this extend to 8 samples and more?Any example implementations maybe?my link gaves you the pattern for up to 16samples. just follow the link.   ;  Ah I'm sorry Kryt0n, I missed that table because I was still focusing on an analytical approach, but it appears to be exactly what I need.I'll implement that, thanks.   ;  kryt0n,Maybe I'm missing something here, but there's no real increase in quality the way I did itWhat I did was use the values of the table as coordinates inside the pixel that is to be antialiased. So for count 4, there are 8 values, which I paired. However, for count 4 the coordinates have the same problem as the squared version because the coordinates represent a sheared square! If you look at every second value, you see that it is 0.75,0.25,0.75,0.25. This means there are 2 values on 0.25 and 2 on 0.75.  This way, lines that are almost horizontal still look badWhat am I doing wrong?   