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
    Just an update on the bug with Density particles not working in 5.6, I have gotten confirmation that they have reproduced the bug. No ETA on when they will fix it though.
     
    hopeful and ratking like this.
  2. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I've made a post about a Realtime Dynamic GI solution I've been working on, It will be able to support volumetric lighting unlike unity's GI system. If you have any questions or just want to follow my progress, here is the forum post
     
    TerraUnity likes this.
  3. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    Hi, is the volumetric work with mixed light mode in 5.6?
     
  4. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Unity's baked lighting is not in a format that can support any type of volumetric lighting unfortunately, only dynamic shadows can block the light scattering.
     
  5. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @Lexie Do you know if this plugin works on HoloLens?
     
  6. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    no idea, sorry.
     
  7. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Just checking: I've seen in a reply to the asset store "Please update to the newest version 1.4." ... was that just a typo or is there a new version available than the one one the asset store (1.3)?
     
  8. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    I'd wager this would melt down the FPS to the single digit range.
     
  9. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Anything about hololens specifically that would cause this? Usually HXVL itself is faster than the dynamic shadows it more-or-less requires -- if it were not to work on Hololens I'd expect it to be because of some sort of visual issue, not because of performance.
     
  10. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Screen-space shaders and post-processing is quite expensive on the HoloLens from my experience. I'm actually not using shadows on the HoloLens either. Single digit FPS may be a bit exaggerated, but it's most likely going to be below the recommended 60 FPS.
     
    brisingre likes this.
  11. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Interesting. I didn't know that about HoloLens. (I've never used one.)
     
  12. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    The HoloLens hardware is very limited, especially with regards to fillrate and transparency. It's on par with iPhone 3 / 4.
     
    brisingre and one_one like this.
  13. Howard-Day

    Howard-Day

    Joined:
    Oct 25, 2013
    Posts:
    137
    So, Out of curiosity, if I wanted to invert the height fog, say if I was making an underwater scene, and wanted strong light rays near the surface... what'd be the best way of doing that - preferably if I could set some sort of surface offset, so my gameplay can still take place on Y = 0? I messed with it a bit, but it didn't seem to understand what I was looking for. I can provide an invoice # over DM, if needed. Thanks!
     
  14. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Without modifying code the best you can do is probably density volumes.

    With modifying code: I'm pretty sure the height fog comes in in the GetFogDensity function at line 200 of HxVolumetricLightCore.cginc. Just inverting it's pretty easy, but to add a way to invert it optionally will be more complicated. That FogHeights vector is set in HxVolumetricLight.cs in a bunch of different places (Line 510, 825, 919, and 1115) once for each light type (Point, spot, directional, projector).

    You might be able to do what you need just by modifying HxVolumetricLight.cs. If not, there's an unused fourth channel of the FogHeights vector that you could probably use to pass in whatever you need without having to add any variables to the shader.

    HxVolumetricLight.cs uses a custom editor, HxVolumetricLightEditor.cs. If you add anything to HxVolumetricLight that needs to appear in the inspector, you'll have to edit that too. If you want to set it up like the existing density settings, where the default setting is controlled from the camera script, you'll have to modify HxVolumetricCamera.cs and it's custom editor as well, just to add the variables you need.
     
    Last edited: Jun 7, 2017
  15. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    Does this work with UFPS? I added it (in 5.5.3) and it doesn't seem to have any effect. I increased the density to full and still nothing. I am also using Unity's Post Processing Stack, if that makes a difference? I tried putting Hx above and below this in the script order, but still, nothing. I have used Hx in a third person game and it worked perfectly. Perhaps it's something to do with the camera that I'm forgetting?
     
  16. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Sorry if this has been answered but I'm using Unity's post effect v1 (v2 seems interesting for your asset btw, there's a lower level integration path or something).

    And: any plans regarding Scriptable Render Pipelines?

    Just wondered if it played happily with V1 (and maybe later V2)
     
  17. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    It's always seemed to me to play nicely with Unity's post-processing stack.
     
    hippocoder likes this.
  18. Howard-Day

    Howard-Day

    Joined:
    Oct 25, 2013
    Posts:
    137
    I've had variable results based on where in the script hierarchy it is, before or after the Post stack..but nothing bad. More like... predictable options?
     
    brisingre likes this.
  19. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    Hi, any fix for this? I using 5.5.3p2 and the latest plugin from store

     

    Attached Files:

    Last edited: Jun 21, 2017
  20. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    On Unity 5.6.1p3 (and this probably happens on any Unity 5.6 version, it did not happen in 5.5), when using HxVolumetricLight, the console is spammed with:

    As far as I can tell, this doesn't really break anything and those errors don't show up in actual builds - but as it happens every frame, I think there's a valid concern that this will have some impact on performance if not fixed.

    There is one issue with the same error message that is said to be fixed in Unity 6 aka 17 aka 2017 (with fixes backported to 5.6) but it looks very much like the fix was for something else that just caused the same error message(s): "In order to call GetTransformInfoExpectUpToDate..." error message appears while toggling Skinned Mesh Renderer component
     
  21. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    509
    There is a compatibility issue between this asset and segi. please look at below pic this will shows the problem.

    When I enable Hx there Is big occlusion lines on models like below pic.

    Those lines only disapear when I disable Hx lighting or SEGI.
     

    Attached Files:

  22. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Hmm, Not sure what would be causing that, Maybe something is happening to the depth buffer. Ill look into it.

    Ill have a look into it. do you have the experimental threaded rendering turned on in unit's player settings? Not sure why that buffer would be in an intermediate state.

    I'm out of the office till next week, Ill get started on a fix as soon as i can.

    Right now there is a bug with particle systems getting rendered in command buffers. Hopefully the newest versions of unity will fix it. They have already reproduced the bug and said it will be fixed. For now disabling density particle support will stop that error from happening.
     
    nxrighthere likes this.
  23. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    The way this effect gets applied to the camera is pretty similar to unity's post stack. (command buffers)
    So not sure if id see any improvements from integrating it into their stuff. The down side to it is you need the base code for the image effect stack in your project for it to work. Any updates they do to the base code might cause issues so it's a lot easier if its just self contained.

    I haven't looked at V2 and how its different from V1 though.

    Scriptable render loop are pretty interesting, I'm still waiting for unity to release some of there own custom render loops that are more advanced to see how easy/hard it would be to integrate into it, so no word on that yet.
     
  24. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Ok i think i know whats happening. Some invisible objects get rendered out to force unity to cast shadows. My guess is that is getting voxelized by SEGI. it should only be rendering them in to the camera so im not sure why it would be picking that up.

    If you comment out line 1399 in hxVolumetricCamera.
    and maybe line 502 and line 1148 in hxVolumetricLight it should remove those invis obects from rendering.
     
  25. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    509
    Cool job, line 1399 solved the issue. Just should I do that every time a new version get release or you going to fix it for next version?

    Thanks a lot for support.
     
  26. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    No, didn't enable the experimental graphic jobs
     

    Attached Files:

  27. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    Having another issue after few try, the volumetric light will pass through the wall. It happen when I look on certain angle only and the light will not pass through if I disable the volumetric effect


    Edit:
    oh ok...It look like the problem fixed if I highlight line 1401 at HxVolumetricCamera script
     

    Attached Files:

    Last edited: Jul 3, 2017
    Rumbleboxer likes this.
  28. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Commenting out that line fixed your issue?
    That line is meant to force unity to render shadows it might cull. In the newest version there is a check box in the advance settings to turn that fix on/off.
     
  29. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    yea, if I comment tat line it fixed the problem.

    I can't disable that at advanced settings...


    Edit:
    ok...I need to turn off the transparent support then only can turn off the shadow fix then enable the transparent support again
     

    Attached Files:

    Last edited: Jul 5, 2017
  30. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Oh thanks for finding that bug.
     
  31. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Is there a stand-alone demo where I can see how a scene looks with and without the effect as well as look at the performance difference?

    [EDIT]
    Nevermind. I bought it. Looks and performs awesome.
     
    Last edited: Jul 7, 2017
  32. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    When I saw this question being asked by hippocoder I thought there was a lack of clarity about timescale & tech details asset store developers would need to be able to integrate with this new system. So I asked on the scriptable render pipelines feedback thread and got a very helpful reply:

    #93

    Summary of the answer: There will be an API with hooks in the right places, they will seek feedback about any missing hooks that devs need, and they are aiming for around October for a still rough around the edges HD pipeline to be in a state where there is an API for developers to get their teeth into.
     
    chiapet1021 likes this.
  33. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    232
    At a strength of 1 the light is entirely absent in the shadowed areas, so it sounds like you need to turn down other light sources or turn down the bounce.
     
    Syberam likes this.
  34. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Unity adds a ton of ambient light to scenes by default, and your life'll be easier if you get rid of pretty much all of it. You do that from Window->Lighting->Scene and you have to do this for every single scene in your project.

    The number one offender is the built-in GI system, which is both slow and ugly in addition to adding a bunch of indirect light you can't really control to your scene. To turn this off, turn off Realtime Global Illumination under Realtime Lighting. If you absolutely must use it, I believe the Indirect Multiplier value of each light will affect how much light it contributes to this system, but you'll be much happier just turning it off. It lags the editor periodically re-baking it's "realtime" GI and it leaks light through thinner walls in big blocky voxels.

    You should also turn off Baked Global Illumination, under Mixed Lighting, unless you're actually planning on using baked lightmaps (which are not compatible with HxVL.) I don't think Baked GI contributes any light unless you have lights set to Mixed or Baked, but better safe than sorry.

    With GI gone, there are still two sources of ambient light.

    Environment Lighting is the ambient light you can actually control. By default it is set to Skybox, which means everything gets its ambient color from your skybox material. This can look good, especially for outdoor scenes, but it affords you almost no control, and it tends to put a ton of ambient light in arbitrary colors on the bottom of ceilings and things. Downward facing surfaces get ambient light from the bottom half of the skybox, which depending on the skybox texture could be black, blue, brown, white, grey, orange, or really anything -- people don't usually pay much attention to that part of the texture. If you set this to Gradient or Color, you get a lot more control over your ambient lighting color. If you set it to Color and make it black, you can turn it off entirely. If you do, your shadows should be pretty much pure black.

    I do not know of any way to set a custom cubemap for ambient lighting, or to affect it per-object, without writing shaders. If you would like to use a cubemap that isn't your skybox for Unity's built-in ambient lighting, I recommend setting it as your skybox and then putting your skybox on a dome or something. :/

    The last source of light is reflections. Not every shader treats reflections like light, but highly reflective PBR materials do. Technically speaking, it's the right thing to do -- reflections are light, and as long as your reflection probes are set up correctly, theoretically it should be fine. I wouldn't know, I've never once gotten a reflection probe set up correctly. If anybody has a functional workflow for setting them up, I would love to know all about it.

    If you're like me and you haven't got your reflection probes set up, everything will use the default reflection cubemap. This is set from Environment Reflections, and it defaults to the skybox. For outdoor scenes this is more or less fine, for indoor scenes it's super weird. You can set it to anything, or blank to turn reflections off. Nothing you can use is really a substitute for getting the reflection probes right, but you can at least stop things in dark rooms reflecting a sunny sky.

    Most games end up using some sort of tone-mapping in addition to this to get their shadows looking right. I feel like tone-mapping usually looks not-so-good, but it's certainly possible to make it look good. It's a tool you have at your disposal, at any rate.

    Most of this will only have a limited interaction with HxVL.

    HxVL lets you control how much the ambient light from Unity affects HxVL's colors, or you can override it with a new color or gradient. HxVL does not do dark fog. Light bounces off tiny abstracted particles towards the camera. The particles themselves are generally assumed to be white -- tint settings can be used to approximate fog of some other colors, but only the hue matters, you can't make the fog darker this way. They don't contribute at all when they aren't lit, either -- no matter how dense HxVL's atmosphere is, it doesn't block light coming from the world to the camera. It can only reflect additional light into the camera. As such, it pretty much only ever makes pixels brighter. It looks very good on dark backgrounds, and no combination of settings will make it particularly noticeable on a bright background, except perhaps by using tonemapping to increase contrast between very bright values, essentially making the background darker. (Extinction Effect is an exception to the rule about only making pixels brighter. It can certainly make pixels darker, but it doesn't really address the problems of darker/thicker fog.)
     
  35. dinosec

    dinosec

    Joined:
    May 24, 2017
    Posts:
    8
    Unity 5.6.2p1 VR single pass doesn't work, version of HxVolumetricLighting is 1.3.0b (Jun 27, 2017)
     
  36. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Working on a fix for that this week. Will keep you posted.
     
  37. dinosec

    dinosec

    Joined:
    May 24, 2017
    Posts:
    8
    also doesn't work on Unity 5.6.2p2 , thank you for your great product, thank you!
     
  38. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    In the latest version there is a check box called shadow fix. If that is enabled then it should stop that from happening.
    can you confirm that you have single pass rendering enabled in the player settings? I tested on my rig using OpenVR and its all working.
     
  39. dinosec

    dinosec

    Joined:
    May 24, 2017
    Posts:
    8
    I do apologize. It works on Unity 5.6.2p2 OpenVR single pass very well, thank you, sir!
     
    Last edited: Jul 11, 2017
  40. scottswarbrick

    scottswarbrick

    Joined:
    Jul 12, 2017
    Posts:
    3
    Hi,
    We purchased your asset pack last week and have been putting some volumetric spotlights into a level.

    We're encountering an issue were the volumetric script doesn't seem to load when we play the level, however if we load a separate level, then reload the level with the spotlights, they work just fine.

    Do you know why this would happen?
     
  41. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    If you play the game in the editor, the system will compile all the shaders you used in that scene. My system creates an object called HxUsedShaders to track used shaders over the course of development. If you're working in a team and using a merge program, a lot of the times people keep overriding that file so it never gets built correctly.

    If you select that file and then check all the boxes and hit build shaders, then push those changes to the rest of your team. That way you're not overriding it all the time.

     
  42. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    If you modify line 1401 in HxVolumetricCamera to this.

    if(ShadowFix) 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, Mycamera);

    It should work with SEGI, let me know how it goes.
    (sorry this was the real fix all along, messed up on my last recommendations)
     
    Last edited: Jul 12, 2017
    Syberam likes this.
  43. scottswarbrick

    scottswarbrick

    Joined:
    Jul 12, 2017
    Posts:
    3
    Okay I tried that, but I still get the same issue. The volumetric lights only work if I load another level before the one that has the volumetric lights in.
     
  44. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    509
    I have a dark room with a windows but I can't get enough volumetric light through this windows without destroying outside lighting and make it totally white. I've tested all setup I could but this looks impossible.
     
    Last edited: Jul 15, 2017
  45. scottswarbrick

    scottswarbrick

    Joined:
    Jul 12, 2017
    Posts:
    3
    I seem to have found the issue with the volumetric lights only working after loading a separate level.

    We had a Screen Space Ambient Occlusion script on the camera, when we remove that it resolves the problem with the volumetric light.
     
  46. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    Anyone experience the crash in 5.6 if turn on the editor scene lighting and occlusion visualization tab after baked the occlusion data?

    The Unity team told me the crash is cause by the command buffer

    Here the video how to reproduce it
     
    Last edited: Jul 14, 2017
  47. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Hi

    Quick question, you have answered that multiple times for RIGHT NOW, but never on a fundamental level AFAIK.

    Is there a possibility that Hx Volumetric lighting is working with baked lighting in the future?
    a) is it not possible to raymarch the baked lightmaps on a fundamental level, or is it just very hard and not implemented yet?
    b) Did you have a look at Unreal Engine and how they implemented their volumetric fog? Guess its different tech, but their solution seems to be compatible with baked lighting.
    c) Is there a chance you combine the raymarched solutions for dynamic lights with a different solution for static lights? Is it possible to somehow combine these solutions to work for mixed lights?


    The raymarched volumetric light seems to be the best volumetric light solution for unity atm, but with unitys shadow system for dynamic lights being extremly inefficient still, that is a nogo for indoor scenes with a lot of small lights. And with the volumetric light being so depended on shadows to correctly work, its not even an option to optimize scenes by switching off shadowing for far away lights.


    One suggestion to maybe optimize a little bit: would it be possible to implement a system for a future release that would "cache" the generated volumetric light geometry and allow to switch off the raymarching selectively after the initial creation of the light geometry?
    That would allow switching off shadows for the light, maybe even switch off the light for optimization, without the volumetric light geometry changing, thus actually HIDING the fact that the light quality changes for far away lights, instead of making it more obvious.
    Maybe some use cases could opt for keeping the volumetric light static even if active objects enter the volumetric light geometry for optimization. Maybe your script could react to a trigger that activates raymarching again.

    Do you think tomething like this could work for a future release?
     
  48. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    A) Baked lighting is not in a format that can be raymarched. The closest thing would be using light probes to guess the lighting, but I'm not sure that's possible in unity.

    B) No, but they probably use a froxel system and compute buffers to speed everything up. Now that unity has announced dropping support for dx9 I'm actually considering a new version that uses froxels and compute shaders to speed up the effect. transparency support would be faster and controlling the density of areas would be a lot easier.

    C) yes, something like baked 3D volumes would work. but not sure how good that would be, also they would take up a lot of space.

    The way I would go about adding some form of baked support would be to hook into unity's baking pipeline and render out a shadow map from the lights perspective, then use that saved shadow map in the the raymarch step.

    In the end its hard to work with unity's lighting system. its very closed off and requires a lot of hacks to get anything interfacing with them.
     
    gian-reto-alig, punk and hopeful like this.
  49. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Ill see if i can turn off the system when the visualizer is open.
     
  50. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Houses are very dusty. using density areas or density particles can help control how dusty the inside of the house is. also houses are a lot darker so any incoming light tends to look very bright. Eye adaption can help a little bit.
     
    Last edited: Jul 15, 2017
    Crossway likes this.