Phone-wire AA demo

Discussion in 'Rendering Technology and APIs' started by Humus, Jun 26, 2012.

  1. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    I have a new demo which illustrates a simple but effective technique for dealing with aliasing on thin wires.

    Results:

    Normal size:
    [​IMG]

    Zoomed:
    [​IMG]

    Download from my site
     
  2. Alexko

    Veteran Subscriber

    Joined:
    Aug 31, 2009
    Messages:
    4,515
    Likes Received:
    936
    Nice. Going by the description on your website, that sounds very cheap computationally.
     
  3. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Yes, it's very cheap. To core of this technique is basically a handful of ALU instructions in the vertex shader.
     
  4. fellix

    Veteran

    Joined:
    Dec 4, 2004
    Messages:
    3,515
    Likes Received:
    441
    Location:
    Varna, Bulgaria
    Is this clamping method applicable to any type of geometry, that nears the sub-sample boundary size?
     
  5. homerdog

    homerdog donator of the year
    Legend Veteran Subscriber

    Joined:
    Jul 25, 2008
    Messages:
    6,286
    Likes Received:
    1,061
    Location:
    still camping with a mauler
  6. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    It should be quite straightforward to apply the same idea to anything cylindrical or spherical. So pipes and railings should be straightforward and if you build your antenna towers out of metal bars it should just work. I don't know how well the idea would extend to non-round objects, like rectangular shapes etc. You would probably need to take orientation into account. Intuitively my guess is that it should work, but I can't guarantee that before I've tried.
     
  7. Malo

    Malo Yak Mechanicum
    Legend Veteran Subscriber

    Joined:
    Feb 9, 2002
    Messages:
    7,844
    Likes Received:
    4,016
    Location:
    Pennsylvania
    "Our new title does in fact support MSAA + FXAA and even SSAA for you PC fanatics!"

    "Yeah but does it support WAA!?!??"
     
  8. micron

    micron Diamond Viper 550
    Veteran

    Joined:
    Feb 23, 2003
    Messages:
    1,189
    Likes Received:
    12
    Location:
    U.S.
    I saw this demo linked at the Chinese technology site expreview.com. The translation used the term "Force of God" to describe how awesome it is:cool:

    [​IMG]
     
  9. Acert93

    Acert93 Artist formerly known as Acert93
    Legend

    Joined:
    Dec 9, 2004
    Messages:
    7,782
    Likes Received:
    162
    Location:
    Seattle
    Awesome--and the solution sounds so simple that going forward there is no excuse. Kudos Humus!
     
  10. Dominik D

    Regular

    Joined:
    Mar 23, 2007
    Messages:
    782
    Likes Received:
    22
    Location:
    Wroclaw, Poland
    You wanted to SAY WHAA?! I guess. ;)
     
  11. Barbarian

    Regular

    Joined:
    Jun 27, 2005
    Messages:
    289
    Likes Received:
    15
    Location:
    California, USA
    It seems like this can be generalized via contour detection similar to the cell shading methods, then expanding the edges and converting coverage to alpha.
    Proper sorting will still remain a problem, but perhaps with DX11 there might be efficient ways to sort per fragment.
     
  12. reptile

    Newcomer

    Joined:
    Oct 7, 2004
    Messages:
    56
    Likes Received:
    6
    Interesting approach. We solved this problem by drawing the wires again as a linelist, this way nearby portions would get hidden by the actual geometry, and far away segments would never go below 1 pixel in size.
     
  13. 3dcgi

    Veteran Subscriber

    Joined:
    Feb 7, 2002
    Messages:
    2,446
    Likes Received:
    301
  14. CeeJay.dk

    Newcomer

    Joined:
    Nov 7, 2006
    Messages:
    8
    Likes Received:
    0
    Location:
    Denmark
    A quick idea : During development apply this to everything in your scene, and then only show (or highlight) the pixels that were affected, to detect good candidates to apply this technique to in the final product - rather than guessing what geometry it might be good for.
     
  15. CeeJay.dk

    Newcomer

    Joined:
    Nov 7, 2006
    Messages:
    8
    Likes Received:
    0
    Location:
    Denmark
    Humus, is the texture lookup in the pixelshader really necessary?

    Since the phonelines are only 1 pixel wide, it seems to me that you could simply use an already defined color .. perhaps the vertex color.
     
  16. CeeJay.dk

    Newcomer

    Joined:
    Nov 7, 2006
    Messages:
    8
    Likes Received:
    0
    Location:
    Denmark
    I did some tests on my own and you can indeed skip the texture lookup whenever In.Fade.x goes below 1, without being able to tell the difference.

    However seeing is this is already such a simple shader it's bottleneck is the export and not the texture lookup on most platforms, so you really don't save anything by this.

    You'd have to not run the pixelshader at all, to do it faster - perhaps an alpha test might work?
     
  17. digitalwanderer

    digitalwanderer Dangerously Mirthful
    Legend

    Joined:
    Feb 19, 2002
    Messages:
    17,853
    Likes Received:
    2,353
    Location:
    Winfield, IN USA
    Well I've known all along Humus was a programming god, but it is nice to see the Chinese finally getting around to admitting it. ;)

    Good job Humus, thank you!!!! :D
     
  18. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Well, the technique is designed for this particular type of geometry, i.e. cylinder shape. So it will work on bars, railings etc. also, but can't just be applied to "everything". I'm sure you can come up with similar solutions for other types of geometry, but this case is one of the most commonly occurring source of aliasing in real games and also relatively straightforward to solve. I think this technique will work relatively well with a square cross-section as well, but I haven't tested that. Might need to clamp to a wider line, like sqrt(2) width to ensure there are no dropped pixels in all angles, alternatively take view angle into account.

    Sure. I'm not concerned with performance here though, so I stayed with a single pass. In a real game engine you may want to split the fully opaque parts from the translucent ones. Not so much for performance, just to better work with deferred rendering etc. May also want to sort the translucent parts if that makes a visual difference somewhere. If you do split you would probably do the translucent parts with a simpler shader, without texture lookups or lighting. Probably just a constant color. In the demo I used quite harmless half-lambertian lighting with no specular or anything to avoid getting shader aliasing introduced that way. If you do more fancy (or more correct) lighting you probably want to start fading out the lighting earlier, in particular specular, say at several pixels width, and transition to a constant color.
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...