Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Antialiasing in Unity 5

Discussion in 'General Graphics' started by Stormbreaker, Jul 11, 2014.

  1. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    We could (or some sort of "better postprocessing anti-aliasing, probably temporal"). Just right now everyone's busy doing something else.

    That said, many anti-aliasing techniques, especially non-temporal ones (SMAA, CMAA etc.) - anyone can implement them. It's just an image effect; which means it's just a shader+script (no need to actually modify "the engine").
     
    shkar-noori likes this.
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Rendering huge and then calculating a final single color for a pixel is the same thing as rendering at `regular size` and having it super-sample at sub-pixel locations and then producing a final pixel color... just different parts of hardware accomplishing the result. I'm just suggesting a workaround.
     
  3. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    Indeed, I was more just correcting on the point that it doesn't render more pixels than the screens resolution, as in downsampling
     
  4. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Supersampling, not downsampling. And for most practical purposes it does render more pixels than the screen's resolution - or to be more accurate, more 'fragments' - it runs fragment shaders and the output merger for each additional sample per pixel.
     
  5. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    I think you may be misinterpreting my post or taking it out of context, as I was originally replying to a post about downsampling:
    "rendering to some high-res render texture bigger than the screen, then scaling that down with bilinear filtering or something" I think you'll agree that that refers closer to the process of downsampling than supersampling.

    In any case, none of this matters or is relevant to the original thread context!
     
  6. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    No, I had the context correct, but reading a bit more about it I think the point I was making was unhelpful anyway, so never mind.

    (It's true that the step at the end when you scale the texture down to fit the screen is downsampling, but I thought the overall strategy - of deliberately rendering to a larger-than-the-screen texture and downsampling it - is called supersampling. Reading up on it, it looks like my definition of 'supersampling' is excessively narrow, though).
     
  7. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    I've actually got Supersampling working in my current project, but Unity as it stands doesn't really like it. Initially I was aiming to release it as an asset, but Unity just breaks when you don't have any cameras rendering "normally" (my method renders to a big RT, then draws that to screen). I've submitted a bug and had it accepted, not sure if/when it's getting fixed though.

    Also, when I've experimented, I've noticed a very large impact on the CPU (under Camera.Render) in more complex scenes when Supersampling. Now, I'm not particularly experienced with how it should work, (so I could be completely wrong here) but I was under the impression that most of it should be done on the GPU?

    On the topic though, it would be disappointing if FXAA was the only default-provided AA option in Unity 5 deferred.
     
    Last edited: Oct 14, 2014
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
  9. Deleted User

    Deleted User

    Guest

    Still it wouldn't be a bad idea to add TXAA into the fold.
     
  10. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Sure, it just does not happen all by itself; someone has to do this instead of <<whatever they'd be doing instead>> :)
     
    GoGoGadget likes this.
  11. Deleted User

    Deleted User

    Guest

    No rush Aras, just stick on the forever growing list to do :)..
     
  12. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Hows Unity's list of stuff to do generated? Seems to me like TXAA would be used more then IBL or PBS...
     
  13. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    PBS will be used along with IBL far, far more than a bit of temporal antialiasing. Also such antialiasing requires render textures and PBS doesn't.
     
    Ryiah likes this.
  14. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    I'm sure Unity can do as much render texture stuff they want behind the scenes without exposing it to users... I'd assume that's what will happen with Oculus support.
     
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yes that's correct. But a feature like this is yet to be even worked on, much less decided. Regardless, PBS is always a better visual upgrade. I think you're way overestimating what TXAA even brings to the table vs FXAA or even the MSAA available in free.

    It's not a big upgrade. A big upgrade, a priority, is PBS - it's a hard thing to use. People should do their research and if they've used it, contribute to http://forum.unity3d.com/threads/official-specular-vs-metallic-workflow.274612/#post-1814248
     
    shkar-noori likes this.
  16. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Most of the games made with Unity I see are mobile focused games with simple graphics... not exactly the type that would make use of PBS and IBL.
    Obviously having fancy graphics makes sense from a marketing stand point.
     
  17. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
    I was just looking at the Unite 2014 presentation about best practices of PBR:


    Right at the beginning of the video with the rotating red object you can clearly see how ugly the details are flickering with PBR. TXAA would remove this issue of "walking edges" and gurantee a more calmer picture. And no, FXAA doesn't solve this issue due how they work. And no this flickering isn't a "feature".

    Just something to keep in mind if someone wants to jump on the pbr train.
     
    shkar-noori likes this.
  18. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    I've been asking for TXAA for a long time, it looks like no one on unity's side is caring 'enough' about Anti-Aliasing.
     
  19. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    561
    Yeah, I agree. You can have all the fancy PBR and GI stuff in the world. Without having a proper antialiasing system you can forget about AAA.
     
  20. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    If we wait long enough we get 24M resolution. Then we probably don't need anti-aliasing anymore. But then we're also not around anymore, since it's the year 8302.
     
    shkar-noori and GoGoGadget like this.
  21. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    TXAA is a feature of nVidia cards of 600 series and above. Unity is not likely to spend a lot of time implementing something only a portion of users can use. Unity is famously cross-platform and all-inclusive. Asking for SRAA, deferred MSAA, or other FSAA makes far more sense than a tech that can only be used by some.

    Also note:
     
  22. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    AAA video game gamers have a >= GTX 600 video card, so let those who develop for high-end have the high-end features.
     
  23. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    If you want to create AAA graphics you're most likely better off not using unity at all.
     
  24. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    Aside from SMAA 1x there is also SMAA T2x which adds temporal supersampling and does not require a specific brand of video card. However for the temporal component to work you'd either have to use render textures or build it into the engine.
     
    shkar-noori likes this.
  25. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    that's what we are hoping for Unity 5 to prevent, we don't want to switch engine in the middle of a project. and the time we invested in Unity is to much to just let it go.
     
  26. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    btw, we're not asking for exact TXAA, a good lookin AA technique with quality steps is what we ask for.
     
  27. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    I'm aware of that, I'm amongst those in this thread saying that.
    I was just addressing the specific mention of TXAA, which is a vendor restricted technology, and far less attractive a feature in my eyes.

    Note that only 42% of Unity Standalone users have nVidia cards (not necessarily ones that can use TXAA), and even less for Web Player (32%).
     
    shkar-noori likes this.
  28. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Putting my "thinking like a Unity exec" cap on ... maybe a top level AA solution would make a good Pro-only feature, to help distinguish between free and Pro versions of Unity. In that it's not an essential feature for an indie game, but it would be great to help push a Pro game to AAA levels.
     
    shkar-noori likes this.
  29. Genjin

    Genjin

    Joined:
    Oct 17, 2014
    Posts:
    11
    I sure would like an improved AA as well. I don't know why but FXAA never seemed to be as effective in Unity as it is elsewhere. Now with PBR, there is a lot of Specular Artifacts and such that something like inbuilt SMAA with quality step control might help me with - so sure I want it :D

    PS: I'm aware of the community made SMAA, but it does not improve in quality when going up in steps, so it is unfortunately about equal to the current FXAA.
     
  30. Deleted User

    Deleted User

    Guest

    At this juncture, post-process AA of some variety seems like the most accessible solution. MSAA on gbuffers or Temporal AA would require engine changes, testing, etc. So those are two non-starters. It seems like if someone could make an efficient, high quality post AA solution and sell it on the asset store they'd make a killing.
     
    shkar-noori likes this.
  31. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    I think they would, but I think new major releases are the right places for breaking changes.
     
  32. FriendlyHo

    FriendlyHo

    Joined:
    Aug 18, 2014
    Posts:
    23
    This is pretty daunting EVEN MY STARS ARE INVISIBLE IN THE FIRST IMAGE. I think theres more to having multi sampling then just softer edges



     
    Last edited: Dec 19, 2014
  33. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Well that's funny since FXAA Preset B seems to be incredibly good for our game, with lines all being properly antialiased. Have people actually really given the existing AA post fx a good chance?
     
  34. FriendlyHo

    FriendlyHo

    Joined:
    Aug 18, 2014
    Posts:
    23
    Ive tried I believe all the anti aliasing scripts I could find, I've tried FXAA Preset B and it just provides a blur effect.. Could I get a link to that FXAA script if its free? are you using deferred?
     
  35. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm using preset B in unity 5 with linear / deferred. The post fx is included with unity's effects.
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    One of the major improvements of PBR is in getting a more accurate and predictable specular response, which in turn uses IBL to reflect the environment. But it's a massively approximated result. This can create a lot of aliasing issues because you end up with a lot of high frequency/changing information in this domain. While temporal antialiasing would likely help, it's not going to magically fix everything for you.

    For instance, one trick is to preprocess your normal map/model to find all the areas where the normal direction rapidly changes and increase the roughness value in these areas. This can significantly help aliasing because it will reduce the high frequency specular reflections (which are gross approximations anyway) in the areas where they are likely to alias and cause visual issues the most.

    You can also pack your normal maps in different ways, such that the majority of the bits are used to represent the angles close to the face normal. On models which have reasonably high polygon counts and involve smooth surfaces, this can increase the accuracy of the normal information (and thus the specular information) considerably.

    Point is, care has to be taken across the entire pipeline if you want to prevent aliasing, not just in the post processing stage, and some of it can be very asset dependent.
     
    Last edited: Dec 26, 2014
  37. startas

    startas

    Joined:
    Nov 14, 2014
    Posts:
    102
    Well, i think that anti-aliasing isnt very important for unity, because i looked at all games list, that were build on unity engine, and there was not a single big game, all i found was simple games for phones and at best some medium games for consoles/pc, not a single AAA title. So i dont think, that it is important to have a powerful AA technique for hardware, that cannot handle it, anyway. And if you would look at unity in general, you can see, that its graphics arent very good (it is many years behind in comparison to unreal engine 4), obviously unity is targeting more phones/consoles, so top quality graphics are out of the question.
     
  38. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    Yes, and this is why you improve them?

    Do you have any idea how ugly games without anti-aliasing (or with FXAA) are if you actually look at them? "Indie games" should not be synonymous with "trash graphics".
     
  39. startas

    startas

    Joined:
    Nov 14, 2014
    Posts:
    102
    Well, yes, actually, i'm pro at noticing lack of AA in games, this is becoming a big problem even in many pc AAA games, that they do not have a good AA method, because new special effects are removing previous AA methods, now there is only some blur tricks like FXAA. And how do you wanna implement powerful AA method, that will take away 999 fps from any mobile device ? This was a problem in all mobile games and previous gen consoles (xbox360/ps3/...), it is a problem, and it will be a problem for many years, till mobiles devices will evolve enough gpu power and till someone will make a great game engine, that will properly combine all special effects.
     
  40. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    AA is less relevant on mobile devices due to the extreme pixel density, with 1080p (or greater) screens being the trend for phones, it's straight up impossible to see the jaged edges.

    On pc however it's a completely different story, and a nice AA solution is needed.
     
  41. andmm

    andmm

    Joined:
    Nov 21, 2013
    Posts:
    37
    One of the things that make UE4 stand out graphically is certainly their AA solution. It just looks miles better than Unity's.

     
    FriendlyHo and movra like this.
  42. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah shame about the speed tho? in any case Unity wants to, but they've said clearly they do not have time this second. All hands on deck are focussed on bringing 5 to launch state so everyone can use it.

    Releasing Unity isn't the end, it's the start of Unity 5.

    If such a solution is to come to be, it might be better served combining it with several other post like motion blur so that the relevant information is available for reuse in some way.
     
    shkar-noori likes this.
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, at 1080p edge aliasing is harder to see on a 4 inch screen - but most of what is bothersome these days is not edge aliasing, it's specular/reflection aliasing due to high frequency details essentially blipping in and out each frame. As long as these details can, from some viewpoint, reach sub-pixel sized, you will get annoying flicker as they pop in and out of the view. Even if phones start running at 4k, you will still have this issue.
     
  44. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    Thanks, that video really demonstrates what a difference temporal AA makes. It's much more than just pixel peeping, the lack of temporal AA causes very obvious and distracting fireflies.
     
  45. startas

    startas

    Joined:
    Nov 14, 2014
    Posts:
    102
    Well, in any way, AA is not the biggest problem for phone games right now, all they need right now is making better hardware, then better AA methods will come.
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    You are right, but this could be adressed using Texture prefiltering. You may want to have a Look at the Lux Texture Preprocessor - it is free on the asset store.
     
  47. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    NVidia made a port of HBAO+ into Unity in-case anyone is interested, I hope they continue doing other GameWorks features in the future.
     
    hippocoder likes this.
  48. Alabatross

    Alabatross

    Joined:
    Dec 15, 2012
    Posts:
    223
    Has there been any news on this?

    My team loves deferred, but no matter how good it looks it will not make up for the massive amounts of jagged edges present in the image. All of the post AA we have tried merely blurs them. So instead of crawling edges you just get blurred crawling edges.

    Deferred is a no go for me on any PC game I'll ever be working on until it has proper MSAA :(
     
  49. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Right now one of postprocessing AA solutions (FXAA etc., or rolling your own MLAA/CMAA) are your best bet. Doing a simple temporal-based postprocessing AA should be doable too, if you know something about shaders.

    We have people looking into proper "built-in" temporal postprocessing AA solutions here, but that will be post-5.0.
     
    fffMalzbier, shkar-noori and hopeful like this.
  50. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    Thank god... so are we looking 'approximately' at 5.1? 5.2? or 5.6?