Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

True Volumetric Lights (Now Open Source)

Discussion in 'Shaders' started by Michal_, Mar 10, 2016.

  1. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    No, I think that's a new one but I don't have Mac anymore... Maybe at work if I find the time.
    Sorry, I don't know Azure and I'm not going to buy 3rd party assets and deal with compatibility issues.
     
    Crossway likes this.
  2. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    Thanks, I'll send a video of problem maybe I'm doing something wrong.

    Also please keep doing what you're doing! it's awesome and now it's part of my project.
     
  3. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    Hi @Michal_
    Got a bit of an issue.
    I just noticed that our debug lines don't show up anymore in our scenes, they are rendered using the GL class, and they appear only when the VolumetricLightRenderer script is removed or disabled from the camera.

    Is there some kind of conflict with something?
     
  4. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Not very familiar with GL class but it seems to render in immediate mode, so my guess is that you render it at "wrong" time and it is overwritten later. When does the GL rendering take place? Can you use Frame Debugger to inspect it?
     
  5. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    just out of interest, any idea where to check on the status of the UT proprietary fog solution?
    read some noncommiting tweets and posts but cant seem to find any concrete info?

    not that i much anticipate it since michal slam dunked it with his tech.
     
  6. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    77
    Not sure if this stuff is relevant but there's this https://www.assetstore.unity3d.com/en/#!/content/39939
    Also check the unity labs for new stuff, for now there's not much to download https://labs.unity.com/downloads but keep an eye out
     
    crackfox likes this.
  7. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    77
    If I don't remember wrong to render them you need to use a material, maybe you could just make them render later like Michal_ suggested
     
  8. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    hi enrico,

    that blacksmith demo is old hat and not very usable at that.
    thanks though, i just found it strange that there is no official word after its been clearly stated the tech will be available upon release of the adam demo/unity conference.

    no matter - thank god for people like michal.
    fwiw, his volumetric tech work also with the deepsky haze so its possible to have atmospheric scattering in addition to volumetric lights.
     
  9. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Actually the wording was more ambiguous than that - originally the adam demo page said 'expect to have these in your hands after Unite Europe'. It didnt say how long after. And at some point it was changed to say 'We'll make these freely available soon!'
     
    crackfox likes this.
  10. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    yeh "clearly" was somewhat exagerrated. still comes off unserious.
    tbh im so fed up of the same circle. every engine or platform, i spend so much time waiting for feature xy.
    unreal also put on volumetric light on their trello with the june as a goal and nothing happened. not even a word on it.

    what i´m saying is - i will really put my faith and money solely into ecosystems with a healthy community developing assets and tech independently. thats where most of the clever stuff seems to be happening.
     
    Ghosthowl and Enrico-Monese like this.
  11. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    I forgot to tell you over the forum craziness, I made the DDS importer a bit more robust (among other things). It supports different texture resolutions and newer file format. It should work for you as long as you stay conservative in the pixel format department ;)

    I'm getting the impression that it won't be part of Unity after all. It would be a shame because things that aren't integral part of Unity usually get neglected or completely forgotten. Just look at the Blacksmith demo. It is hardly usable now. If it ever was...

    That's a problem with general purpose engines. Too many users, too many different projects, impossible to make everybody happy. It is all about compromises really. That's why engine source code + experienced team is always your best bet. Usually not an option for indies though.
    Btw. if you're after atmospheric scattering and volumetric fog then CryEngine is probably best "free" option at the moment. Or if you're after advanced rendering in general. It has its own problems obviously...
    But look at the bright side. You can at least choose now. AAA engine would cost you fortune not so long ago, now it is pretty much free.
     
    crackfox and elbows like this.
  12. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Actually its July on UE4's roadmap. And their Roadmap still had things for May on it so I presume its out of date and in need of a refresh. I am certainly watching to see what happens with them.
     
  13. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    ive tried cry engine and wanted to ...cry. ba´dum-tssss.
    not often do i struggle to even import an asset.

    no, unity fits me perfectly. im loving the results im getting and the workflow, but again its mostly because of the community.
    if i want a feature, its most likely to be found in the asset store. also the third party asset support is the best i´ve encountered in a lifetime of using programs.

    @Michal: do you happen to have something in the store atm?
     
  14. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Yeah, CryEngine is ... different :) Good ol' proprietary engine built around a specific game. I don't know if you have ever used in-house engine before but some of them have pretty crazy workflows. From modified Maya as game editor (been there) to writing scripts, configs, anim trees etc. in Lisp (looking at you Naughty Dog). Anyway, making game and engine simultaneously in one team is a great experience. I really miss that.

    Nah, I work full time for AAA game company. I do this just for fun.
     
    Martin_H likes this.
  15. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    honestly, from the artistic standpoint, all off the alternatives except unreal are not really viable for us plebs.
    hope you find some time to bless us with some goodies though, nudge nudge.:)
     
  16. Invizx3

    Invizx3

    Joined:
    Feb 1, 2016
    Posts:
    8
    Thanks for this stuff! It looks and works realy great! ...In game mode.
    But when I make build, effect disappeared. Any processes in profiler. What am I doing wrong?
     
  17. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    Add all the shaders into "Always included shaders" in graphics settings.

    ...so, these 4 folders and their files, plus adding the those 3 shaders in the graphics settings (all as shown in the screenshot) are all you need to get these lights going in your project.

     
    tequyla and Invizx3 like this.
  18. Invizx3

    Invizx3

    Joined:
    Feb 1, 2016
    Posts:
    8
    Thanks for your help!
     
    Dreamaster likes this.
  19. SimStm

    SimStm

    Joined:
    May 24, 2013
    Posts:
    44
    After some time (I just got some free time to do some tests now) I realized after many tests that the lightning doesn't work because something happened with the "Volumetric Light Component" from my object after Deftly instantiate him. To solve this I've removed the component from my object and created a basic script to dynamically add the Volumetric Light Component into my object:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class AddVolumetricLightInRuntime : MonoBehaviour {
    6.  
    7.     private GameObject lightObject;
    8.     private VolumetricLight volumetricLight;
    9.  
    10.     void Start () {
    11.         lightObject = this.gameObject;
    12.  
    13.         volumetricLight = lightObject.AddComponent<VolumetricLight>();
    14.         volumetricLight.SampleCount = 12;
    15.         volumetricLight.ScatteringCoef = 0.25f;
    16.         volumetricLight.ExtinctionCoef = 0.01f;
    17.         volumetricLight.SkyboxExtinctionCoef = 0.9f;
    18.         volumetricLight.MieG = 0.1f;
    19.         volumetricLight.HeightScale = 0.1f;
    20.         volumetricLight.Noise = true;
    21.         volumetricLight.NoiseScale = 0.015f;
    22.         volumetricLight.NoiseIntensity = 3.84f;
    23.         volumetricLight.NoiseIntensityOffset = 0.3f;
    24.         volumetricLight.NoiseVelocity = new Vector2 (8f, 3f);
    25.         volumetricLight.MaxRayLength = 400f;
    26.     }
    27. }
    Everything works now. It's a workaround but can't figure out exactly why this happens...

    Anyway, awesome asset. The results are incredible.
     
    DxStd_IgnatPribylov likes this.
  20. Soul-Challenger

    Soul-Challenger

    Joined:
    Dec 30, 2010
    Posts:
    152
    Thanks a lot Michal! I'll check it out as soon as I'm back in civilization
     
  21. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    this looks awesome! well try asap! thanks!
     
  22. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    @Michal_
    Everything is fine in editor, but when I build my project and run it in Development Mode, I get these errors in the console when running it from the executable.

    (yes there are 4, the last 3 are not duplicates but individual errors)

    NullReferenceException
    > UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:170)
    VolumetricLightRenderer.Awake () (at D:/ProjectName/Assets/Volumetric Lights/Scripts/VolumetricLightRenderer.cs:160)

    NullReferenceException
    > UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:170)
    VolumetricLight.Start () (at D:/ProjectName/Assets/Volumetric Lights/Scripts/VolumetricLight.cs:94)

    NullReferenceException
    > UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:170)
    VolumetricLight.Start () (at D:/ProjectName/Assets/Volumetric Lights/Scripts/VolumetricLight.cs:94)

    NullReferenceException
    > UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:170)
    VolumetricLight.Start () (at D:/ProjectName/Assets/Volumetric Lights/Scripts/VolumetricLight.cs:94)

    NullReferenceException
    > UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:170)
    VolumetricLight.Start () (at D:/ProjectName/Assets/Volumetric Lights/Scripts/VolumetricLight.cs:94)

    How can I fix this?
     
  23. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Missing shaders. Popular error. Last time answered few post above. I'll add some error message and put it into readme on the off chance that somebody will read it..
     
    Dreamaster and yc960 like this.
  24. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    For anyone who had problems with cascade shadows, I accidentally found a fix while working on atmospheric scattering. It is live now along with checks for missing shaders and updated readme.

    I'll update the atmospheric scattering project this week. I wouldn't call it finished but I think it is usable now. I decided to retrofit light shafts from volumetric lights project to save time. I know it was a while and I don't want to delay it even more. I'll start a new thread and put a link here.
     
    elbows, looki666, Nateply and 3 others like this.
  25. eros-dadoli

    eros-dadoli

    Joined:
    Oct 17, 2015
    Posts:
    8
    hi everyone i'll show you my first blockout of the scene i'm creating with the @Michal_ volumetric light package



    Hope you enjoy :)
     
    Alverik, Lex4art, Dreamaster and 3 others like this.
  26. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    @Michal_ I have also noticed that if I look up in the right place, my skybox seems to flicker.
    I am using the Unistorm weather system but this doesn't happen with this disabled, so I am guessing it has something to do with the volumetric lighting system, or the way it's rendered.

    I believe it is something past the clouds layer that is being affected as they are still visible.
    http://kylebriggs.co.uk/wp-content/uploads/2016/07/Unity-VLighting.mp4
     
  27. salad__fingers

    salad__fingers

    Joined:
    Aug 11, 2012
    Posts:
    42
    When I add any kind of Ambient Occlusion (SSAO or HBAO), volumetric lights are no longer rendered, making this unusable for me :(

    Any solution or ideas?
     
  28. moure

    moure

    Joined:
    Aug 18, 2013
    Posts:
    184
    Just tested it today with unity's ssao from the cinematic effect package and everything worked without any issues!
     

    Attached Files:

  29. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Well, the way I reconstruct position from depth isn't entirely correct. Maybe the geometry gets clipped sometimes. I was lazy (I'm still lazy) and I hoped nobody will notice :) I guess I could finally do it properly. I'm not sure if that is your issue but we'll see.

    This is usually just about the order in which post-process effects are rendered. Can you try the one @moure suggested? I guess I could take a look at the one that is giving you trouble when I have time. As long as it is freely available.
     
  30. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    @Labyrith-Studios I fixed directional light rendering. Should be correct now at all times. Unless I made a mistake. It turned out Unity supports SV_VertexID semantic. That made it easy. I would have done it properly from the start if I knew.
    Anyway, let me know if it helps or if you have a different problem.

    Edit: @Crossway Maybe it will help you too.
     
    Last edited: Jul 27, 2016
  31. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    It seems this is causing more issues, running this now looks like this:
    vlight.png
    That little tile in the bottom right taking up 1/4 of the screen I think is what the scene is meant to look like, but the rest is unaffected.

    If I look to the fully top or bottom, this turns completely black around models.
     
  32. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    That's strange. It is working on my end. Are you sure you have updated all files? I changed 3 of them. Are the example scenes working for you?
     
  33. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    3 files?
    I copied just the VolumetricLight and VolumetricLightRenderer into the project, I thought that was all I needed for the functionality?
     
  34. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    Update: I copied all 3 files (sorry about that), but I am still getting the original issue, the corner square thing is no longer occurring, but it looks like the original issue (from the video) is still occurring.

    On the upside, I worked out that it is, the renderer is stopping, if I disable the VolumetricLightRenderer during play, I get the same thing, where the sky goes from it's white to blue (the colour it is without the vol lighting).

    It could have something to do with the BeforeForwardAlpha: PreFinal buffer seeing how turning that off does the same thing.
     
  35. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Do you have shadows turned on? Unity stops rendering shadows when there is no visible receiver. This effect is connected to shadow rendering and it stops working when Unity disables shadows. The problem is that there is no way for me to detect it. Try to put some shadow casting/receiving object in front of the camera. Or try if it happens when you manually disable shadows.
     
  36. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    http://imgur.com/PhBt2Gs

    i did a mood and look dev aswell
    thanks to your volumetric lights its pretty moody already ;D - great job!
     
    Michal_ and Peter77 like this.
  37. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Alright, I updated atmospheric scattering project. I think I spent more time cleaning the code, writing documentation, making example scenes etc. than I spent making the technology. How can you guys sell assets on the store? There are so many boring things you have to do :)
    Anyway, here is the new thread.
     
    Elecman and yc960 like this.
  38. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Time for a little advertisement. @Lexie published his volumetric lights technology on the Asset store today. If you're looking for polished product with full support then you might want to check it out. It supports transparent object too!

    That brings me to an interesting question. Does anybody plan to keep using this? Would you be interested in more updates? There's a bug during upscaling I plan to fix (point sampler instead of linear sampler). Only yesterday I found out I can use two samplers with one texture. I thought Unity doesn't support it. So, I'll fix that. It'll improve image quality. I planned at least one more update after that but maybe I'll keep it for myself?
     
  39. moure

    moure

    Joined:
    Aug 18, 2013
    Posts:
    184
    Judging from the repo favorites and watch stats alone i guess many people are interested in the project. Having a free open source option for volumetric lighting is also a great learning resource. It would be great if you could keep the project updated , but i also understand if it is getting tiresome to continue maintaining it.
     
    Martin_H likes this.
  40. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,369
    I vote for keeping it alive. Or even better, convince Unity to integrate it.
     
    Alverik, Dreamaster, yc960 and 2 others like this.
  41. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    I vote for keeping it!
     
    Alverik likes this.
  42. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    keep it alive!!
     
    Alverik likes this.
  43. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    I love this asset, only one like it.
    Although after the 5.4 update it seems to have turned itself off!?
     
  44. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Should work with 5.4 now. Try to update. Btw. was the problem you were having caused by the shadows as I suspected? There's a simple workaround if that is the case.
     
  45. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Keep it alive! Would be happy to donate something for this. Really is a great asset.
     
    Alverik likes this.
  46. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    I don't like making promises, but right this moment I'm using it and I don't plan on buying any asset for volumetric light. It's not essential to my project, but as long as I have the performance budget for it I like having it. Whether I'd switch to another free volumetric light solution (wasn't UT going to release one?) depends on which one is better for my usecase.

    I think it's super cool that you are sharing this great asset for free and I'm sure many people appreciate that they can use it and learn from it! Thanks again and keep up the great work!
     
  47. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    keep it alive!!
     
    Alverik and Martin_H like this.
  48. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    UT created a solution for the Adam demo but stated it would NOT be released with their Cinematic assets, they may choose to release it at a later date but seeing how we are still waiting the The Chase assets from SIGGRAPH 2013, I wouldn't bet on it.
     
    Alverik, hopeful and Martin_H like this.
  49. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    No, they stated that we would have it after Unite Europe. The decision to release it was already made. Its just a question of when. The best guide I have to 'when' is the twitter feed of Robert Cupisz, and last time I checked it sounded like we are likely to get it 'in the fall'.

    Personally I've stopped waiting for that and am using Lexie's solution instead. It's very good, as is the one this thread is about.
     
    Martin_H likes this.
  50. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    I'm still not sure what to do next but you can count on the following.
    • I'm not going to kill the github repo. It is here to stay. A also don't mind spending 15 minutes or so making compatibility patches every now and then. Like the 5.4 patch I made last night. I'll keep it working in foreseeable future.
    • I'll do some refactoring work in the next patch to make potential future changes easier on my side. Shader recompiling on the fly doesn't work for example. I want to change that. And I want to switch from dx9 hlsl to modern hlsl. Again to make my life easier. Nobody is going to port it to dx9 anyway. So prepare for a funny merge if you have local modifications. Quality and performance will be slightly improved as a side effect.