Search Unity

Downsampling and high resolution rendering, how?

Discussion in 'General Graphics' started by Morning, Jan 10, 2015.

  1. Morning

    Morning

    Joined:
    Feb 4, 2012
    Posts:
    1,141
    Hello,

    As some of you might know, downsampling AA is the thing right now so I am wondering as to how can that be implemented in Unity?

    For people who don't know, downsampling AA is rendering game at 2x(or more) of monitor pixel size and then resizing image down, producing smooth looking result.

    It is very performance hungry since it is essentially brute force AA but for games with low requirements this can do a lot of justice.

    Thanks for support
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Presumably you need either render textures or 4 cameras with 4 sets of grabbing pixels into textures, then you draw the texture using your own downscaling shader I presume... or something like bilinear filter.
     
  3. Morning

    Morning

    Joined:
    Feb 4, 2012
    Posts:
    1,141
    I did a small test with render textures. Base resolution is 1280x720


    1x - original image, nothing done
    2x - render texture at 2560x1440, very smooth looking
    4x - render texture at 5120x2880, too big of a size causes jaggies to show up, not as much as at 1x but noticeably more than at 2x, could be because of downsampling filter? Same happened at 3x too.

    I have not yet tested at any other resolutions though so I have no idea how that will look.
     
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    the 4x is doing that because you're trying to bilinear sample a 4x4 block, which ignores 2 rows and 2 columns, and produces a jump from one row to another at an offset, which is why it looks worse. It should look better than 2x. But you can't rely on bilinear to do it, unless maybe you render the 4x texture to a 2x texture (half size downsample) then use that texture and render it half size again. Otherwise you need a custom shader that will sample 16 pixels and average them.
     
  5. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Even the 2x is quite a noticeable improvement actually. If you get the 4x working it'll be even better.
     
    theANMATOR2b likes this.
  6. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    You could also split the screen into areas with their own render textures, so as not to hit the maximum texture size limit?
     
  7. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
  8. Morning

    Morning

    Joined:
    Feb 4, 2012
    Posts:
    1,141
    That's an interesting idea, wonder what would the performance difference be though.

    Does unity have internal maximum resolution? As far as I know modern GPUs have a high max texture resolution.
    The problem with splitting screen is some post process effects do not play well. You could in theory apply them to final image but that is too much work right now. Not to mention in that case they won't get to use the high resolution picture.

    That looks very informative. I'll look into it. Thanks/
     
  9. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    doing a half-downsample from 4x to 2x, then another from 2x to 1x, will of course be slower than then 2x to 1x, because you've got to do an additional 400% texture lookups, plus an extra 2x-sized write. But it may look nice :D