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. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    77
    What are the main differences between this project and the one Unity released?
    https://github.com/Unity-Technologies/VolumetricLighting
    To me it seem like Unity's one doesn't support directional lights but this one doesn't have area and tube lights nor fog volumes. Is this correct?
     
    Last edited: Sep 22, 2017
  2. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    I don't know anything about VR, I don't have VR device so I wouldn't count on me fixing it.

    More or less. This one supports all builtin light types including shadows and light cookies. Unity one has pretty limited support for builtin lights but it does support area and tube lights.
    Both projects also render volumetric lights in a completely different way. Each has its own advantages and disadvantages. Try both if you can and use the one that works best for your use case.
     
    UnityLighting likes this.
  3. wingsfan64

    wingsfan64

    Joined:
    Sep 17, 2017
    Posts:
    1
    Currently working on a project in Unity 5.6.2, and I'm getting this error:

    Invalid pass number (1) for Graphics.Blit (Material "Hidden/BilateralBlur" with 1 passes)
    UnityEngine.Graphics:Blit(Texture, RenderTexture, Material, Int32)
    VolumetricLightRenderer:OnRenderImage(RenderTexture, RenderTexture) (at Assets/Amazing/Volumetric Lights/Scripts/VolumetricLightRenderer.cs:354)

    Is there a simple fix for this? Did I forget some part of the setup?
    (I'm not a code guy)

    FIXED:
    I fixed it by going into Edit > Project Settings > Player. Within "Other Settings > Rendering" I unticked Auto Graphics API for Mac. I then re-ordered the list so OpenGLCore appears above Metal.

    "This sorted the error... hope it works for others."
    -shahinrostami

    Thanks!
     
    Last edited: Sep 22, 2017
  4. NKdefiance

    NKdefiance

    Joined:
    Jan 4, 2017
    Posts:
    15
    Hi there, is there a way to get the fog to only affect the same layers as the light itself?

    Right now the fog effects everything, it does not not follow the culling mask of the light.

    Thanks.
     
  5. GiantGrey

    GiantGrey

    Joined:
    Jul 2, 2012
    Posts:
    266
    Is there a way to fix this error:
    Invalid pass number (3) for Graphics.Blit (Material "Hidden/BilateralBlur" with 1 passes)
    looks like it appears on certain graphic cards.
     
  6. lloadead

    lloadead

    Joined:
    Sep 3, 2013
    Posts:
    3
    Invalid pass number (1) for Graphics.Blit (Material "Hidden/BilateralBlur" with 1 passes)

    me too earlier versions works fine !!!
     
  7. Linkooo

    Linkooo

    Joined:
    May 16, 2016
    Posts:
    29
    Hi,

    I want to use volumetric lighting on the sun in my scene to get a result like on the github screenshots, i have tested every settings but I can't get near to your result. Also when i look directly at the sun with shadows enabled the volumetric lighting disapears.

    Here is the Unity project, what settings should i use?

    https://github.com/Linko-3D/Realistic-Unity-Project
     
    Last edited: Oct 8, 2017
  8. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Light's culling mask tells the light not to affect objects in layers not included in the mask. The problem is that the volumetric effect happens in the free space between objects. And the free space isn't in any layer. I'm not sure what you're trying to achieve. Maybe if you give specific example, we'll be able to come up with a solution.

    @propeller @lloadead Earlier versions worked with DX9 class hardware. Current version requires DX10, DX11 or newer. That's probably your problem? Can you verify that the problematic GPU is compatible with DX11?

    I don't have time to look now. I may take a look later. Try to play with cascade shadow drawing distance and other shadow related settings.
     
  9. NKdefiance

    NKdefiance

    Joined:
    Jan 4, 2017
    Posts:
    15
    Thanks for the reply.

    I need to have a world with distinct environments in their own contained sections. For instance, I have one area that is a desert environment with bright lighting, but directly next to it I need to have a winter environment in the middle of a blizzard with heavy fog.

    The fog cannot bleed over into other sections, and you need to be able to see whats happening in one section from outside of it. Imagine basically an "environment in a glass box".

    I was hoping your solution would be able to work with that but maybe not.
     
  10. GiantGrey

    GiantGrey

    Joined:
    Jul 2, 2012
    Posts:
    266
    yes that's what I thought. Unfortunately I don't have much information about the used GPU.
    But according to our bug reporter it's a
    Intel(R) HD Graphics Family with DirectX 10.1 GPU

    Is it possible to create a fallback? Or to deactivate Volumetric light completely? As for now I do deactivate Volumetric light based on the DirectX version. But looks like that's not enough.
     
  11. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    I'm not seeing the noise animate or move. I have imported this into Unity 2017.2.0f1 so I know that might be the issue. Other than that it's not throwing any warnings or errors.

    Actually never mind, applying to my first person camera and the noise is indeed working. So for any future users, yes this asset is working in 2017.2.0f1. I seem to have overlooked the fact that one imported package set Time Scale to 0 and that appears to affect the Editor when not in Play mode as well.
     
    Last edited: Oct 13, 2017
  12. arwe12

    arwe12

    Joined:
    Jun 4, 2017
    Posts:
    1
    Does anyone know why I might get these errors? \
    I only see them when I build my project.

    Code (csharp):
    1. WARNING: Shader Unsupported: 'Hidden/BilateralBlur' - Pass '' has no vertex shader
    2. ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)WARNING: Shader Unsupported: 'Hidden/BilateralBlur' - Setting to default shader.
    3. WARNING: Shader Unsupported: 'Sandbox/VolumetricLight' - Pass '' has no vertex shader
    4. ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)WARNING: Shader Unsupported: 'Sandbox/VolumetricLight' - Setting to default shader

    The scene turns almost totally black when I run the program:
    https://i.imgur.com/jOtraiD.png

    I have included the shaders in always include shaders:
    https://i.imgur.com/V3nu2vV.png

    Everything works great when I run in the editor. I have another project using True Volumetric Lights with no issues when it is built. I tried to copy over all the settings from that project to the broken one but I can't seem to fix it. Anyone know what might be causing this?


    BIG BOLD EDIT:
    I finally fixed this problem by deleting my terrain, and then rebuilding the project. I added the terrain back in and rebuilt one more time and voila, everything works. If you try this yourself MAKE BACKUPS of your scene before you delete the terrain. Hopefully this helps someone else some time.

    Also: this fixed an issue where my builds were taking eternally long amounts of time (i.e. could not finish a build). So if anyone has super slow builds, you may try this method as well.
     
    Last edited: Oct 23, 2017
    JamesArndt likes this.
  13. Linkooo

    Linkooo

    Joined:
    May 16, 2016
    Posts:
    29

    Attached Files:

  14. CyclonicTuna

    CyclonicTuna

    Joined:
    Sep 22, 2017
    Posts:
    4
    Hi there,

    I have a question about the plugin regarding 360 video.

    I'm working on a project where I'd like to use the volumetric lights. However I'm forced to use this 360 video renderer called Helios: https://www.assetstore.unity3d.com/en/#!/content/63643

    And I can't seem to get it to work properly. In the preview window the volumetric lighting seems to work fine, however when I enable Helios and start rendering it just seems to completely ignore the volumetric lighting.

    I've already contacted the creators of Helios but they couldn't help me resolve the issue. So now I'm here on the other end asking for help.

    So I'd greatly appreciate some suggestions and/or fixes I could try. It might be worth noting aswell that I'm not really a programmer myself, and I'm not that familiair with Unity yet.

    Thank you in advance.
     
  15. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    The effect is disabled when there is no visible shadow caster. For example when you look up in your scene That's a known limitation of unity (or at least was when I made this). You could use some invisible shadow caster in front of your camera as a workaround. It would force unity to update shadow map. It is described somewhere in this thread.
    Otherwise I suggest trying it in real world scenario. There will be some unwanted quick changes to the shadow map cascade if all you have in the scene is small plane and a box. It will work better in regular level scene.

    I'm sorry but I can't help you with this. I'm not going to buy 3rd party asset for 30eur so that I can debug it in my free time.
     
    Martin_H likes this.
  16. lloadead

    lloadead

    Joined:
    Sep 3, 2013
    Posts:
    3
    My card is a directx 10.1 compatible , yes earlier version works very well :(

    Can you please fix this problem for old graphic card ?
     
  17. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    It's highly questionable if it makes sense to fix issues for old graphics cards, when it's quite possible they won't have the raw processing power to make good use of dynamic volumetric lighting to begin with.
     
  18. Nadimaride

    Nadimaride

    Joined:
    Jan 8, 2015
    Posts:
    1
    Hi, im having a problem with the volumetric lighting, when i build the game it disappears... any idea why?
     
  19. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Have you manually included the shaders in the appropriate list of the project settings? Unless it's used in a material that is being used somewhere you need to manually check in all shaders you need here.
     
    Adam-Bailey likes this.
  20. StefanFortuin

    StefanFortuin

    Joined:
    Nov 10, 2017
    Posts:
    1
    Hey,

    i was really looking forward to use this in my small little game but i read in this forum that you stated that it didnt work with a orthographic camera.

    Is there any way that you can implement that it could work with orthographic?

    Great project, keep going!

    Thanks
     
  21. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    I suppose it could be done but I don't have time now. It's crunch time. Game development ftw
     
    Alverik likes this.
  22. DINKmod

    DINKmod

    Joined:
    Jan 25, 2017
    Posts:
    14
    Hey @Michal_ !! Thanks so much for your continued support on this forum for your open source projects. It's very generous of you and we all appreciate it. And this is a great tool, especially for free.

    I did want to post something on here that was already mentioned in this thread, but I couldn't find if anyone had any answers on the forum about it or any possible fixes.

    Here are some screenshots from my scene, which illustrate the issue.

    The volumetric effect doesn't draw under certain camera conditions. I've actually got 4 volumetric lights in this scene, but this shot and this light is really the only one I'm having this problem with.

    EDIT: Correcting the images. It showed up in preview but not when I posted. Damn Google Drive!









    I've tried various methods to fix the issue, including:
    Moved the light into a different position, including just floating in the middle of the scene.
    Different light types.
    Created new lights.
    Created new cameras.
    Shadow bias.

    I believe I've tried some other things, but these are the ones I've got off the top of my head. I also experience the issue where if you have the camera face away from the light, the volumetric stops drawing - I know some others on this thread have mentioned this.

    I'm also curious: Does anyone know if the hx Volumetrics plug in on the asset store have this same issue? Looks like a great plug in from @Lexie and I might buy it if there really is no way to fix this issue with Michal's open source volumetrics. (It looks like a fantastic plug-in that does a lot, but I'm only doing a portfolio environment project right now, so I only wanted a simple solution.)

    Thanks everyone, in advanced! :)
     
    Last edited: Nov 25, 2017
  23. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    @DINKmod Interesting. Is this about baked lights or general problem? I've never used baked lights in unity so I'm not sure about their limitations. Can you make a small repro project that would illustrate your problem?

    If it is about baked lights, then you could also use second realtime light as a workaround. Add real time light identical to your baked light. Disable it and use it only to render the volumetric effect. You would have to make a small change in VolumetricLight.cs because I think I check if the parent light is enabled. And it wouldn't work for shadow-casting light.

    Otherwise unity decides what light or shadows needs to be rendered based on visible receivers but it doesn't consider the volumetric effect (obviously). So sometimes it turns of light/shadow and that disables the volumetric effect even when it should be visible. There are possible workarounds for those special cases.
     
  24. DINKmod

    DINKmod

    Joined:
    Jan 25, 2017
    Posts:
    14
    I'll set some time aside to try to make a repro project for you.

    I was thinking this was a possibility, but hadn't gotten around to trying it yet. I'll probably end up doing it this way!

    Thanks very much, Michal.
     
    Last edited: Nov 25, 2017
  25. baal547

    baal547

    Joined:
    May 30, 2017
    Posts:
    1
    Hi,

    Is there any reason why i have a 7 spotlight limit with this?
     
  26. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    None that I know of. I can definitely use more than 7 spotlights. I just tried that without any problems.
     
  27. LordSoth

    LordSoth

    Joined:
    Apr 7, 2013
    Posts:
    3
    Hello,

    We are using the volumetric effect on our project, which is pretty cool. Thanks for developing.

    As long as we are developing for Ps4, we have the following errors on shaders:

    Any help would be appreciated. Thank you.
     
    Last edited: Dec 22, 2017
    maxaud likes this.
  28. Givago

    Givago

    Joined:
    Oct 22, 2015
    Posts:
    27
  29. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Hi. I would help but I don't have a ps4 devkit. Not even at work anymore. The error only tells me that the shaders didn't compile but not why. I would need to know the actual shader compiler error to get any idea of what's going on.

    Nope. That's the one and only version I made. I stopped working on it a long time ago (beyond occasional bug fix).
     
  30. TinyMonti

    TinyMonti

    Joined:
    Nov 28, 2017
    Posts:
    1
    Hi Michal

    Thank you very much for this awesome volumetric lights, I've tried it out on my windows computer and it worked very well. I want to use it on a school project and I have to work on a Mac there. The problem is, that on the Mac, the volume scattering doesn't work. I've tried so many things to fix it but I don't get a solution....

    The Problem is, it looks just like fog, as if it ignores the objects in my scene (those are the same objects like the scene on my windows computer) so there are no light shafts.... It's really sad because we want to make a beautiful ambience and without it, it wouldn't be rly nice...

    Graphic API is OpenGLCore

    hope you have an idea how I could fix it

    Mac_VolumeScattering.png
     
  31. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    konsic, maxaud and Gametyme like this.
  32. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    I would help but I don't have Mac. OpenGL on Mac should be working according to other people though. I'm sorry, I can't think of an reason and I have no way to try it.

    Very nice. It is kind of hard to believe you can do this in Unity. You've got yourself a like sir. Good luck!
     
  33. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    77
    Tried out the Volumetric lighting repo by Unity. Good quality, ability to make areas more dense and custom tube and area lights were nice, but performance was a mess. Bought HX Volumetric lighting from the assetstore. Very good performance and nice quality. Only problem is that it's lacking macOS metal support. So I spent the afternoon looking for solutions and tried this repo again.
    Apparently it now works on metal too! Very nice!
     
  34. matthewse19

    matthewse19

    Joined:
    Aug 9, 2015
    Posts:
    3
    When I make a mac build there's this pink overlay on the screen, but it doesn't occur in the editor or the windows build that I run on my computer. I'm pretty sure I've added all the shaders correctly too, though maybe I need to do something special for the mac build.
     

    Attached Files:

  35. uvavoo

    uvavoo

    Joined:
    Oct 15, 2007
    Posts:
    60
    I am having a similar problem on my mac too. Works fine in editor. But now in build it displays a black screen. Shaders have been added to Graphics/Always included shaders in the graphics preferences.
    It has worked previously in a build, so the 2017.3 version of Unity has broken it. This is a real pity as this is a great asset. I hope a solution is found, as I am no expert on shaders and I have a feeling this it the culprit. Thanks for the work on this asset to the author.
     
  36. Deleted User

    Deleted User

    Guest

    Hello! I've seen the demo video and i need to ask you how did you do the red laser effect emmited from the sphere. Good job dude!
     
  37. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Custom shader but same technology as this. Imagine a very thin volumetric spot light with a cookie texture.
     
  38. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,068
    I think there is a little/big bug in VolumetricLightRenderer.cs

    Code (CSharp):
    1.  
    2.         if (_pointLightMesh == null)
    3.         {
    4.             GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
    5.             _pointLightMesh = go.GetComponent<MeshFilter>().sharedMesh;
    6.             Destroy(go);
    7.         }
    8.  
    You create primitive sphere to obtain it's built in mesh.
    And than destroy it with Destroy().
    This will defer the destruction of this sphere, unfortunately it has a collider and will collide with other bodies until fully destroyed.

    Changing Destroy(go); into DestroyImmediate(go); solved the problem form me.
    Still the best option would be to obtain mesh directly, if possible.
     
  39. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Hi folks, any update on 2017.3 compatibility?

    If not, is there a similar asset, free or paid, that has the same kind of lightweight, simple and good functionality?
     
  40. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Weather Maker has full volumetric light with fog and supports VR, and renders all the lights (including area lights!) in ONE full screen draw call. Works even on mobile.

    https://www.assetstore.unity3d.com/en/#!/content/60955?aid=1011lGnL

    Discalimer: I am the asset author
     
    Last edited: May 11, 2018
    mcbauer likes this.
  41. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Vapor is free (from same guys as Alloy).
     
    Mauri likes this.
  42. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Thanks guys. I'm sold by demo scenes and its hard to beat this one. I only need the volumetric lights for a few locations/scenes and I don't need the weather functions etc.

    Michal, Aura fog /volumetric lights version 1.00 was broken by Unity 2017.3 as well, but it was fixed pretty simply in 1.01 a few days later. Its all open source, maybe you can find the fix from that asset to fix this one?

    https://forum.unity.com/threads/released-free-aura-volumetric-lighting.441387/

    Aura fog is too complex/powerful, and the UI is still fairly raw, plus it is incompatible with multiple cameras. I want a simple asset that I can work within the limitations of and that has been tested, refined and used by people for many months.

    There are so many of these open source fog assets... I wish there was a killer paid one with support for the latest Unity versions :) $20, $30, $40, the price is immaterial compared to the value of an asset with support.
     
    Last edited: Apr 15, 2018
    pcg likes this.
  43. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
  44. PleaseEnterYourName

    PleaseEnterYourName

    Joined:
    Feb 11, 2015
    Posts:
    11
    I am running several projects in 2017.3, and my volume lights are working well... What issues are you facing ?
     
    Dreamaster likes this.
  45. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    LOL these folks had me bawling last week because I assumed this project went to Hell in a hand basket after 2017 launched or something, as I've been away from Unity for a long time and just recently started getting back into it. I loaded the sample project up in 2017.3 this morning and it worked great still! Then I upgraded to 2018.1... again expecting it to break but it upgraded and worked fine. WHEW.
     
  46. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    Holy crap! Has it been 4 years? This was my post a while back to help people get these lights easily integrated into their own project.
     
    Adam-Bailey likes this.
  47. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    Of course, i can't really know what year it is for you, but in my (current) timeline, it has only been less than 2 years since that post.
     
    Dreamaster likes this.
  48. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    Thank you! Things get confusing since the "accident".
     
    Whippets and Adam-Bailey like this.
  49. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
  50. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    No, there's no tutorial and yes, it is a bit messy. I never expected so many people will want to try it. Anyway, I believe you need Resources, Scripts, Shaders and Textures folders. Everything else is there just for the sample scenes.

    You may want to consider some other solution. This project is pretty much dead. There's a bunch of free and paid plugins out there. I'm sure some have actual support.
    Also, Unity 2018.2 will ship with built in volumetric lights if I'm not mistaken.
     
    Martin_H likes this.