-
-
Notifications
You must be signed in to change notification settings - Fork 17
This page gathers R&D ideas to improve both performance and quality:
As shown in [1], supersampled images should be filtered before rescaling to avoid artefacts (moire patterns or jaggies). Pisces / marlin (march 2013) only counts subpixels to compute the pixel coverage ie all subpixels (8x8) have the same weight (=1). To improve visual quality better resampling, filters can be implemented (tent or gaussian filters).
TODO:
- precompute filter weights according to the subpixel grid (2x2 up to 16x16) but also their integration onto the subpixel grid for performance reasons to improve scaline processing (sp_x, sp_y)
- instead of counting covered subpixels during scanline processing, use filter weights per covered subpixels (use integer weights by scaling up by a scaling factor) before summation and store weighted coverage into alpha line (as usual). Warning: for each edge only 1 subpixel corresponds to the edge intersection; the pixel coverage corresponds to all subpixels between 2 edges: take care of correct filter integral between these subpixels: same several pixel(s) !
- normalize pixel coverages once all scanlines have been processed per pixel line according to the filter scaling factor
- convert then the pixel coverage (int) to an alpha value (byte) [0..1] ie [0.255] using the maximal precision ie 1/256 uncertainty
Several solutions have been implemented in GPU to compute more accurately the pixel coverage of a primitive (line):
- Edge distance function:
See [2] for proper line rendering using 4 distance functions and filtering
See also Wu line algorithm: http://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm http://freespace.virgin.net/hugo.elias/graphics/x_wuline.htm
- Coverage mask:
...
For very small polygons or details (intersection, corners or small polygons), the scanline step controls the detail level ie using 2x2 or 16x16 will refine the pixel coverage accuracy ie take into account the small polygon features.
Depending on the edge slope / edge intersections or edge length, it may be possible to refine the supersampling using 4x4 (by default) up to 16x16 or more.
Another issue concerns small polygons / shape details (corner or extrema) that are smaller than 1 pixel or few subpixels: again their coverage is too badly estimated due to rounded starting / ending edge coordinates: refining scanline increments should improve that but it can become very costly in terms of performance.
Adaptive algo is needed but rather more complex to do but I have the feeling it is the good direction: only refine scanlines when needed ~ error estimation / propagation in physics.
[1] Study of Supersampling Methods for Computer Graphics Hardware Antialiasing Goss, Michael E.; Wu, Kevin 12/05/2000 http://www.hpl.hp.com/techreports/1999/HPL-1999-121R1.html
[2] Prefiltered Antialiased Lines Using Half-Plane Distance Functions McNamara, Robert ; McCormack, Joel ; Jouppi, Norman P. 1998 http://www.hpl.hp.com/techreports/Compaq-DEC/WRL-98-2.html