Graphics Update... BGolus and Varrak cleanup rampage

Discussion in 'Planetary Annihilation General Discussion' started by varrak, April 10, 2014.

  1. varrak

    varrak Official PA

    Messages:
    169
    Likes Received:
    1,237
    It's been a caffeine-fueled couple of weeks here in the graphics cave at Uber, and BGolus and I have been busy. I decided it was time to take a brief respite from optimization, and focus on fixing up some of the annoying visual issues (and missing features) that we have in the game. Some of these are actually out in the wild (I believe...), and are quite subtle so you might have missed them. Others are coming soon.

    Warning: This might get very technical. I apologize in advance for any drowsiness reading this might cause.

    The first thing I did was to fix issues with normal map compression. A while ago we pushed most of our content over to using DXT compression for textures. This saves a lot of space (4x or 8x, depending on whether the texture has an alpha channel or not). But there's some downsides if you, for example, forget that normal maps don't compress well by default [hangs head in shame]. This was not a visible issue on almost all planets, except on metal planets with the hard crease normals, and there, it was... well... bad juju.

    The fix here was simple(ish): I updated the content pipeline to swizzle the texture channels so the green channel stores the y component, red and blue store 1.0, and the alpha channel stores the x component. You lose a component, but the fact that normals are guaranteed to be unit length means you can easily derive Z when sampling, by just doing the equation z = square_root(1.0 - dot_product(normal.xy, normal.xy)). The end result? We end up with close to non-compressed quality normal maps (well, closer, anyway), and the metal planet looks much better. See exhibit a, below:

    clean_normals.jpg

    Next, BGolus pointed out that our GBuffer normals (that's the normal data that gets built up prior to the lighting passes - for more info, go read up on deferred shading) were horrible, since we were using an 8-bit per channel texture to store world-space normal data. Since the vectors are normalized, you only actually get to use around 2% of the precision of the 3 bytes stored; as a result, you can get banding which looks ugly and makes artists sad. See exhibit b, below:

    best_fit_normals_off.jpg
    The smart guys over at Crytec figured out a really nifty way to work around this, though, using a technique called "Best Fit Normals". This uses a texture lookup to figure out the best non-normalized vector to fit our normal to, and use that instead. At the lighting phase, we just normalize the value (which we were doing anyway), and hey presto - we get up to 97% of the available values. That's a bit good. See exhibit c, below:

    best_fit_normals_on.jpg

    Another thing that's been annoying a few people here for a while was some artifacts that showed up around shadows, especially around the edge of planets. This was due to precision issues at glancing angles, where shadow/non-shadow depths would pop back and forth, and cause hatching. I don't have a picture of that, but I'm sure anyone who played the game with shadows noticed it. BGolus worked out a fantastic solution, the name of which I forget, which makes things look a lot better. I'll leave it up to him to talk about that one (wouldn't want to steal his thunder...).

    Last, but definitely not least, our lead artist has been asking for a particular feature for a Long Time. The feature in question is something called "Ambient Occlusion" (click the link if you're interested). This can have a massive impact on the visual quality of graphics; but it's one of those effects that if it's there, you don't really notice it, because it just looks right. Well, I'm pleased to say that as of today, I integrated the latest and greatest screenspace algorithm for ambient occlusion - something called Scalable Ambient Obscurance. The paper is here. It's some pretty heavy reading (I have keyboard-key-shaped indents in my forehead where I fell asleep reading it last night). But if you're really, really curious, then clickity...

    Anyway, it was a fun and interesting challenge to actually implement it (by "fun" and "interesting", I of course mean "challenging" and "my head hurts"), but by golly I got it working. Words don't do it justice, so here's some pictures:

    First, a nice sunset, with no SAO:

    SSAO_off_1.jpg

    Now with SAO:

    SSAO_on_1.jpg

    And some metal planet action:

    (Without)

    SSAO_off_2.jpg

    And on:

    SSAO_on_2.jpg

    Anyway, we had fun doing this stuff, so I thought some of you might be interested in reading about it. Obviously, if you're reading this part, you're still awake! Congratulations... :)
    tesseracta, trialq, Gorbles and 80 others like this.
  2. Arachnis

    Arachnis Well-Known Member

    Messages:
    938
    Likes Received:
    442
    Looking very good. :rolleyes:
  3. spainardslayer

    spainardslayer Well-Known Member

    Messages:
    304
    Likes Received:
    257
    Looks amazing! The shadows look so nice.
  4. chronosoul

    chronosoul Well-Known Member

    Messages:
    941
    Likes Received:
    618
    Thanks for the update,

    I'll have to read the linked stuff later, but so far so good. keep up the good work uber graphic masters.
  5. stevenrs11

    stevenrs11 Active Member

    Messages:
    240
    Likes Received:
    218
    I love these so much- please don't stop posting them. And wow, SOA makes a huge difference.
  6. nightbasilisk

    nightbasilisk Active Member

    Messages:
    194
    Likes Received:
    103
    Bgolus, varakk, great job guys!! Always a pleasure reading your posts.
    varrak likes this.
  7. ace902902

    ace902902 Active Member

    Messages:
    548
    Likes Received:
    212
    awesome!!!!!!!!!!

    btw, can we get an awesome head biome?
  8. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    Amazing work! I'm pretty keen to hear about the glancing shadow angles too, because that was a problem in Supreme Commander also (and, I thought, a fairly intrinsic problem without going to much more expensive shadowing solutions).
  9. brianpurkiss

    brianpurkiss Post Master General

    Messages:
    7,879
    Likes Received:
    7,438
    Wow. The improvements on that ice planet look awesome!

    I imagine that it's now going to be a lot easier to see terrain differences.

    And now that I have my new beast of a computer, I can enjoy these at maxed out graphics!!! :-D
  10. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    I swear the developer interaction was worth my $90 on its own.
  11. BulletsFrozen

    BulletsFrozen Active Member

    Messages:
    194
    Likes Received:
    104
    I didn't even attempt to understand most of ito_O, so I guess I will have to trust you guys just this once, however remember I have my eyes on you ;).

    lol Just kidding keep your doing great, appreciate the amazing work :D!
    igncom1 likes this.
  12. Dementiurge

    Dementiurge Post Master General

    Messages:
    1,094
    Likes Received:
    693
    I love all of this.

    Well, except ambient occlusion. It drives me nuts when the shape of shadows changes with the direction you're looking at the scene.
  13. bgolus

    bgolus Uber Alumni

    Messages:
    1,481
    Likes Received:
    2,299
    And that SAO is before it's been giving an art pass, so the numbers might be a little off.

    The shadow "fix" is more accurately a shadow acne error mitigation. There's a GDC "paper" from 2009 talking about it here:
    [​IMG]

    It does a good job talking about the issues with shadow mapping and the usual fixes people use, and why they don't work. I'm currently biasing using the GBuffer normals, which is wrong because we use normal maps, but the error usually isn't enough to be noticeable. I may change it to derive the normals from the depth which is what the AO uses.
    websterx01, lokiCML, ozonexo3 and 4 others like this.
  14. KNight

    KNight Post Master General

    Messages:
    7,681
    Likes Received:
    3,268
    Ambient Occlusion makes everything better!

    Mike
  15. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    First of all, yes I will be this guy:

    Will these fixes and improvements be in the next build?

    Second: How much does Ambient Occlusion impact framerate?
  16. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    This is absolutely awesome! Without shadow acne and AO (especially near trees) game will look a lot better. :)

    PS: Can't wait to see how game will looks on planet with tons of trees. :rolleyes:
    Last edited: April 10, 2014
    shootall likes this.
  17. aevs

    aevs Post Master General

    Messages:
    1,051
    Likes Received:
    1,150
    VERY glad to hear that shadow acne is getting cleaned up!

    The ambient occlusion looks good, though I think it's "cut off" a bit too soon (not sure if this is something that can be altered or not). It looks a bit like a line was drawn in the concave parts on that ice biome brush with a soft brush, for example.

    Which also makes me wonder... is realtime SSAO really necessary for permanent features? Some features (like on the metal planet in the first image) already have baked AO in their textures, and those that don't (like that ice prop) probably could. Adding AO on top of baked AO looks a bit like overkill.
    The actual ground on a planet doesn't have baked AO, of course, as can be seen in both examples, but would it be cheaper to place 'decals' mimicking AO on the terrain based on the location of their respective brushes instead? I guess there might be problems for overlapping decals though, so maybe not...
    Idunno, SSAO is definitely nice for units and buildings, but it seems a bit odd when some details already have baked AO and SSAO is applied on top of that.
  18. varrak

    varrak Official PA

    Messages:
    169
    Likes Received:
    1,237
    SAO is not hugely expensive, so on most mid to high end systems I doubt you would notice a difference. And we should see most out all of these in a build coming out... soon... ;)
    websterx01, Schulti and Raevn like this.
  19. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    I 100% expected "soon" but hoped and wished for a different answer, also when you say SAO i am going to assume that is the same as SSAO, I wanted to know if implementing HBAO or HDAO would be beneficial in any way.
  20. varrak

    varrak Official PA

    Messages:
    169
    Likes Received:
    1,237
    SAO is scalable ambient obscurance, which is a newer form of ssao. It's faster and more stable than hbao. I believe the latest call of duty releases have used it.
    websterx01 likes this.

Share This Page