Search Unity

[RELEASED] Hx Volumetric Lighting

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

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    I don't use glow in the post stack and rely on volumetric but in the case of glowing material or glowing explosion, how do I do?
     
  2. ggevrin

    ggevrin

    Joined:
    Jan 8, 2013
    Posts:
    13
    Hello,
    I am currently testing your asset at our studio (fusebox-games) and of course it rocks. Results are very beautiful. Unfortunately, I am encountering a few visual artefacts, I hope they are related to bad settings but I was not able to find answers in your documentation. Please, feel free to redirect me to the dedicated support if I am at the wrong place.
    First and worst : results are different when I launch play mode from Unity and when I make a build. I am using Unity 5.5.2f1, I have no directional, only point lights (Hx lights) and particle effects (some Hx and some not Hx).
    In play mode, everything renders fine, camera Hx density is 0.2 ; the scene is crisp except near the Hx lights and it is fine. I made a screenshot of a wall torch using a point light and a particle system for smoke (Hx particles).
    When I make a build, the same scene is very foggy (as if the camera Hx density would be much higher) and the particle systems have no effect. I use deferred rendering and player settings are "Fantastic".
    Screenshots : GameMode is when I launch the scene from the editor and Build is... well... from the build.
    Thanks in advance for your answers
     

    Attached Files:

  3. ggevrin

    ggevrin

    Joined:
    Jan 8, 2013
    Posts:
    13
    Sorry for the disturbance. My issue is fixed by adding the shader Hidden/HxVolumetricPointLight in the "always included shaders" (graphics project settings). It seems that no other Hx volumetric related shader is needed. I guess I missed this point in the doc. My opinion is still the same : very beautiful volumetric effect ! :)
     
    hopeful likes this.
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    @Lexie, I'm trying to ground the objects in the scene with high scattering and they look far too saturated because ref probes don't work so I try using SSR from the unity post stack and it doesn't work with Hx, see attached photo.
    How then can I add directional ambient and reflection that takes Hx into account?
    SSR and volumetric.PNG
     
    Last edited: Apr 5, 2017
  5. Deleted User

    Deleted User

    Guest

    @Lexie
    I'm the lead shader developer for Alloy, and I have an integration question. Basically Alloy supports mesh-based decals that work in both forward and deferred mode with a variety of blending options. The additive and alpha ones are fine, because we can just fog to black using your VolumetricTransparencyAdd() function. However the multiplicative ones won't work because they need to fog to white.

    Questions:
    1. Do you provide a function that could handle this case?
    2. If not, could you add it?

    Thanks.
     
  6. Rumbleboxer

    Rumbleboxer

    Joined:
    Dec 26, 2012
    Posts:
    27
    @Lexie I'm experiencing a crash on unity 5.6 after attaching the volumetric lighting script to a directional light and opening the occlusion tab. Anyone else getting this problem?
     
  7. -Singularity-

    -Singularity-

    Joined:
    Jul 27, 2014
    Posts:
    122
    Hi, Love this asset but I'm experiencing problems after upgrading to 1.3

    I'm now spammed with debug logs that cut my frame rate in half, any way to disable this?

    I think it's related to the new script that HX volumetric camera adds to the camera
     
  8. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    I having the same problem as well. Before 5.6 I getting a bunch of command buffer error if I open the occlusion tab

    Actually you can just open the HxVolumetricLight script and highlight or delete the line 325
     
    -Singularity- likes this.
  9. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    @Lexie I've found a couple of problems with HX

    1. See pictures below, top one is quarter mode, bottom one is half quality. Half and Full mode, look the same, but quarter looks different, notice in the top picture quarter mode only affects the level geometry and not the sky which makes the effect look really odd, any way to fix that?

    2. In the latest version 1.3 single pass VR mode is broken in quarter and half mode. everywhere you look you can see chunky pixels around near meshes, of course doesn't affect full mode so much, but all modes worked in 1.2


    fog.png
     
  10. -Singularity-

    -Singularity-

    Joined:
    Jul 27, 2014
    Posts:
    122
    Thanks for this, very much appreciated!
     
  11. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    1)I've looked into it a little bit, Unity's internal team is working a few lighting over hauls using scriptable render loop. Ill probably leave it up to them.

    2)The static light maps are just painted on to the model, It doesnt have any 3D data of how the light looks. I'm working on a runtime GI that can support volumetric lighting. If it all works out all have a package that combines this plug-in and it.

    3) The modes are to control the density, It can be usefull to make sure a whole area is 0.1 density for example. You can do that by using the MAX blend mode. where if it was addative all the particles would add together and create a density over 1.

    4) If you want you could edit the script called HxVolumetricImageEffect and add this to line 13
    [ImageEffectOpaque]
    This will force it to apply the image effect before things like depth of field. Ill add a checkmark in the next version so you don't have to edit this.
     
    elbows likes this.
  12. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Thanks for the report. Ill have a look into it. My guess is its something to do with the depth aware upsampling.
    Ill look into the VR issue.
     
    punk likes this.
  13. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Strange, The plugin actually keeps track of what shaders you need and manually includes them. Must be a bug somewhere.
     
  14. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    If you edit the script HxVolumetricImageEffect, on line 13 add
    [ImageEffectOpaque]
    This will force it to render the effect out after the opaque step. Then just move the HxVolumetricImageEffect above the SSR script on your camera. Ill add a check box so its easier in the future.
     
  15. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    There is a function called VolumetricTransparency that you can use instead of that one. works the same way.
    it might be VolumetricTransparencyBase. I cant remember right now. I forgot to add them to the docs, Sorry.
    If that doesn't work I can add one.
     
  16. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    There is a bug with unity 5.6 and rendering out particle emitters in command buffers. If you disable density particle support on the hxVolumetricCamera script until they fix it, it should solve your problem. If that doesnt solve it. Can you tell me what the error message is?

    Edit: Whoops. I see what it is, It's some left over debug stuff to make sure a light doesnt render. Ill take it out.
     
    punk likes this.
  17. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Usage of Resources Folder

    Using quite a few packages in my project that add almost 200 MB of "stuff" much of which I'm not even using because they have plenty of assets in the resources folder, I've been doing some cleanup. As far as I can tell, there are only a few changes needed in HxVolumetricCamera to make this work properly and have Unity handle the dependencies for us (instead of Unity automatically including everything that was put into the Resources folder).

    Basically, what I did was add public variables to HxVolumetricCamera or using existing ones (and making them public or serialized if necessary), and assign the default values for the script from the project, replacing the code that uses Resources.Load(...). In some cases, like WarmUp() this also significantly simplifies the code ;-)

    I'm not sure if that's a direction you want to go but if you do, the best solution to not break existing projects would probably to simply keep the Resources.Load(...) stuff but only as a fallback if the variables aren't already assigned.

    Anyways, here's what I have now (I think this is so little code that it's okay to post this publicly, I hope I'm right with that assumption):

    Code (csharp):
    1.  
    2.     public ShaderVariantCollection shaderVariantCollection;
    3.     public HxVolumetricShadersUsed usedShaders;
    4.  
    5.     void WarmUp() {
    6.         if (CollectionAll == null) {
    7.             CollectionAll = shaderVariantCollection;
    8.             if (CollectionAll != null) { CollectionAll.WarmUp(); }
    9.         }
    10.  
    11.         if (UsedShaderSettings == null) {
    12.             UsedShaderSettings = usedShaders;
    13.             if (UsedShaderSettings != null) {
    14.                 TransparencyBufferDepth = UsedShaderSettings.LastTransperencyQuality;
    15.                 DensityBufferDepth = UsedShaderSettings.LastDensityParticleQuality;
    16.             }
    17.         }
    18.     }
    Code (csharp):
    1.     public Texture2D lightSoftCookie;
    2.  
    3.     [HideInInspector]
    4.     public Texture2D SpotLightCookie {
    5.         get {
    6.             if (_SpotLightCookie == null) {
    7.                 _SpotLightCookie = lightSoftCookie;
    8.                 if (_SpotLightCookie == null) { Debug.Log("couldnt find default cookie"); }
    9.             }
    10.             return _SpotLightCookie;
    11.         }
    12.         set {
    13.             _SpotLightCookie = value;
    14.         }
    15.     }
    16.  
    Code (csharp):
    1.  
    2.    void Awake() {
    3.         if (_SpotLightCookie == null) {
    4.             _SpotLightCookie = lightSoftCookie;
    5.         }
    6.  
    7.         [...]
    8.     }
    NoiseTexture3D I have simply assigned (and removed the assignment in Create3DNoiseTexture which otherwise would override my assignment from the editor), Tile5x5 apparently is currently created in CreateTileTexture anyways because the call to Resources.Load would fail (because it's not in resources).

    Finally, I also changed some paths referring to "HxVolumetricLighting/Resources" to "HxVolumetricLighting/ResourcesDontInclude" (but that's just my personal way of making Unity not include everything in that folder).
     
  18. overdox

    overdox

    Joined:
    Jan 8, 2014
    Posts:
    1
    Hi

    Have a small issue with my hx volumetric lighting setup.

    Firstly the volumetric lighting wont show up unless I turn of shadows.
    And when they are enabled, I get some strange black square shadows in my scene.

    Like this:




    I have tried multiple settings and configurations, I am not able to figure out what causes this. Anyone got any ideas?
     
  19. Mattiebo

    Mattiebo

    Joined:
    Feb 11, 2013
    Posts:
    12
    I've updated to 1.3 and now the effect appears to naturally work with all of my custom shaders, which is great. This may be a strange request, but do you have a way to prevent the effect from working over a certain material in the new build? I'd like the out-of-bounds areas in my top-down game to appear completely black. Before the update I managed this by using an incompatible material on the skybox.

    In other words, I'd like to make this look like this.
     
  20. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    The system already compiles all the variences that you actually use for your scene. none of the shaders are included unless you actually use them. Check out the object called hxUsedShaders. You can set what is to be included using that object. If you use the shader once though it will include it. So what you can do is delete this object and play through your scene and it will recollect the shaders you actually use.
     
  21. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Hmm. not sure whats happening there, I'd suggest removing the folder and reimporting the newest version. Something my have gone wrong with the update.
     
  22. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    If you edit the script HxVolumetricImageEffect, on line 13 add
    [ImageEffectOpaque]

    That should solve your issue.
     
  23. Deleted User

    Deleted User

    Guest

    @Lexie
    Are you sure about those functions? I've looked inside them, and they are multiplying the color rather than interpolating it to white.
     
  24. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Actually no, everything that is in the Resources folders is always included, regardless of whether you ever use it or not. It's explained in the Unity manual:

    Source: Unity Scripting Reference, class Resources

    They also recommend not using the Resources folder:



    Source: Best Practices - The Resources folder

    With HxVolumetricLighting, there's actually so little in that folder that it's probably not really an issue (except having all 6 noise textures in there, when usually only one is used, is a bit of a waste - that's about 5 MB that are not necessary). But I also have some packages that include their examples stuff in there, with plenty of really heavy assets (textures and the like). So this is not at all criticizing HxVolumetricLighting - but I'm hoping to create more awareness of this issue and as I've had a solution to have HxVolumetricLighting I thought I'd share it ;-)

    To give you an idea what abuse of Resources-folders means: An empty project, with an empty scene builds to 10.3 MB (that's only the data folder - the executable is another 20 MB). In my project, building an empty scene results in a 242 MB data folder. So that's about 230 MB of garbage that doesn't belong there. Not all of this is the Resources-folders - but a significant part is (148 MB, to be precise ;-) ).

    That's actually a really good point - I already have a mechanism in Holodance to warm up shaders after loading a scene before rendering to the HMD again; so I should probably use that instead of HxVolumetricCamera.WarmUp() ... even though the WarmUp method immediately returns when the shaders were already warmed up.

    The workflow I use is via Project Settings / Graphics, "Clear", then playing the section of the game with the relevant shaders, then "Save to asset..." and adding the resulting ShaderVariantCollection (named with the level, or in some cases where I share a set for several scene "semantically") to my scene loader to warm it up when necessary.

    Global shader warmup is another issue more people should be aware of (including Valve ;-) ). But I digress ...
     
  25. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Not for shader, Unity only includes shaders for materials that are in the resource folder and the variances assigned to each material as they are all optional compile defines.

    Yeah shader warm up is really important, My system warms up all the shaders its tracked at the start.
     
    Last edited: Apr 19, 2017
  26. hasseyg

    hasseyg

    Joined:
    Nov 16, 2013
    Posts:
    81
    Hi, I am getting a low fps in vr single pass, due to having a lot of objects in my scene that cast shadows. Is there any way, apart from disabling shadows, to choose which items effect the volumetric light at runtime, such as using a tag or layer.

    thanks
     
  27. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    @Lexie
    What types of light source your plugin supports?
    It only supports directional, point, and spot? no area light support?
     
    Last edited: Apr 24, 2017
  28. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    @Lexie
    I looked at your in-developing GI system.
    Realtime GI with emissive surfaces
    It is very impressive!

    I am wondering that GI system is only optimized for your voxel game?
    Or, you guys may publish it as another awesome asset for generic games?
    Many developers do not like Unity's default GI system... They are looking for good alternatives.
     
    Last edited: Apr 24, 2017
  29. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Hello,

    I tried looking through this thread for an answer, but couldn't find one... is MSAA support coming soon?

    Thanks.
     
  30. RecursiveRuby

    RecursiveRuby

    Joined:
    Jun 5, 2013
    Posts:
    163
    Hey,

    I'm creating a top down scene where the camera is a fair distance away from the objects and it seems that the shadows from the density light fade as the distance is increased. I've tried tweaking around with some settings which I thought would allow the shadows to be displayed at greater distances but it doesn't seem to be working the way I thought it would. I've also read through the documentation and I can't seem the find anything addressing this. Is there anything you would recommend? Also is there anyway to make the shadows more pronounced? More harder rather than softer rays I guess.
     
  31. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    There is a setting on the camera called Max Direction Ray Distance and Max Light Distance
    Max Direction Ray Distance - Changes how far away the directional light will be calculated to.
    Max Light Distance - Changes how far away spot and point lights will be calculated with the system.

    increasing these values should help.
     
  32. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    MSAA support is pretty hard. The effect Is applied as an image effect, So just like unity's directional light shadows, it wont be effected by MSAA.

    The only way to support MSAA is to create custom shaders for everything and sample the volumetric effect when it's rendering each fragment. It would be extremely incompatible with a lot of other assets on the asset store, and would mean a big overhaul to everyone's rendering pipeline.

    It's would make the system a little too complicated and no longer a drop in solution. so I don't think i can add it.
     
  33. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Only realtime Point, spot, Directional. if unity ever adds an official realtime area light, Ill add support for that.
     
  34. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    The system uses the shadow maps unity generates for shadows. So the amount of shadow casting objects doesn't really effect the speed of the volumetric pass, Only the speed of your lighting pass. Because it is reusing unity's shadows, lowing your shadow quality can help speed up the volumetric pass as it means it's sampling from a lower res shadow map.

    Sample count and resolution tend to have the biggest impact on performance. Also disabling advanced features like Transparency Support and Particle Density support will also speed it up.
     
  35. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    The new realtime GI I'm working on Voxelizes the scene on the GPU for you, so it means it would work for just about any current gen game. The data is stored in a way that could contribute to a volumetric pass (unlike enlighten).
    Everything is 100% dynamic.
    I'm not sure if I will release it to the public or not. Right now its just a prototype I've been working on, But it is looking really promising and doesn't rely on any of unity's backend which is a huge plus (wont need updating with every version unlike this plug-in)

    If you have any other question, message me as I don't want to derail this thread.
    I'll post any progress on my twitter
     
    Dan2013 likes this.
  36. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Single pass VR is working for me, Did unity possible switch over to using multi pass? Would you be able to remove the asset and re download it. I cant replicated your issues at all so maybe something went wrong when merging the update.
     
  37. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    @Lexie thanks bro, that did the trick
     
    Lexie likes this.
  38. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Just so you know the demand's there: This looks super good, I'd love to have realtime GI that works. If you decide to finish it and put it on the asset store, I'll buy it the day you release it.
     
    Dan2013 and Lexie like this.
  39. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    so its similar to SEGI? :)
    would be cool if there were more options on the asset store
     
  40. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    Sounds awesome! I will follow it.
     
  41. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    I will buy it too. :D

    @Lexie
    If you view the GI related posts in this forum, you will release how badly developers want an alternative real-time GI system!
     
  42. TimNedvyga

    TimNedvyga

    Joined:
    May 18, 2015
    Posts:
    95
    @Lexie
    Still have this problem. Any ideas what it can be?

    Unity 5.6.0f3 and HX Volumetric Lighting 1.3.0
     

    Attached Files:

  43. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Wow, That is really strange. I don't touch the directional light's shadow map so I'm not sure whats happening there.

    I do place a large object in the scene to force unity to render shadows though. So the shadow map might be extending the area to fit the object, But i didn't think unity did that.

    If you comment out line 1399 in hxVolumetricCamera it will stop it from rendering that object in the scene.

    It looks like this

    Graphics.DrawMesh(HxVolumetricCamera.BoxMesh, Matrix4x4.TRS(transform.position, Quaternion.identity, new Vector3(Mathf.Max(MaxDirectionalRayDistance, MaxLightDistance), Mathf.Max(MaxDirectionalRayDistance, MaxLightDistance), Mathf.Max(MaxDirectionalRayDistance, MaxLightDistance)) * 2), HxVolumetricCamera.ShadowMaterial, 0);
     
    TimNedvyga likes this.
  44. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Thanks For the interest, I know a lot of people want a real time GI solution for unity. I'm trying to make it run fast enough for people to use in a game, I think its just about there, I just need a few more days work before I can put together a demo. SEGI uses cone traces, they look nicer and are more responsive to change, but suffer from a lot of light bleeding and tends to be very expensive to render out at full resolution. The method I'm using doesn't look as nice and takes a little longer for changes in the scene to be updated in the GI, but it is a lot cheaper to render out and has a lot less light bleeding. It can also support forward rendering and is fast enough for VR so that's a huge plus.

    I'll make a post about it soon, I really don't want to derail this forum post though so please just private message me if you need to respond to this.
     
  45. TimNedvyga

    TimNedvyga

    Joined:
    May 18, 2015
    Posts:
    95
    yes, problem solved. Thank you!
     
    Lexie and hopeful like this.
  46. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    Hi!, I'm using HxVolumetric/Standard/Transparent material on a plane, works perfect but I need to render both sides of the plane. I don't know how to modify that on the shader.
     
  47. paxilon

    paxilon

    Joined:
    Aug 9, 2016
    Posts:
    25

    Attached Files:

  48. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Best way is to honestly make your plane have double sides, If you turn off backface culling on transparent objects they tend to look really bad.
     
  49. Navdeep-Hayer

    Navdeep-Hayer

    Joined:
    Mar 7, 2013
    Posts:
    1
    Do you have an ETA when VR will be fully supported ?
     
  50. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    VR currently works with single pass rendering and your camera set to both eyes (the best setup for VR). It requires a pretty good machine to render though as VR uses really high resolution and the cost of this effect scales with screen size.
     
    Crossway likes this.