Search Unity

SEGI (Fully Dynamic Global Illumination)

Discussion in 'Assets and Asset Store' started by sonicether, Jun 10, 2016.

  1. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Can you be a bit more precise? Did you turn on the Volume Ray Casting or do you get this bright result when you use the Unity ShadowMap? I'm using Unity 2017.1.1f1 and SEGI Cascaded, I just reimported it into a new Unity Project and there were no errors at all, so maybe you have an old Unity version or you mixed it up with another SEGI version? Also the Unity shadows are currently only working when you set the shadows in the quality setting to "No cascades"... I need to fix that at some point.

    Edit: I think you are using gamma color space? Try it with linear color space... also turning of infinite bounces for now might help... anyway very sad that this "It's broken as hell." is the only feedback... even so the 2D volume conversion should improve performance, because there is no clear compute shader needed anymore. I must admit the Volume Ray Casting is very buggy at the moment, but when you use the standard settings without it everything should be fine.
     
    Last edited: Sep 29, 2017
    arnoob and RB_lashman like this.
  2. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    I can't give you more information at the moment, I replaced the SEGI folder with your version and didn't change anything. SEGI from the official repository works absolutely fine. I'm using Unity 2017.1.1p3.
     
    Last edited: Sep 29, 2017
    RB_lashman likes this.
  3. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I did some changes the brighten bug should be gone, it's currently not working correct with the infinite bounces.
     
    arnoob and RB_lashman like this.
  4. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    Yep. It works now. The difference is about 0.5 ms compared to the original version, but I noticed that emissive materials don't contribute to the GI.
     
    Last edited: Sep 29, 2017
    arnoob and RB_lashman like this.
  5. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Is the volume ray casting 0.5 ms faster or slower on your pc? Currently it's missing some features, the problem is the voxelization must happen before the raycasting shadows, so I might have to split color, emission and sun light up in different channels can think of another way.
     
    arnoob and RB_lashman like this.
  6. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    It's faster. Also, there's something wrong with the effect in the scene view.
     
    Last edited: Sep 29, 2017
    TooManySugar, arnoob and RB_lashman like this.
  7. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Funny that's faster on your pc, currently the default settings (without raycast and unityShadows) are still the fastest for me, but maybe I can optimize it a bit further. I know there is a lot of stuff missing due to the "new" pipeline, I let you know when everything works as expected, then you can test it, if it's still faster...
     
    RB_lashman and Frpmta like this.
  8. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    What's your PC specs?
     
    Last edited: Sep 29, 2017
    RB_lashman likes this.
  9. Casupaa

    Casupaa

    Joined:
    Mar 25, 2009
    Posts:
    20
    Are you testing on the same scene?
     
    RB_lashman likes this.
  10. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    GTX 1080, 3,6Ghz 8Core, 32GB Ram, testing with the Low Poly Scene.
     
    RB_lashman likes this.
  11. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    Interesting... Maybe it's just something different in Unity 2017.1.1f1 and Unity 2017.1.1p3? :D
     
    Last edited: Sep 29, 2017
    RB_lashman likes this.
  12. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    :)
    btw. I think this is a better solution (when you don't use VoxelAA):

    Code (CSharp):
    1. void interlockedAddFloat4(RWTexture2D<uint> destination, uint2 coord, float4 value)
    2. {
    3.     uint writeValue = EncodeRGBAuint(value);
    4.     InterlockedMax(destination[coord], writeValue);
    5. }
    6.  
    7. void interlockedAddFloat4b(RWTexture2D<uint> destination, uint2 coord, float4 value)
    8. {
    9.     uint writeValue = EncodeRGBAuint(value);
    10.     InterlockedAdd(destination[coord], writeValue);
    11.     // InterlockedMax(destination[coord], writeValue); // could be used for brighter shadows
    12. }
    I think this is a clearer and faster approach as the for-loop or while(true).... what do you think?
    ( I don't need the VoxelAA feature, it didn't make a big visual impact in my test scenes.)
     
    RB_lashman likes this.
  13. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    Well, the performance will be better, because the shader compiler will not produce a lot of garbage maths as it does now. But we need to test it.

    https://www.diffchecker.com/R2tJb3jF
     
    Last edited: Oct 1, 2017
    RB_lashman likes this.
  14. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    For all the fuss surrounding SEGI, I feel like I haven't seen much eye candy produced with this asset. Anybody have some amazing SEGI renders lying around?
     
    RB_lashman likes this.
  15. Abuthar

    Abuthar

    Joined:
    Jul 12, 2014
    Posts:
    92
    @buttmatrix a couple from the project i've been working on - not really a game, but I'm using unity. These are done in realtime (ofcourse) on an i7, GTX 980 with 16gb ram. I get about 700 FPS in the editor, with Heavy Post Effects, NGSS and all quality settings maxed out. SEGI has been a game changer for my project.







     
    P_Jong, CazCore, one_one and 7 others like this.
  16. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I have uploaded the a new VolumeRayCasting-Shadow version, infinite bounces and emission are now working again, but it's still WIP. (Also the unity shadow map works with the Volume shadow method now!)

    Nice pics Abuthar! Did you ever try https://github.com/TheMasonX/UnityPCSS ? I think it's more or less the same as NGSS, but the shadow softness is a bit more flexible... maybe combine both...
     
    Last edited: Oct 1, 2017
    arnoob, Lex4art and RB_lashman like this.
  17. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Could you explain what your volume ray tracing system accomplishes over the existing solution and what its pros and cons are? It's sounds interesting but I'm not actually sure what it does. Is it essentially a form of optimisation?
     
    RB_lashman likes this.
  18. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    @Shinyclef: The system creates shadowmaps via volume ray casting, instead of using traditional shadowmap rendering (where each object gets rendered separately via forward rendering). the volume ray casting only renders one voxelVolume per frame and creates a shadowmap with this data. So it's basically a voxel shadow, the quality is not as good, but it's a bit faster or at least not slower (depending on hardware and scene complexity; On my pc it's now the same speed as the normal tech). Also Spot or point light shadows might be be possible in the future via this system.

    I also added another feature, I called it "Use Unity Shadow Map(s)" (currently it's not working with unity shadow cascades but with a single unity shadow, I'm working on that) it adds the high quality shadowmap generated from unity to the voxel volume, without extra performance costs (maybe only noticeable on very old machines.)

    I also optimized the general SEGI code a bit, so maybe SonicEther wants to merge some part of it, I'm not sure if I should pull request my stuff, because it's still in an early stage, even so it's already working. Also I didn't fix the VoxelAA feature, I think it's not useful for me anyway.
     
  19. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    I've never seen any visual changes with this enabled !
     
    RB_lashman likes this.
  20. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Could I summarise this as "It lets you create shadow maps dynamically where previously you had to bake them"?
     
    RB_lashman likes this.
  21. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    No, sorry I thought you might have some tech/coder background...ok I give it another try, it replaces the internal shadowmap technique of SEGI, both are dynamically, but the volume tech renders one cube that traces stuff that creates shadows, the other (standard) tech renders all shadow casting objects... hope that helps.
     
    RB_lashman likes this.
  22. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Right I think i get it. Yeah I am a programmer, but I've not dealt with shadow maps before. In fact, I've not dealt with shadows in any form yet.
     
    RB_lashman likes this.
  23. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,664
    From the User Guide.pdf:
     
  24. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Good point, I need to test it further, maybe it helps with moving objects, but currently I'm happy with the results.
     
    RB_lashman likes this.
  25. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    I am dancing with joy to see the community work on this. Now if you guys excuse me I am going to go dance and sing a bit more.

    Good job guys and thank you Sonic!
     
    TooManySugar and RB_lashman like this.
  26. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    This outdoor scene is using segi. Much more believable lighting than i was getting before.

     
    P_Jong and RB_lashman like this.
  27. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    I recall @BruceJRBarratt posting some images of a nature scene using SEGI. Still don't know how he did that, but amazing stuff.
     
    RB_lashman likes this.
  28. Silas6

    Silas6

    Joined:
    Nov 5, 2016
    Posts:
    4
    Too bad you're getting a solid 16 fps
     
    RB_lashman likes this.
  29. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    SEGI requires you set up your scenes specially for it, it's not a silver bullet. The author gives tips earlier in the thread for dealing with open doors and so forth.

    edit: open world, no idea why I wrote open doors. Senile fart.
     
    Last edited: Oct 2, 2017
    AndyNeoman and RB_lashman like this.
  30. Ninlilizi

    Ninlilizi

    Joined:
    Sep 19, 2016
    Posts:
    294
    Couple of mine of SEGI in action
     
    coverpage, AndyNeoman and RB_lashman like this.
  31. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    to be fair that has more to do with the 100,00k plus grass/foliage and trees in the scene but of course there is no optimisation at the moment. I was getting a solid 40-70fps recently until some demon infected my scene.
     
    RB_lashman likes this.
  32. tweedie

    tweedie

    Joined:
    Apr 24, 2013
    Posts:
    311
    I think the bigger point is, SEGI simply frees you from having to bake anything, that's (pretty much) it. So if your lighting setup, or the composition / mood you create with that lighting is really poor, your visuals are gonna be really poor. That being said, people seem to rely a lot on SEGI + point lights, which isn't really the point (ba dum dum tss). Lighting things with emissive objects is about the only thing that'll instantly improves results, because then you get some really nice soft shadows, and it replaces the hack that are point lights with an actual, physical, light source.

    Anyway, my point is, people clamour over the next lighting solution thinking it'll give them AAA graphics, when really they should spend the time learning how lighting affects composition, colour and atmosphere etc etc. Lighting is, imo, the most significant factor in what makes or breaks an image. Poor modelling + texturing can be masked with excellent lighting, and excellent modelling + texturing can be wholly ruined by poor lighting. I just like SEGI for how quickly I can iterate through lighting designs.


    @Abuthar Some of those dragon shots are particularly nice. :) Great example of how much difference good post makes too.
     
  33. tcmeric

    tcmeric

    Joined:
    Dec 21, 2016
    Posts:
    190
    Anyone aware of any movement forward on this for single pass rendering (ie VR) ? :rolleyes:
     
    RB_lashman and Ninlilizi like this.
  34. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    I don't think there is any movement forward at the moment, and SEGI is still deferred only, so TAA or nothing.
     
    tcmeric and RB_lashman like this.
  35. Monkeybro

    Monkeybro

    Joined:
    Sep 15, 2017
    Posts:
    5
    One of the example images show an apartment interior that looks nice, but I can't get anything that resembles that quality in my simple text interior. I get a blurry, splotchy mess no matter what I do. Are there any unity scenes that I can download and dissect?
     
    RB_lashman likes this.
  36. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    In my experience, SEGI really benefits from a directional light, so if you have an interior scene that has windows open to sunlight, you can include a directional light and then place light cards (emissive quads) in the windows to further enhance the light distribution of the scene. Using the debug features, especially the 'visualize GI' can be helpful to ensure that an appropriate amount of occlusion appears in the right places. Of course, posting screenshots or sharing a sample scene can sometimes help - someone on the forum may feel compelled to have a go at improving your scene.
     
    RB_lashman likes this.
  37. Monkeybro

    Monkeybro

    Joined:
    Sep 15, 2017
    Posts:
    5
    (I have no idea why i wrote "text interior", I don't even know what a text interior is. I meant just "interior").

    Yes, I might have to do that. I work in archviz and putting area lights in windows is an old trick, but I try to avoid it since you often need to crank up the intensity to "propel" the light to the back of the room and get unnaturally bright areas near the windows. But I do have a patch of trees outside the window, so the light is relatively dim when it reaches the window. It might be that this particular scene just isn't optimal for this. Good tip about the debug feature, thanks. Can't share the project, but here's an image of the space.

     
    IronDuke, hopeful, Lex4art and 2 others like this.
  38. andrej-szontagh

    andrej-szontagh

    Joined:
    May 18, 2017
    Posts:
    20
    Hi everybody,

    I have finally have a time to try SEGI in my project. I have to say I haven't really checked the code yet but my assumptions about how the SEGI works were probably wrong.

    Is SEGI working in a screen/camera space ?

    I am posting a video showing how the lighting is changing quite rapidly depending on the camera view direction. I thought that SEGI voxelize the scene around the camera position in the world space not really a camera/view space. Why is that ? .. or I do I have set up something wrong ? Do any of you guys have the same issues ? .. or its normal ?

    To me this is far bigger problem then a light leakage, also I had a hard time to get enough light in the dark areas. I have infinite bounces turned on and indirect lighting gain is set to 1, however it doesn't seems that the light is getting far.

    The link to the video (temporary);

    upload_2017-10-3_15-43-48.png
    upload_2017-10-3_15-44-17.png
    upload_2017-10-3_15-44-45.png

    upload_2017-10-3_15-35-35.png
     

    Attached Files:

    RB_lashman likes this.
  39. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    If you're aiming for realism, SEGI may not be the way to go. Of the very impressive archviz proejcts I've seen in Unity (e.g. 1, 2, 3 - to name a few), none of them use SEGI, but instead rely on Unity's default lightmapping tools. Enlighten can be a nightmare to work with, but the new mixed mode with precomputed realtime GI + baked GI with Shadowmask is probably your best bet for achieving high quality indirect lighting plus specular reflections for smooth surfaces; fully baked lighting with Progressive Lightmapper is great, but doesn't respect normal maps.
     
    RB_lashman likes this.
  40. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Some eye adaptation might help with those dark corners, otherwise maybe try fidgeting with the settings some more. I'm not sure about your light instability issue, also not sure what version of SEGI you are running or if it is related to the new features that have been implemented.
     
    RB_lashman likes this.
  41. andrej-szontagh

    andrej-szontagh

    Joined:
    May 18, 2017
    Posts:
    20
    I took the master yesterday. Watch the video to see what kind of light instability I am talking about.

    Cascaded version looks the same but it somehow has lower resolution, so I don't use it. It would be nice to have ability to specify voxel resolution manually.

    Regarding setting I tried everything .. Eye adaptation is not really a solution, it's just too dark in contrast with the light up parts .. the relative amount of light is too low to look anywhere near natural. As I am writing this I have an Idea why is this .. I don't use Linear space. For the simple reason .. doing lighting and shading in linear space is correct but you should always convert result into gamma / sRGB space otherwise your contrast will be incorrect and image will look bad and that's what actually happened .. I need to google a bit about how this works in unity.
     
    RB_lashman likes this.
  42. Abuthar

    Abuthar

    Joined:
    Jul 12, 2014
    Posts:
    92
    Inclusion Layers on 2 causes a lot of AO and shadow issues. It's better on 1. Also you don't have a transform attached to segi so it will just follow your camera, which can cause issues when the GI updates since it's not always in the same position. A small tip as well, but at the cost of performance, Voxel AA and Mip Filter go a long way to improve accuracy and remove artifacts. And if the corners are too dark, turn down near occlusion and maybe turn up secondary bounce gain. Hope this helps.
     
    AndyNeoman and RB_lashman like this.
  43. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Thanks to the snap comment re the frame rate :) I've been tweaking. Getting a reasonable 30fps now. Some nice lighting at around 1m 30secs.

     
    LennartJohansen and RB_lashman like this.
  44. andrej-szontagh

    andrej-szontagh

    Joined:
    May 18, 2017
    Posts:
    20
    Thanks for tips. I didn't saw much difference before but I got some light leakage I set it back to 1. The Linear mode was the cause of brightness issue, however it's screwed lighting for my terrain, but at least I know what was the problem.
    The lighting instability is still there, I set up the "Follow Transform" to a empty transform at 0,0,0 .. however the lighting is still dependent on the camera view. I need to fix this light instability somehow.
     
    RB_lashman likes this.
  45. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Edit. It was just my settings reset so FPS wen through the floor. All back now. Thanks for the tips. Any gems directed at outdoor scenes with just realtime Sunlight (and moon but i have that as basic realtime shadowless light)

    Also I wonder why the camera needed. I tried to set it up as a public camera so I could hook up my player camera but it did not like that.
     
    Last edited: Oct 3, 2017
    RB_lashman likes this.
  46. andrej-szontagh

    andrej-szontagh

    Joined:
    May 18, 2017
    Posts:
    20
    Hi Everybody,

    so I have figured out the cause of the lighting inconsistency and view-like dependency (check my post above). It looks like it only happens when I use motion-blur in the my Post Processing Profile. When I turn it off the weird flickering and highlight flowing just disappears.

    However I have realized that with "Soft Sunlight" set up to zero I have zero contribution from the sun ! .. I am not sure if this is normal behavior but this is in the user guide :

    "Soft Sunlight: This adds cone-traced soft sunlight to the scene. This can be useful for partially cloudy environment lighting or just to add a soft look to the outdoor lighting. It is particularly effective for sunset lighting."

    So I am not sure if that is sun light contribution slider or this add something additional to the scene. However without using "Soft Sunlight" I have no sun contribution to the GI .. all GI is just from sky. When I set the "Sky Intensity" to zero I have no GI .. all black.

    Just to point out my sun reference is set up.

    Is this normal ?

    Why is GI interfering with motion blur ?
     
    arnoob, buttmatrix and RB_lashman like this.
  47. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    @drednac: There should be also indirect light with "soft sunlight" at 0, are you using SEGI Cascaded? Maybe test with the lowPoly Demo scene first to see if it works there... Also to find the reason for wrong GI behaviour is by turning on the Debug Tools -> "Visualize Voxels". If you use infinite bounces the shadow area should be lit, if not, the shadow area should be black like in the original poly scene.
     
    RB_lashman likes this.
  48. andrej-szontagh

    andrej-szontagh

    Joined:
    May 18, 2017
    Posts:
    20
    I don't know how it fixed it self (maybe after exiting Unity) but the only problem that I suffer at this point is motion blur interference. I would like to have a motion blur in my project, but when turned on the GI highlights starts to change depending on the camera angle .. it's weird. You can see it in the video I have posted above before.
     
    arnoob and RB_lashman like this.
  49. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    I have crash problem too with this new version of SEGI. then I must restart my PC after crash.
     
    FPires and RB_lashman like this.
  50. Silas6

    Silas6

    Joined:
    Nov 5, 2016
    Posts:
    4
    Getting better, but could still improve I'm sure.
     
    AndyNeoman and RB_lashman like this.