Search Unity

DX11 Realtime GI Solution + Discussion

Discussion in 'Works In Progress - Archive' started by TacticalDan, Apr 5, 2014.

?

Do you want a product like this?

  1. Not really, there's no demand

    2 vote(s)
    3.7%
  2. Yes, a cheap simple starter project to experiment with

    23 vote(s)
    42.6%
  3. Yes, a quality addition to my game

    29 vote(s)
    53.7%
  1. TacticalDan

    TacticalDan

    Joined:
    Jan 1, 2013
    Posts:
    35
    Over the last half a year I've been tinkering with voxel cone tracing global illumination, and come up with a result I really like. This post functions as a discussion of the general cone tracing technique, it's strengths and weaknesses, the ideas I added to the concept, and a litmus test for the demand for this solution as either a cheap starter project or a more costly quality addition to larger games. If you haven't researched voxel cone tracing yet, give it a Google. It's interesting stuff!



    Current Strengths
    • Realtime physically accurate specular and diffuse reflections on any surface
    • Infinite diffuse light bounces (explained below)
    • Absolutely no baking
    • Reacts immediately to changes in level geometry, lighting conditions
    • Any surface can emit light in realtime
    • Framerate independent relative to number of light sources
    Current Drawbacks
    • DX11 only
    • Much slower than baked results
    • Does not cooperate with other surface shaders
    • Rough voxel resolution sometimes makes for some chunky artifacts
    • Diffuse reflections barely affected by occlusion
    • No cascading volumes, distant objects not included
    The solution involves rendering the nearby geometry into a 128^3 3D texture and cone tracing through the volume in a custom surface shader. As I'm already rendering into the volume to begin with, I'm also doing diffuse cone traces during the 3D rasterization process using a previously rendered volume. The result of this is that for each new volume render, light is given another diffuse bounce.

    Performance
    Tested on my GTX770

    With a 128^3 resolution volume it runs 120fps at 720p, 60+fps at 1080p, or 120fps at 1080p with a reduced 64^3 volume. The following screens come from a fullscreened editor window on a 1080p monitor. Notice the degradation in reflection quality and boost in speed from the lower volume resolution.

    $128GridScreen.png
    $64GridScreen.png

    Future Work

    Right now, the cone tracing is done right on a surface shader, so if developers want to add this solution as an afterthought on top of other shaders of theirs, they're going to have a bad time. I'm scheming a way to do the cone tracing in a deferred screenspace pass once I have all the color, normal, depth, specular, roughness and emission data per-pixel. Once that's up, people can use whatever shaders they want to to receive light, as well as specialized shaders for emission and specular reflections. On top of that, you'll notice dark patches or crusty edges where a cone-trace collides immediately with an adjacent surface, so I'm working towards adding screenspace reflections to supersede these voxel artifacts the solution to add some detail to the edges of objects. I coded my own ambient occlusion shader as a separate pass already.

    The thing is, right now I see voxel cone tracing as an outlier to game development. There's a significant subset of gamers that won't be able to use this solution. Even though it runs 120fps on my rig, I'm sure a lot of people will be disappointed by their computer's performance. As such, I don't see this technology being effective for First Person Shooters or other twitch based games, and may be better suited for a niche horror, exploration or simulation title.

    $SteamDX11stats.png
    Fortunately, Steam's statistics indicate a majority of it's users have DX11

    Product

    With that in mind, I've been thinking of releasing a cheap ConeTracingGI Starter Project with my current tech to encourage developers to experiment with the technology and search for their own improvements. Is the asset store the place to release this, or are developers looking for refined professional solutions more akin to Chris Kahler's dynamic GI?

    The other option is to continue refining the solution until it's plug-and-play with any existing project - targeting developers looking for extra bells and whistles to add to their existing game. The problem in this lies that developers may assume the solution will run quickly on their games and will be suited to their gameplay, when I feel this realtime cone tracing hasn't reached that point.

    To summarize: Overall I'm really digging this development process, and it's a lot of fun to tweak and experiment with! There's a lot of potential here and it feels like a real step forward towards next-gen game experiences, though not there quite yet.

    I'd love to hear your thoughts on the subject.
     
    AntonioModer likes this.
  2. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Congrats. This is really advanced stuff.
    I remember when I tested the Elemental Demo when UE4 was still using this technique. They decided to deprecate the method because of its bad performance. It was like 4fps in a 560 ti xD

    Anyway, I find this really interesting for model showcase.

    Keep it up!
     
  3. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    Good work!! You should be very proud it looks very good too me. Looks like it would make a valuable asset. Your deferred rendering idea would be even more clean if you could make that work.
     
  4. TacticalDan

    TacticalDan

    Joined:
    Jan 1, 2013
    Posts:
    35
    Yeah, sure hoping it would! It may improve the framerate as well.
     
  5. TacticalDan

    TacticalDan

    Joined:
    Jan 1, 2013
    Posts:
    35
    I was pretty disappointed when they got rid of it. I had greeted some of the developers in person at GDC 2013 and was giving them praise over the technology, and they were all awkward because it was already gone by then :p

    Yeah, the effect really shines in smaller showcases, when the volume is tightened up so the voxels aren't that visible.

    Thanks a bunch!
     
  6. Gistix

    Gistix

    Joined:
    Jul 21, 2013
    Posts:
    29
    That looks great! Would it work on DX11 with DX10 videocards? Btw, I got a little something too, it's not that good but...
     
  7. TacticalDan

    TacticalDan

    Joined:
    Jan 1, 2013
    Posts:
    35
    Pretty

    I'm guessing not but I haven't tested this. I'd guess I could pop in my old AMD card if I wanted to try.
     
  8. Bdelcast

    Bdelcast

    Joined:
    Jul 11, 2014
    Posts:
    23
    Hey, from what I can see this is the best solution aiming for Cone tracing right now (both other projects disappeared into the ether), I'd be really happy if I could get a scene to play around with the current implementation. I've been trying to get into this but my work obligations have kept me from really researching it.

    Awesome stuff though. Gongrats.
     
    Last edited: Jul 13, 2014
  9. KheltonHeadley

    KheltonHeadley

    Joined:
    Oct 19, 2010
    Posts:
    1,685
    You guys can also just wait for Enlighten.
     
    jameos likes this.
  10. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,664
    ...which might likely will be a Pro-only feature, but yeah. Would be better.

    However, LIVENDA is brewing something called SpectraGI.
     
  11. jameos

    jameos

    Joined:
    Sep 22, 2013
    Posts:
    111
    looks awesome something u couldnt tell was unity .although only dx11 limits certain computers compatibilty
     
  12. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Enlighten is a realtime GI were dynamic objects doesn't contribute to GI. It's not 100% dynamic.
     
  13. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    I think there is a system coming that will support both DX9 and DX11 (and opengl) from Livenda.

    This is what i would buy, i want to be able to port my game to every system, not just DX11 enabled ones and this is always my top priority when buying an asset.

    I have bought around 3000$ of assets here and i think only one is DX11 only and do not use it in my game, just bought it on offer to see the effects :)

    So, my suggestion would be to make a universal system, this would have a big demand imo. Also i would wait it out and see how it plays with Unity 5 and its own systems and new possibilities, maybe compute shaders get a global appeal in Unity 5 (but i am nort sure).
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Enlighten is still limited in the way it needs to prep and process a scene's geometry before being able to tap on realtime GI. But then, Enlighten doesn't require DX11, and looks amazing and it's very fast indeed.

    In some situations you might need a fully realtime solution, and that's where something like this may be useful. I can certainly see it being a useful high end option for power rigs. Probably not useful for next gen consoles though, need slightly more muscle considering it will probably be rendering an entire game to boot.

    But, each thing in it's place :)
     
  15. HonoraryBob

    HonoraryBob

    Joined:
    May 26, 2011
    Posts:
    1,214
    This looks like a great method. But how do you render the nearby geometry into a 3D texture? I assume you step a camera through the nearby areas of the scene and render from each step into a different slice of the 3D texture?
     
    Last edited: Mar 16, 2015
  16. vahi2008

    vahi2008

    Joined:
    Oct 1, 2010
    Posts:
    321
    Can you share the project/or some part of it for learning purpose ?

    Is it comfortable on mobile ?