Search Unity

Completely Real Time Global Illumination Using Light Propagations

Discussion in 'Assets and Asset Store' started by brilliantgames, Oct 24, 2014.

  1. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Real Time Global Illumination Using 3D Light Volumes



    THREAD HAS BEEN MOVED! http://forum.unity3d.com/threads/co...glossy-specular-reflections-no-baking.312277/




    Video Trailer




    WebDemo, Cornell Box: https://dl.dropboxusercontent.com/u/65183439/SimpleRoomdemo/SimpleRoomdemo.html


    DX11 Village Benchmark Demo(Expensive): https://dl.dropboxusercontent.com/u/65183439/VillageBenchMarkDX11.zip


    Real Time GI That Works?

    Hello Unity community. It's been some time since BG Light Engine was released. Before it was released, I promised real time global illumination. Unfortunately, after trying several different methods, I could not fulfil that promise in time for release. Well I have finally found the right solution. It has some similarities to Cryteks methods of light propagations using 3dtexture volumes, only the 2 systems work very differently and I have been able to take things further by adding the ability to have infinite bounces while having all lights injected into a single texture.


    Features
    This GI contains full diffuse and specular reflections all completely in real time. This means, any light or geometry can move and be fully updated in both the diffuse and specular(Unity 5 GI only allows lights to change and move around in real time, not geometry, there are also no real time specular reflections). For lower end machines, you can choose to have static GI. Static GI with this system means, diffuse and specular reflections will remain correct, while movement of lights and geometry within reflections will not update. Keeping the GI static means there is virtually no cost to performance!


    Performance
    The performance draw back on the GPU is almost next to nothing. I have estimated that the total computational power required to approximate both diffuse and specular reflections is the equivalent of 5 point lights(This never changes no matter how many secondary light sources). The only draw back so far is injecting the reflect maps into the volume. Since I have not found a way to generate and modify textures within CG, I must use C# to inject the reflect maps into the volume in real time on the CPU. However, performance is still very fast if resolution is kept low, and I am working my hardest to find other solutions.


    Asset Store Deal
    I am putting this solution into 2 different packages. The first being of course, BG Light Engine, which is already available for purchase on the asset store(The package contains Area lights and physically based shading). The second, will be the GI on its own. Many people may only be interested in the GI by itself, so you will be able to purchase just the GI for a lower price.


    With all this said, here are some screenshots to keep you excited. Videos and demo's are coming soon. The stages of this project are still pretty early, but extremely promising. Happy GI everyone!


    New volumetric lights. Add thousands of box shaped lights to your scene at nearly no cost to performance.




    New Skylight With Occlusion(No extra cost to performance)

    With Occluded Skylight & GI Bounces




    GI Bounces Only, No Skylight.



    No GI Bounces Or Skylight.




    Cornell Scene



    Screenshot showcases multiple bounces in sponza. Observe the reflections of the lion on the floor and sphere. This is not possible without multiple bounces.




    Demonstration of emmissive material reflections. All of the light and reflection from the fire is a result of GI.




    Clear shot of both diffuse and specular results.




    Another Sponza shot.





    The first screen shot I ever took of successful diffuse and specular reflections.

     
    Last edited: Mar 19, 2015
  2. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    633
    This looks great! In the first picture, why aren't those reflections possible if you don't have multiple bounces?
     
  3. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,360
    Very impressive :), how much will the standalone GI pack be ?

    Also does the system needs the shaders of a project to change in order to be implemented ? That is the most crucial factor for my project, since would be very hard and time consuming to use it.

    Thanks
     
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Would it be possible for this work with a larger environment, or outdoor scene, and still have the dynamic response to moving objects or procedural meshes?
     
    Baldinoboy likes this.
  5. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Way to go!!!

    I have to admit... I was one of those doubting Thomas's when you said you needed to put everything on the back burner, but you stuck with it and pulled it off!! Cheers!

    Would your GI be able to plug into another rendering system like Jove 2?
     
  6. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    If light is bouncing off of an object that is not directly lite, that means there are multiple bounces.

    @nasos_333 I cannot say yet.

    @imaginaryhuman Yes. Though I do have yet to implement cascading.

    @Licarell I cannot guarantee compatibility with any package at this time. Though it's extremely cheap to render so it shouldn't be hard to integrate it into any shader yourself. It's likely it could squeeze in the same pass with any single pass shader out there. Besides, this is going to be physically based on it's own, you likely aren't going to need to clutter it up with other physically based systems. ;)
     
  7. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,360
    Is there any chance to make it independent of shaders as an option later ? Like apply it as post filter in Pro or by other means.
     
  8. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937

    It may be possible to make it a post effect down the road. But that is not my focus right now.
     
  9. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,360
    Ok, that is great :)
     
  10. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    This one's a beauty. Light and specular reflections from emmissive fire material. No point lights, just GI. :)

     
    blueivy and Baldinoboy like this.
  11. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Holy cow that is incredible. I have so much wanted to see someone with any dynamic GI have a scene with a fire particle lighting the room and now you have. I am so happy:D. That is awesome. Thank you.
     
  12. Mistale

    Mistale

    Joined:
    Apr 18, 2012
    Posts:
    173
    I'm guessing this is a naive question, but since you said that the gi is cheap to render; mobile support? :)
     
  13. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    It requires a minimum of shader model 3.0. So if the phone can run that, technically it will work. It might be do-able with the GI volume being static.
     
  14. Mistale

    Mistale

    Joined:
    Apr 18, 2012
    Posts:
    173
    Hmm, perhaps I'll try then. It would depend on the features used from sm3 since sm3 is a desktop standard. Looks like newer gles 2/3 devices do have support for most sm3 functions (with varying performance), but no way to know for sure without knowing which functions are used.

    Would it be possible for you to test on iOS / Android once it's completed?
    For iOS, I would be happy even if it only runs on iPad Air / iPhone 5s and up.
    For Android, since it's hard to try on all devices, perhaps just provide a demo .apk which customers could try out on their target devices to see if it works?
     
  15. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,360
    Holy cow, bring this on fast :)
     
  16. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    561
    Very nice screenshots. However I do seem to miss the typical GI look. This might be the scene setup though.
    Is it possible to show us a cornell box screenshot? This would expose the GI capabilities of your system in a comparable manner.
     
  17. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    This one is interesting, it would allow many torches in game without having too much performance impact, since i was worried how to implement 20+ torches with each having point light on. That makes it very cool!
     
  18. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Your wish is my command! I have made some major improvements today. Accuracy and efficiency has been improved dramatically. I created a unique shader that pinpoints the exact location of each pixel in world space in the reflection map. No more relying on inaccurate depth maps! Very excited at the progress I have made. It's just about time for a video and demo!




    Diffuse Only. A more raw look.

     
    Last edited: Oct 26, 2014
  19. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    When you say reflection map do you mean that that reflection relies on baking or can the scene be totally dynamic ? The reflections certainly look impressive. Also can your system work with moving dynamic lights and could you give some idea of how many you can have in the scene before performance becomes a major issue ? Since it sounds like it is some sort of LPV isn't the issue usually that it only works well with one static light ? If the number of lights is an issue then it might be worth showing how well it works combined with other dynamic lights. I'm assuming for best performance you would have 1 lpv light that could produce all the reflections and gi and then have the other lights in the scene using a more simple algorithm.

    Also a demo to test out the performance on would be great
     
  20. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Nothing is static unless you want it to be. Reflection maps are generated in real time in a similar way to real time shadow maps. Yes, the more dynamic lights you have, the more expensive. But you can choose what resolution all your dynamic lights are(typically directional lights will need the highest resolution, while small point lights can use very low res). You can also choose to have a light/probe only render a reflect map once, making that light static, but the reflection maps are diffuse are still dynamically cast at almost no expense. Realistically, if it were me using this for a complex game with a day/night cycle, I would probably choose to have the directional sunlight completely dynamic, while having indoor lights partially dynamic or static. All of the lights reflection maps are transferred to a single 3d volume texture(multiple when cascading is implemented) where the shader approximates specular and diffuse.

    There you go, I pretty much just revealed how the whole thing works. Demo is coming very soon(Maybe a day or 2?), cause it's nearing the stage where it is getting reliable and stable enough for applications. :)
     
    Last edited: Oct 29, 2014
    shkar-noori and 8Infinite8 like this.
  21. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    561
    Thanks for taking the effort, very nice indeed!
     
  22. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Hmm interesting, allow me be a bit esceptic until I see it working on a demo-video but hey.. I'll be watching this..
     
  23. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Working on improving diffuse approximations further. Making some great progress. I decided the algorithm was too bare bones to accurately capture the surrounding diffuse reflections, so I Increased the samples. Each pixel now takes more angles into account.

    Screen shot of an area light made entirely with GI. This is how I have been testing accuracy.

     
    Last edited: Oct 29, 2014
    blueivy, Stormbreaker and Baldinoboy like this.
  24. Stormbreaker

    Stormbreaker

    Joined:
    Aug 15, 2012
    Posts:
    161
    Looks good! Can't wait to see a demo.
     
  25. ruth-salguero

    ruth-salguero

    Joined:
    Feb 26, 2014
    Posts:
    6
    @brilliantgames,
    do you have an ETA for an update on Asset Store?

    I'll buy your asset once it's updated :)
     
  26. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Occluded Skylight
    Today I added skylight/background reflections. You simply add a cube map of your choice to the volume and the diffuse and specular of that cube map will be used to 'background reflections'. This means, when a pixel does not find a reflection, the cubemap will be used for both the missing specular and diffuse. In other words, image based occluded skylight and reflections smoothly and correctly blended with the GI.

    Direct Light Only




    Direct Light + Multiple Bounces




    Direct Light + Multiple Bounces + Skylight



     
  27. Howard-Day

    Howard-Day

    Joined:
    Oct 25, 2013
    Posts:
    137
    This is amazing! I can't wait to see more. :D
     
  28. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    The coolest thing I have seen in a while. It is so beautiful. What is the performance like in the different images.
     
  29. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Skylight has no effect on performance because it is simply a cubemap multiplied into what's missing. Of course there is a performance difference with real time GI vs no real time or static GI.
     
    Baldinoboy likes this.
  30. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Cool. Thanks for posting those.
     
  31. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    More screenshots of the previous scene demonstrating skylight. It is the upcoming demo.




     
    Baldinoboy likes this.
  32. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Skylight certainly increases the quality, A LOT. The grass affects a bit oo much in color terms, but as a showcase is ok.

    Could you test it with a tunnel? I could provide you a CAD tunel model.

    If combined, the package of area lights lighting is also computed in a GI manner?.
     
  33. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Last image of the night everyone. Another screenshot from the upcoming demo I'm working on.

     
    Baldinoboy and Stormbreaker like this.
  34. CKahler

    CKahler

    Joined:
    May 6, 2013
    Posts:
    149
    @brilliantgames: looks nice! I also made something similar a year ago, however I didn't make it commercially available because of crytek's patent on this technique. Did you find a workaround ?
     
  35. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    very cool
     
  36. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,451
    Yay thank goodness skylighting!! :D
     
  37. Stormbreaker

    Stormbreaker

    Joined:
    Aug 15, 2012
    Posts:
    161
    Looks great!
     
  38. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    The 2 systems work very differently so I don't think it will be a problem.
     
  39. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Update of the day. Been doing a ton of tweaks and trying to make the bouncing as realistic as possible for multiple bounces of GI.

    Simple room test for multiple bounces. Note the occlusion/shadow naturally happening on the sphere near the wall.



     
  40. cg_destro

    cg_destro

    Joined:
    Aug 13, 2013
    Posts:
    142
    looking goood! :)
     
  41. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Is that light leaking on the floor next to the window or is it some sort of reflection? It doesn't look quite right...
     
  42. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Looks like the skylight.
     
  43. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,451
    It's a leak...it is the skylight but it wouldn't be lighting the corner where the floor meets the wall
     
  44. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    It is skylight. It's difficult to say for sure if that is a leak or not. There are infinite bounces in this scene. The point of the floor on the bottom would be receiving light right until the corner from both the skylight and the frame of the window, however in real life it would darken gradually as it got closer, but because of resolution limitations, this doesn't happen.

    That being said there are some leaking issues still. No matter what there probably always will be some, unless you are dealing with crazy high resolutions. Light is infinite in real life, in this case it is represented as a finite texture.
     
  45. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Is the wall a separate object than the floor?, It just looks like its receiving shadow information differently than if it where a single mesh...
     
  46. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937

    You might be confused here. The floor near the wall below the window is receiving light from the sky out the window and the skylight reflecting off the windowsill above, not from the sunlight bouncing off the floor.
     
  47. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,451
    I'm fairly certain him and I are talking about the same thing. We understand it's the skylight only there is no way it would light the area right up against the wall where the floor meets said wall. The sill would occlude it as the light is coming from outside the window (obviously). Bounces or not, there shouldn't be that pool of light...

    ...but who cares this looks great so carry on!
     
  48. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Haha alright. I did explain why that's happening though. It is because of the physical limits of the texel size in the resolution(which doesn't necessarily mean 'bleeding'). If I raised the resolution significantly it would darken as it got closer. The reason why is because the space in which it would darken would happen exponentially in a matter of inches. The texel size in this scene is about 8x8 inches, which is actually considerably high resolution for real time GI.
     
  49. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,451
    Right no and that's fine and I understand that completely.

    Licarell's next question then might be, "...if the floor and the wall were one object (shared edges) would that same limitation still occur?" :D

    (correct if I'm wrong Licarell, hehe)
     
  50. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Ditto... I don't mean to be anal here... I love what you have done BTW... it's just that my eyes were drawn there and as they say in France... Quelque chose qui couille la...


    And if the walls and floor where the same mesh would the limitation still exists;)
     
    Last edited: Oct 30, 2014