Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Realtime GI (LPV) for dx9 and Mac (will release soon for FREE)

Discussion in 'Works In Progress - Archive' started by brianasu, May 12, 2014.

  1. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Update

    Source is now free to download.
    Github project is here https://github.com/brianasu/unitygi


    Update

    Did a fix for Windows. I only tried it on my parallels with win 7 so hopefully it will work. Sorry should have double checked it on Win again.

    Update

    Sorry for the delay. Just cleaning up the source code but if you can try the demos and see if they work on your older PC's that would be awesome. I'll release the source free soon. The reason it's free is there are probably better paid solutions out there and it's a good learning experience for everyone. I think the next leap in graphical technology is real bounced lighting.

    I've added some more shaders including particle lighting.

    **Version 2 Web player DEMO Cornell Box** (1 mb)

    [/HTML]

    ** Version 2 Web Player Demo Conference Room ** (4.4 mb)






    Keep an eye out here for all the source code.





    Releasing my realtime GI for dx9 and Mac. It's an implementation of Light Propagation Volumes using a simplified cascaded volume. It works also in the editor so you can preview it. I'm not using SPH but straight color bleeding to reduce memory footprint. Works with spot and directional lights.
    Here is a image with a bunch of image effects on :)

     
    Last edited: Jun 1, 2014
  2. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,782
    Nice, how's the accuracy and did you also find a way to get rid the light leak in LPV?
    can you show another screenshot, maybe bit more complex scene?
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Would like to see it with just the GI/shadows and nothing else.
     
  4. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Good old sponza. The light leaking still exists but I might try the solutions crytek suggests or just go onto another type of tech called radiance hints.

    I'm not a super duper shader guy I just wanted to create a simple nice but not super physically accurate GI. I've had this project for a while and it just got way too messy. I removed all the spherical harmonics and just voxelise the scene from the camera view, blur the 3d volume to fake propogate the lights and then render.

    Sorry for my crappy screen shot skills. This has no post on it just a model and light.

    Indirect + Direct
    $gi1on.png
    Direct only
    $gi1off.png
    Indirect + Direct
    $gi2on.png
    Direct only
    $gi2off.png
     
    Last edited: May 13, 2014
  5. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,657
    Just for clarification: With "dx9 and Mac", you mean that it's also compatible with dx9 and Mac, not that it's just a Mac only-thing?
    It looks great and it'll be even free, which is a nice addition. Thread bookmarked!
     
    Last edited: May 28, 2014
  6. Soul-Challenger

    Soul-Challenger

    Joined:
    Dec 30, 2010
    Posts:
    152
    Looks great! Can't wait to test this.
     
  7. Deleted User

    Deleted User

    Guest

    Looks interesting. Judging from screenshots, I would call it more of a color bleeding solution instead of GI since light distribution seems rather localized and uneven across scene.

    But color bleeding is great in itself. I think very rich-looking results can be achieved by combining color bleeding with strategically placed lights and/or ambient lighting.
     
  8. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Yeah you are right passe. I'm not using spherical harmonics now so there is "back propogation". I should probably change it to light bleeding but not sure if everyone understands that term. I should just title it stuff that makes it look like you have GI.
     
  9. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    When are you releasing this? Because even though my lighting doesn't look too bad, a Fake GI solution would look better... :D

    And is this for free version too?
     
  10. XilenceX

    XilenceX

    Joined:
    Jun 16, 2013
    Posts:
    122
    Free (Fake) Realtime Global Illumination!?! I must be dreaming, bookmarked and eagerly awaiting the release!
     
  11. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,784
    This looks very interesting.... :)
     
  12. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Updated with some new web player demos.
     
  13. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,782
    demo not working for me, no Light bounce and the particle are pink
    Btw Your new thread title make me happy :)
     
    Last edited: May 28, 2014
  14. Axel59

    Axel59

    Joined:
    Feb 28, 2013
    Posts:
    37
    it's not working too, same problems
     
  15. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Same here, I do like the weird light fog in the BG though!
     
  16. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    I think it might be related to tex2Dlod. Are you guys running windows or mac?
     
  17. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,657
    Same problems here. No light bounces at all, everything is dark, pink particles.
    Since you have not responded to my previous posting above, I assume that this is not Windows friendly at all.
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,840
    works fine on mac.
     
  19. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Trying to get it to work on windows unfortunately only have access to a mac no. I think it's just a small tweak to the shaders and openGL stuff. That's why I'm doing these webplayer demos to work out the kinks:)

    Does anyone know if tex2dlod fails on windows?

    Not trying to deny you windows users stuff of free stuff Mauri just takes a bit of time:) If it doesn't work out I'll just post the source and let you guys hack at it.
     
  20. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    @Mauri
    Did a fix for Windows users. Give it a try again.

    @FuzzyQuills
    That is my v-lights asset store tool. Creates volumetric lights with shadows.
     
  21. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,657
    Tested it again. It works now. :)

    The Control + Mouse thingy doesn't work.
     
  22. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Source code is up now to download. It's build on Unity 4.5.
     
  23. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @brianasu:

    Pitty the same can't be said for clouds... I can't really find a free solution anywhere for that.
     
  24. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    One more thing: perhaps a simple release with the bare-bones to get started? I don't know what to take...

    EDIT: the demo scene for minecraft won't open properly on my PC: it says "D3D shader assembly failed: cannot have dynamic conditional "if" blocks"

    EDIT: WTF?! ALL OF THEM DO IT NOW!!!
     
  25. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    That minecraft scene is a bit huge. Not sure if it's just killing your system. It's pretty much drop the light bleeding prefab in the scene adjust your volume bounds and assign the surface shaders to whatever object needs to render the lightbleeding.

    I'll take a look at the d3d shader problem and do a quick tutorial on the wiki.
     
  26. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    It's more likely because I have an Intel HD 3000... Other shaders have done this.

    But the big surprise is that the webplayer runs perfectly. Is the editor any different?
     
  27. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,782
    Your github give me a lot of shader error, and the LPV doesn't work on dx9 only at dx11
     
  28. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I guess i could try DX11... In fact, I will try this now!

    EDIT: I just discovered something horrible: is this pro-only...? :(
     
    Last edited: Jun 5, 2014
  29. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    dx9 compiler stuff fixes. Yeah unfortunately it's only pro. I can try using read pixels but it probably would chug.
     
  30. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I can use readpixels! I have before, and making it smaller makes it a bit easier. I will see what I can do. :)

    EDIT: Well, that failed... there's too many textures to recode! :confused:
     
    Last edited: Jun 5, 2014
  31. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Ok, just a question: would it be possible to re-use an LPV texture from this? Sort of like LPV-based GI baking?

    If so, I might PM you on something I thought about! :)
     
  32. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Yeah I have thought of that. It would technically be a dense light probe volume. Bake the area once then use that 3d data to light the characters.

    I've actually moved on to deferred irradiance probes similar to in far cry 3 and assassins creed games.
    https://twitter.com/brianasu/status/540679384839880706

    http://codeflow.org/entries/2012/aug/25/webgl-deferred-irradiance-volumes/

    It's semi realtime but much more efficient than LPV.

    They let you relight a static scene using spherical harmonics. Most of it is working but I'm still having some artifacts computing cubemap => spherical harmonics.
     
    Arkade likes this.
  33. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Eric2241 and Mauri like this.
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,840
    wow, that sounds (and looks) really great!
     
    Eric2241 likes this.
  35. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    +1! :)
     
    Eric2241 likes this.
  36. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,782
    How's the performance?
     
  37. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, according to one of those links, it has a large amount of overhead from all the overdraw- DAMN IT!!! :D I said "over" twice! :p

    Anyway... From what the page said, the performance was okay, but the ton of overdraw from doing everything was apparently too much. Point being though, brianasu may have improved it by now. :)
     
  38. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    It's kinda fill-rate bound but I can still get pretty good performance even on my 5 year old mac book pro. The "heavy" parts are reprojecting the shadow map onto the baked cubemaps and converting the cubemaps to spherical harmonics. I've offloaded both onto the GPU and can even render 2nd and 3rd bounce illumination. I might clean it up and upload it to GitHub and you guys can hack it.
     
  39. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,838
    Impressive !!!! I will start a new project and start experiementing with it asap

    Is it Unity Pro only ?

    That would be amazing, thanks :)

    Will your implementation require DX11 for the GPU part ?
     
    Last edited: Feb 5, 2015
  40. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Please do! The work you're doing on this is incredible! :)

    And I did guess from the blog-post that fill-rate was the problem... :D
    For first question... yes, it's pro-only... :(
     
  41. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    [Edit]
    Sweet! finally a LPV solution is not based on dx11, and working with Mac !
    Good job! :)
     
    Last edited: Feb 6, 2015
  42. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,838
    Perhaps it is for the best, if the speed is increased this way. I will test it when i activate Pro test period.
     
  43. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    We might as well produce a baked version for Unity free as well... ;)

    Ironically, I just finished my own lighting system, of which I could actually add bounce illumination like brianasu's approach! (I produced it to replace Unity's default light probes,, of which aren't available in unity free... :()
     
  44. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,838
    That would be cool to have in parallel to the faster one, for sure :)
     
  45. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Possibly! :)

    I have also made a few adjustments to correct some weird-as artifacts I got, mainly tuning the interpolation algorithm, and finding half a million ways to occlude the main light with lightmapped shadows... :D
     
  46. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
  47. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    @FuzzyQuills That's pretty cool. Is it still using a volumetric texture with the lighting info?

    @Luckymouse I do most my work on my mac so everything has to be dx9. It's a bit of a pain in the arse but I've learned a lot of cool hacks.

    @nasos_333 I've done tests with get and set pixels and it does run but I can't read occlusion info from a shadow map unless I do read pixels with really slows down the frame rate. Your GI Proxy stuff is pretty cool.

    The main difficulty is that all these solutions work is small closed environments. I can try cascaded LPV or some other stuff but it's not very stable and. At the moment the best results are from using deferred irradiance probes.

    I'll try to get some code out there but my other work is kinda getting in the way:)
     
  48. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,838
    Thanks :)

    In general i would prefer a solution to be in Unity Pro, if that would give the maximum performance, or even GPU based (DX11) now that Unity 5 supports building DX11 for other than windows platforms.
     
  49. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well... I am not sure if it's right to call it a volume, but yes, I do store lighting data into a PNG file, and ironically, the map looks a bit like yours! (Of course, the file has a .bytes extension, so it's loadable by the script as an asset!)

    An example of what I'm talking about (Taken from a project I installed the system on):
    bake .png
    You will probably have to zoom in to see all those little squares... :D BTW, the texture is encoded like so:
    Texture size = width is 6 x height, which is number of probes in scene.
     
  50. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Also thought about adding a baked shadow map to the scene as well, to help occlude light (atm, I use the -Y face of the lighting information, of which works on simple scenes, but if the surface itself is a dark color... :D)