Search Unity

[RELEASED] Hx Volumetric Lighting

Discussion in 'Assets and Asset Store' started by Lexie, Aug 1, 2016.

  1. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    So unity's included unlit shaders dont cast shadows so they don't write to the depth buffer (unity uses the shadow pass to write to the depth buffer). Effects like SSAO and volumetric lighting use the depth buffer to calculate part of the effect.

    I modified the unlit shaders to include the shadow pass so they write to the depth buffer.

    Unlit-color
    Unlit-Normal(texture)

    using these should allow you to use the effect with an unlit type shader. If you intend on writing your own shaders, copy the shadow pass from these shaders and add them to your custom shaders
     
    Last edited: Oct 27, 2018
  2. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I'm organizing some time to work with switch compatibility in the coming week. Bug reports look like a texture format isn't supported (see post above yours for info), If the issue is deeper then that then ill have a build next week sometime with support.
     
    Last edited: Oct 27, 2018
    marcos likes this.
  3. marcos

    marcos

    Joined:
    Oct 18, 2009
    Posts:
    592
    Awesome!

    Thanks so much, looking forward to it :)
     
  4. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    83
    Hm, seems like that gives a different error:

    Code (CSharp):
    1. Unsupported texture format - needs to be ARGB32, RGBA32, RGB24, Alpha8 or one of float formats
    2. UnityEngine.Texture2D:SetPixels(Color[])
    3. HxVolumetricCamera:CreateTileTexture() (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricCamera.cs:2607)
    4. HxVolumetricCamera:CreatePIDs() (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricCamera.cs:694)
    5. HxVolumetricCamera:Awake() (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricCamera.cs:2526)
    What I changed in HxVolumetricCamera.cs:

    Code (CSharp):
    1.    static void CreateTileTexture()
    2.     {
    3.         Tile5x5 = Resources.Load("HxOffsetTile") as Texture2D;
    4.         if (Tile5x5 == null)
    5.         {
    6. #if UNITY_SWITCH
    7.             // https://forum.unity.com/threads/released-hx-volumetric-lighting.420343/page-16#post-3825607
    8.             Tile5x5 = new Texture2D(5, 5, TextureFormat.R16, false, true);
    9. #endif
    10.  
    11. #if !UNITY_SWITCH
    12.             Tile5x5 = new Texture2D(5, 5, TextureFormat.RFloat, false, true);
    13.  
    14. #endif
    15.             Tile5x5.hideFlags = HideFlags.DontSave;
    16.             Tile5x5.filterMode = FilterMode.Point;
    17.             Tile5x5.wrapMode = TextureWrapMode.Repeat;
    18.             Color[] tempc = new Color[25];
    19.             for (int i = 0; i < tempc.Length; i++)
    20.             {
    21.                 tempc[i] = new Color(Tile5x5int[i] * 0.04f, 0, 0, 0);
    22.             }
    23.  
    24.             Tile5x5.SetPixels(tempc);
    25.             Tile5x5.Apply();
    26.             Shader.SetGlobalTexture("Tile5x5", Tile5x5);
    27.             Shader.SetGlobalFloat("HxTileSize", 5);
    28.         }
    29.         else
    30.         {
    31.             Shader.SetGlobalTexture("Tile5x5", Tile5x5);
    32.             Shader.SetGlobalFloat("HxTileSize", Tile5x5.width);
    33.  
    34.         }
    35.  
    36.     }
    UPDATE:
    Even with the error, it seems like I can sometimes create a Switch build anyway. But the volumetric light doesn't look correct ...
     
    Last edited: Oct 29, 2018
  5. terrivellmann

    terrivellmann

    Joined:
    Mar 10, 2015
    Posts:
    23
    These worked great, thank you for getting back to me so quickly. Cheers
     
  6. renardmf

    renardmf

    Joined:
    Jun 29, 2012
    Posts:
    47
    Was there any plans for this asset to work with LWRP or HDRP? Thanks!
     
    Icetare likes this.
  7. 5LS-Brent

    5LS-Brent

    Joined:
    Sep 17, 2013
    Posts:
    14
    I'm having some issues at the moment getting the mie scattering/extinction effects to match the where it's emanating from the sky vs close up geometry



    You can see in the image above the intensity of the glow from the shafts on the geometry is not matching that on the skybox emanating from the sun.
     
  8. John-Lisenby

    John-Lisenby

    Joined:
    Nov 8, 2013
    Posts:
    122
    Hi,

    Quick question, does it work on UWP and UWP on Xbox?

    Thanks,

    John
     
  9. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    83
    Any news? :)
     
  10. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I was able to get the base effect running on the switch, Pushing a build today. Just keep in mind that the switch hardware is around the level mobile phone so its best to limit the use of shadow casting volumetric lights to 1.

    Play around with the the quality settings to get a good enough result at high enough frame rates.
    also low res rendering should help a lot with performance if you intend on rendering more then 1 light. I'd also rule out transparency support as that is expensive to calculate.

    There is still a bug with density particles that might take me some time to track down whats going wrong with that. But everything else is working. Although I don't know if the hardware would work very well with it anyway.
     
    Last edited: Nov 9, 2018
  11. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    350
    Hi, I have Unity 2018.2 and I still get this warning every time I import HxVL into my project:

    "`UnityEngine.Rendering.GraphicsDeviceType.Direct3D9' is obsolete: `Direct3D 9 is no longer supported in Unity 2017.2+'" (HxVolumetricLight.cs) - should be solvable with a simple #if.
     
  12. marcos

    marcos

    Joined:
    Oct 18, 2009
    Posts:
    592
    Any idea when this build will be available on the asset store?
     
  13. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    83
    Was just about to ask the same question. Newest version I can find on the Asset Store is 1.3.5b from September 27, 2018.
     
  14. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    DMing you a download link now.
     
    marcos likes this.
  15. marcos

    marcos

    Joined:
    Oct 18, 2009
    Posts:
    592
    Thanks! I'll give it a try tomorrow :)
     
  16. allornothingJM

    allornothingJM

    Joined:
    Feb 3, 2015
    Posts:
    20
    We're using HX with Post Processing Stack V2, and finding that it renders after the stack no matter what we do. At first I thought it was just some of the effects (Tonemapping/lens distortion) but on closer inspection it appears to be after everything?

    The effect components are above the stack to ensure the correct order but it makes no difference when we switch. Our version is up to date too.

    Is there a way for us to change the order of where HX is applied? I have tried switching to opaque but it causes a lot of problems visually in our environment (even with transparency support). Any advice would be greatly appreciated!
     
  17. E_Urban

    E_Urban

    Joined:
    Sep 16, 2014
    Posts:
    8
    I'm having some difficulty getting transparency to work correctly. 1st image is writing to depth, so volumetric looks correct. 2nd image is using the provided HxVolumetric/Sprites/Diffuse shader. It appears almost completely see-through. I get the same result when modifying other transparent shaders as described in the documentation. Transparency support is checked in the HX Camera component. Thanks for the help!


    upload_2018-12-5_20-20-55.png upload_2018-12-5_20-22-10.png
     
  18. seanybaby2

    seanybaby2

    Joined:
    May 17, 2013
    Posts:
    120

    Is there a way now to support spot lights, and point lights while not using single pass?
     
  19. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I could probably get it working, but this effect is pretty expensive to render for VR, you really need single pass rendering to get 90hz
     
  20. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    What version of unity are you using, Ill see if the somethings up with the sprite shader and that version of unity.

    Only other thing is you might need to change transparency distance. Increasing that might solve your issue.
     
  21. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Hey Lexie,

    I sent you an email about HXVolumetric lights not working on the Xbox One, using Unity 2017.4.17f1.
    Does it happen with other users ?
    Is this a known issue ?

    Thanks !
    Bruno
     
  22. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I've gotten a few reports of issues with Xbox one,

    I'm trying to arrange the use of an xbone dev kit for the weekend. I'm in the middle of a relocation right now so my personal kit wont be available till the end of the year.

    I'll let you know as soon as I have news.
     
  23. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    74
    I think there is bug in HxVolumetricDownscaleDepth shader.
    In fragQuaterCamera function there is line

    Code (CSharp):
    1. float2 outUV = float2(0, 0);// input.uv;
    In fragHalfCamera there is

    Code (CSharp):
    1. float2 outUV = uv;
    and in fragEighthCamera:

    Code (CSharp):
    1. float2 outUV = input.uv;
    Which one is correct? I think in all there should be same start value.
     
  24. KevinAristotle

    KevinAristotle

    Joined:
    Jun 25, 2013
    Posts:
    5
    Hello, I'm currently using Hx Volumetric Lighting for a VR game on the Oculus Rift. After upgrading to Unity 2018.3.0f2, I started getting the following error when exiting play mode in the editor:

    ImportAtPathImmediate is not supported for assets with import dependencies. Ignoring for asset: Assets/Plugins/HxVolumetricLighting/Resources/HxUsedShaders.prefab
    UnityEditor.AssetDatabase:CreateAsset()
    HxVolumetricShadersUsed:SetVolumetricValues(Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean) (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricShadersUsed.cs:110)
    HxVolumetricCamera:SaveUsedShaderVarience() (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricCamera.cs:2261)
    HxVolumetricCamera:OnDestroy() (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricCamera.cs:2247)

    Every time when exiting play mode, HxUsedShaders.prefab would get overwritten. And occasionally, when trying to re-enter play mode, the editor would crash.

    I was able to fix the issue by opening HxVolumetricShadersUsed.cs and changing every instance of the string "Assets/Plugins/HxVolumetricLighting/Resources/HxUsedShaders.prefab" to "Assets/Plugins/HxVolumetricLighting/Resources/HxUsedShaders.asset".

    Perhaps the new prefab system in 2018.3 isn't playing nice with creating prefabs out of ScriptableObjects, so an asset needs to be created instead of a prefab? Nevertheless, I hope an official fix can be released. Thanks!
     
  25. APhilpo

    APhilpo

    Joined:
    May 24, 2018
    Posts:
    5
    Thanks! I had the same issue and it looks like this has helped.
     
    KevinAristotle likes this.
  26. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    thanks for the report I'll look into it shortly.
     
    KevinAristotle likes this.
  27. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    In addition to getting the same console error when exiting, I'm also getting a warning about:

    Assets\Plugins\HxVolumetricLighting\Scripts\HxVolumetricLight.cs(477,46): warning CS0618: 'GraphicsDeviceType.Direct3D9' is obsolete: 'Direct3D 9 is no longer supported in Unity 2017.2+'

    It also seems that the bool ShaderModel4() method returns false no matter what.
     
  28. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I resolved an issue with the plug-in and xbox one xbk. Ended up being an engine issue but i found a work around. I'll be testing with older versions of unity tomorrow and if everything is fine ill push a new version.

    I've also fixed the issue with the 2018.3 and being unable to create .prefab objects. expect a new build in the next few days.
     
    glenneroo, Seith, punk and 1 other person like this.
  29. sandBucket2

    sandBucket2

    Joined:
    Mar 26, 2016
    Posts:
    29
    Hey Lexie, is there a way to have the fog disperse or fade out when the camera is close to the fog?
     
  30. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hi Lexie, is there a way to download the new version that works with 2017.4.18f1 and the Xbox One? It's kind of an emergency for us as we need to submit within a week... Thanks!
     
  31. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Hi, I have 1.3.5c and just tried to update to the latest version v 1.3.6, but the Asset Store is not saying that I can update. I'm using Unity 2018.3.1. Just deleted the cached Asset Store download so I can try to get the latest, but the version that gets downloaded still has the errors in 2018.3 as mentioned above (renaming "prefab" to "asset" as well as several shader warnings related to use of UNITY_MATRIX_MV). Did anything change related to those errors in 1.3.6?
     
  32. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    @Lexie What happened with the prefab fix?

    I just upgraded to 1.3.6 and I still get the error:

    [Error] ImportAtPathImmediate is not supported for assets with import dependencies. Ignoring for asset: Assets/Plugins/HxVolumetricLighting/Resources/HxUsedShaders.prefab


    EDIT: I also get this error:
    Opening Prefab Mode failed: The Prefab at 'Assets/Plugins/HxVolumetricLighting/Resources/HxUsedShaders.prefab' is broken.


    EDIT #2: I also replaced all occurences of HxUsedShaders.prefab by HxUsedShaders.asset in HxVolumetricShadersUsed.cs and no longer have errors.

    Hopefully its a proper fix.
     
    Last edited: Jan 23, 2019
    glenneroo and Alex_May like this.
  33. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    209


    Thank you! This solved it.
     
    Alex_May likes this.
  34. KevinAristotle

    KevinAristotle

    Joined:
    Jun 25, 2013
    Posts:
    5
    Hey Lexie,

    I'm currently in the process of refactoring code in my game so that scripts no longer generate garbage after they are loaded (or at the very least not on every frame). Unfortunately, HxVolumetricCamera.OnPreCull() generates 320 B of garbage every single frame. This issue occurs both in the editor and in standalone builds. Is there any chance that HxVolumetricLightning will be updated so that it no longer generates garbage every frame?

    Thanks!
     

    Attached Files:

  35. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Update to unity 2018.3, it was a regression on unity's end. Bug report
     
    hopeful likes this.
  36. KevinAristotle

    KevinAristotle

    Joined:
    Jun 25, 2013
    Posts:
    5
    Sweet, can't wait to upgrade to 2018.3! Just gotta wait for 2018.3.5 due to this bug
     
  37. allornothingJM

    allornothingJM

    Joined:
    Feb 3, 2015
    Posts:
    20
    Belated thanks for your reply Lexie - much appreciated. The original question was about Post Stack V2 not applying colour grade and tone mapping to HX.

    We'd prefer not to change to another tone mapper, as we're nearing the end of production and it seems an unnecessary change given the comments from Unity below. I'm also not sure if this would actually change anything as we'd still have ordering issues potentially as a result of HX's incompatibility with the stack order.

    This is a bit of an issue in our setup as it means we render volumetrics in space (beyond our windows) which obviously wouldn't happen :)

    I've followed up with Unity support as this remains a big issue for us. We were advised that they are not applying Tone Mapping before image effects are completed, but rather "tonemapping after the stack is done. Image effects that come after that are purely gameplay image effects on the final render" - HX is not integrated in any way to the stack, and thus will render after no matter what we do with the stack itself. They have said that for HX to be fully compatible with Post Stack v2, "they need to inject HX volumetrics into the stack itself, using one of the injection points we provide
    https://github.com/Unity-Technologies/PostProcessing/wiki/Writing-Custom-Effects "

    Is this something you can advise on? It seems like it would make sense to provide this as an option in HX for those using the Post Stack V2 (Which I Imagine is a lot!) rather than a range of other solutions.
     
    wetcircuit likes this.
  38. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    Could you provide a comparison of hx volumetric lighting against aura volumetric lighting and unity's own volumetric lighting in hdrp pipeline?:)
     
  39. papaonn

    papaonn

    Joined:
    Aug 21, 2015
    Posts:
    30
    Dear Creator, thanks for creating the shader!

    I have just purchased your assets recently, and plugged in to play with success of volumetric lighting.
    However, my current system has an underwater Fog shader implemented, and somehow Hx Lighting assets disabled it and now my underwater fog is gone, may I know how to fix this issue?

    UnderwaterFog.png
    Underwater Fog (Before HxVolumetricLighting assets import)

    UnderwaterFogMissing.png
    Underwater Fog lost ( After HxVolumetricLighting import )



    I am suspecting HxLighting is taking over the fogging configuration, or might not.
    The other alternative is to have HxLighting setup the fog shader for me to replace my old shader, but I have no clue where to start. Hope some advice could be given.

    Many thanks.
     
    Last edited: Feb 12, 2019
  40. Benjamin_Overgaard

    Benjamin_Overgaard

    Joined:
    Jul 20, 2015
    Posts:
    17
    Hey Lexie,

    Any news on getting HX to work with custom SRP?
     
  41. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    Hi, any idea why I'm getting this:

    ImportAtPathImmediate is not supported for assets with import dependencies. Ignoring for asset: Assets/Plugins/HxVolumetricLighting/Resources/HxUsedShaders.prefab
    UnityEditor.AssetDatabase:CreateAsset(Object, String)
    HxVolumetricShadersUsed:SetVolumetricValues(Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean) (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricShadersUsed.cs:110)
    HxVolumetricCamera:SaveUsedShaderVarience() (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricCamera.cs:2261)
    HxVolumetricCamera:OnDestroy() (at Assets/Plugins/HxVolumetricLighting/Scripts/HxVolumetricCamera.cs:2247)

    This is in In 2018.3.6.
     
  42. BlueSpirit

    BlueSpirit

    Joined:
    Jun 10, 2013
    Posts:
    33
    Hi,

    Awesome package! I have a few questions.
    Is there a way to reflect the volumetric lighting? I saw in an earlier post that it should work by adding that extra line in the HxVolumetricImageEffect script? But it doesn't seem to do anything for me :(
    I have a plane with a Reflection Probe and it's reflecting the environment just fine. It's just not reflecting any of the volumetric lighting. Any ideas?

    Also, for my next setup I want to have the plane "fade out" completely from full opacity to zero while having it reflect the volumetric lighting at the same time. Is that possible with volumetric lighting? Or is that going to be very tricky with the render queues?
     
  43. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,270
    How would this package do with Bakery Lighting assets
     
  44. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    The effect can only work with realtime lights. You could bake the indirect lighting in bakery and then have the direct lighting be realtime. But the volumetric effect would only work for the direct lighting. There wouldnt be a way to have the indirect light contribute to the volumetric effect.


    Updating the asset from the asset store should resolve that issue.
    I'm in the middle of writing a custom SRP to better understand the best way to add support for it.


    Looks like you water shader is doing a grab pass before the volumetric lighting is applied. You might need to look at the frame debugger to understand exactly what is happening there. Your water asset might have a setting for when to do the grab pass.
     
  45. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    I am using the latest version. If I try and re-import I just get the Nothing to import! dialogue.
     
  46. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    For anyone.
    Does this asset work with multiple cameras? (only one camera active at once but switching cameras at runtime).

    Thanks
     
  47. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    76
    Any news about VR support and the Lightweight Render Pipeline? The roadmap only says:
    • VR support (untested, may already work)
    Anxiously awaiting the day we can switch our project over to LWRP...
     
    Icetare likes this.
  48. HsinChien

    HsinChien

    Joined:
    Nov 19, 2012
    Posts:
    22
    Hi Lexie:
    I got these vertical strip artifacts on screen. How can I eliminate it? And also I am building a VR app running on a nvidia 1080 card, but with the volumetric light, the frame rate drop to 40fps. How can I make the frame rate higher? Thanks!

    upload_2019-3-12_14-21-1.png
     
  49. larnelar

    larnelar

    Joined:
    Dec 15, 2018
    Posts:
    1
    Hello. Is there a way to limit the volumetric area with cookie on a directional light? When I'm adding a light cookie to directional light, volumetric works as there is no cookie and the whole area is washed out.
    Thanks!
     
  50. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    Hey Lexie,
    I am making a game with portals and want the view through the portal to also show the volumetric lighting. Is this possible? I've added the component to both cameras, the second of which renders to a render texture, but the result is completely lacking volumetric light. Am I just doing it wrong?
    Cheers
    Alex