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

[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
    The volumetric particles Are more of a rough idea of the density in the air in that general area.

    It renders all the particles to a bunch of slices that are distributed along the cameras view.
    Lowering the particle Density Distance will give more detail with in that area.

    If you still cant get the quality you want for the density particles, You can increase the number of slices it renders out at the cost of some performance. There is an objects called HXUsedShaders that has a setting called Density Particle Quality. Increase that and hit build shaders to apply those settings. This quality setting cant be changed at runtime.

    If you need tighter control over what areas are dusty, Use a density area script. Although you can only have a small number of those.
     
  2. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Unfortunately-vague performance question for Lexie or anybody else who might know:

    What is GFX.WaitForPresent doing when HXVL makes it take a long time? WaitForPresent has always been a bit of a mystery to me, as I understand it it's supposed to represent idle CPU time, has something to do with VSync, and shouldn't ever actually cause slowdown even though it seems to all the time. Certain postprocessing effects (including HXVL), under certain conditions, make it much worse, but that's all I've really been able to observe.
     
  3. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    Say you're getting 120fps on your game and your monitor has a refresh rate of 60 milliseconds, turning on vsync will limit the frame rate to about 60fps by waiting for the nearest frame ie 1 second or 1000ms / 60 so approximately every 16 frames. Now say if you're getting 50fps because you're either using too much CPU or GPU to achieve 60fps, vsync will wait for the next refresh which will effectively result in a drop to 30fps. If you're using a VR device and the refresh rate is 90ms and you're only getting 80fps then you'll see a drop to 45fps with vsync on, the only way to avoid this is to optimise your graphics and code, so you are consistently above the refresh rate

    when I say 'getting x fps', what I mean is that the cost of you graphics and code takes around (1000/fps)ms to complete, but this can fluctuate - hopefully that all makes some sort of sense. Optimization is a massive topic, but that's pretty much what's happening
     
    Last edited: Oct 8, 2017
  4. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Thanks for your answer. I'm pretty sure there's more to this issue. Perhaps I should elaborate.

    I know, more or less, how vsync is supposed to work. When it's switched on, it's clear in the profiler that vsync is filling up unused processor time to get to 30 or 60 FPS. It causes a bunch of issues though, so I keep V Sync Count to "Don't Sync", which I'm pretty sure entirely disables vsync.

    I'm pretty sure GFX.WaitForPresent isn't entirely the same as vsync. Vsync shows up as it's own thing in the profiler, in orange. GFX.WaitForPresent is green in the profiler, it's part of Rendering. As far as I'm aware it always exists, but under normal circumstances it's 0ms or very close to 0ms. When something's breaking it, it can be 20ms or more, and the game is usually CPU-bound as a result.


    When I search for the issue, all I can really find is:
    • People saying GFX.WaitForPresent is just a placeholder for idle time, and can't possibly be responsible for issues
    • People saying GFX.WaitForPresent is sure-as-heck doing something or it wouldn't lag their game so much
    • People saying GFX.WaitForPresent is vsync-related and to try turning vsync off if it's causing problems
    • One person saying it has to do with certain post effects on certain hardware, with no further explanation

    Here's where I am on it:
    • GFX.WaitForPresent is doing something. My game runs slow when it's taking a long time, so it's not just a placeholder.
    • It doesn't stick to 30 or 60 like vsync would. It behaves as I would expect for a framerate-unlimited CPU-bound game.
    • Anyway, vsync is off, so I really don't think it's a vsync issue.
    • I can bring it back to 0ms or close to 0 by disabling the HX Volumetric Camera script.
    • I can make it worse by making HX Volumetric Camera do more work, i.e. increasing quality settings, maximizing the game window
    • Some scenes with HVXL have this problem, other scenes don't. It's reasonably but not entirely consistent within a scene. Probably I'm changing something that affects it without realizing it.
    • It might be something to do with directional shadow maps? This is a hunch.
    • HXVL performs much better when this isn't happening. Scenes that are very fast on full quality when GFX.WaitForPresent is behaving itself are pushing CPU limits on half quality when it it's broken.
     
    Last edited: Oct 8, 2017
  5. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    Hmmm not sure what's happening there, I don't have those sorts of issues, what I do is put the samples down to 4 and the resolution at a half and I get no noticeable drop in performance, plus it still looks great - this scene is about 400 set pass calls - 980TI graphics card GrimsteadArch.png
     
    Shodan0101 likes this.
  6. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    The only thing I can think of, is that you are close to being CPU bound or GPU bound before HX and then turning that on just pushes it over the edge, but I'm not sure maybe @Lexie can shed more light on it
     
  7. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    As far as I understand, when you see GFX.WaitForPresent dominate the CPU profile, it's time to switch to the GPU profiler and frame debugger because the CPU is waiting on the GPU to finish doing something.
     
  8. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    From my experience, high GFX.WaitForPresent times usually mean that your GPU is your performance bottleneck (especially if you've already turned off v-sync.) Even though HXGI is quite performant, it is still not a lightweight effect, especially on higher settings.
     
    punk likes this.
  9. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Thanks guys. That helped solve it.

    That makes perfect sense, and is indeed what's happening. GFX.WaitForPresent means I'm GPU bound, and I'm GPU bound primarily because of HXVL (although some water effects also don't help.)

    This left me with an intermittent performance problem with HXVL, and it took me a little while to figure out what was causing it, but I have. The feature that's killing my performance is volumetric density areas, which apparently cost 2ms each on a 980Ti on full quality. The scene with the issues had like eight of them in the same general area.

    Hey, we have the same graphics card. Anyway, turning it down isn't the end of the world. I can barely tell the difference between full and half. I was more concerned because it seemed to be a sudden performance drop -- I'd been running it on full for months and months without framerate issues, and suddenly I was only getting 25 FPS in some areas and even setting it to half didn't totally alleviate my problems.
     
    hopeful and punk like this.
  10. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    I had problems with water at one point, in the end i decided that real time water was too costly so I faked it with animated meshes which ended up looking better anyway, my game is a VR game so it's gotta run at 90fps+, so to stay with the volumetric effects (which are pretty important to me) I make sure I'm not wasting processing power anywhere else, which means baking as much as possible and keeping the set pass calls below 500
     
    brisingre likes this.
  11. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Your game looks really good. I've been impressed with your screenshots.

    My game's about breeding fish. It has a lot of water in it, and my water effects stack is a constant work in progress. Right now I'm using a very simple custom shader for water in tanks and Jonny10's stylized water shader for oceans and pools. At some point I'm probably going to have to write my own ocean water too, but I've got a bunch of other things in worse shape than that. I'm curious about your animated mesh approach -- could you tell me some more about how water works in your game?

    I am not, fortunately, a VR game, but I need to have thousands of unique procgen fish on the screen all the time, and I can't have the environment cutting into my fish count too much -- expensive effects have to really be worth their weight.
     
  12. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    Thanks bro, I basically use a 3d package to simulate an ocean and the export a seamless animated tile as a sequence of meshes and I just play them back in unity with a nice looking shader, the movement looks super realistic, but there is no computation required and the tiles can use occlusion culling, so it's super fast, it is limited tho, you can't view it from all angles cos it's not infinate, but for me the ocean is a background so it's not a problem
     
    brisingre likes this.
  13. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    You could also try turning down all your effects and see which ones you can live without, drop your shadow distance, turn off shadow cascades, be careful with realtime lights, I fade mine off after 50 meters, makes a massive difference, I also stagger the execution of my code, so it's not all running at once
     
    brisingre likes this.
  14. Vel_1828

    Vel_1828

    Joined:
    Apr 12, 2014
    Posts:
    53
    Hello!
    I have writen the same issue on the contact e-mail, but we are quite in a pinch with the time before release and so I thought you may respond here quicker.

    We have a strange issue with the Volumetric lights not working on machines when the project's files were "not" open in Unity.

    SITUATION:
    We have a game using Volumetric Camera, Image Effect and Volumetric Light scripts.

    A) When on a single PC both Unity Project with the game and the standalone build were opened at least once, everything works fine.

    B) When we run the very same build on a different machine, where Unity Project was not open at least once, there are no shadows nor volumetric lights in the game.

    B.1.) When we open the project files on the new machine, all HX Volumetric scripts are deactivated on gameobjects on the scene. After manual activation, it turns into case A).

    Any ideas how to make it work? :/
     
  15. moodiey

    moodiey

    Joined:
    Jan 4, 2017
    Posts:
    16
    Hello!

    This question may have already been answered but I am developing a VR game and wondering where I should put the HX volumetric camera script with respect to Oculus? Im placing it on the centereyeanchor...but I dont have an Oculus so cant test. Should I place it on lefteyeanchor and righteyeanchor as well?

    I am developing it on a VIVE and its running great on it.

    Great asset by the way, love it. Thanks!
     
  16. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    When I build for the Wii U platform I get the following compile errors:
    Code (CSharp):
    1. Shader error in 'Hidden/HxVolumetricDirectionalLight': GLSL vertex shader: (316): ERROR: '' : 'SHADOWS_NATIVE' already defined
    2. (316): ERROR: '' : syntax error syntax error
    3.  (on wiiu)
    4. Compiling Vertex program with SHADOWS_NATIVE
    5. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP
    6.  
    7. Shader error in 'Hidden/HxVolumetricSpotLight': GLSL vertex shader: (316): ERROR: '' : 'SHADOWS_NATIVE' already defined
    8. (316): ERROR: '' : syntax error syntax error
    9.  (on wiiu)
    10. Compiling Vertex program with DENSITYPARTICLES_ON SHADOWS_NATIVE
    11. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP
     
  17. Johnny_Jr

    Johnny_Jr

    Joined:
    Jan 23, 2015
    Posts:
    9
    I have been using this asset and love the visuals of it but would need to up the performance a bit. All lights (except in one place) of our games are stationary and will never change any parameters during the course of the game. I have created a version of HxVolumetricLight that caches a lot of values to gain performance, but still I feel there should be more that I could do. Has anyone done any such optimisations and have pointers on what to change?
     
  18. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    you can turn the samples down quite low and still get good results, also use half or quarter quality
     
  19. Johnny_Jr

    Johnny_Jr

    Joined:
    Jan 23, 2015
    Posts:
    9
    Yes, I am doing that already. I need to optimize further and reading the source code it is obvious that there are calculations every frame to support lights moving and changing that would only be necessary at start if you now that won't be the case
     
  20. AcornBringer

    AcornBringer

    Joined:
    Mar 22, 2015
    Posts:
    70
    Hi there!

    I'm using forst's Advanced Foliage Shaders v.5 on all my forest assets so I'm a bit worried this asset and that one will conflict after reading "custom transparency shaders will need to be modified" on the store page. Does anyone know if this will be an issue for me? I looked through the documentation briefly and saw there was some code entries provided in case I need to modify but I'm no expert on scripting or either of these assets so I want to be sure before making a purchase.

    Thank you :)
     
  21. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
    Some test with Hx volumetric. I really like this tool!
     
    tryptic, one_one, punk and 3 others like this.
  22. AcornBringer

    AcornBringer

    Joined:
    Mar 22, 2015
    Posts:
    70
    I just went ahead and imported this asset into my game and it works perfectly fine with the cutout transparency AFS uses. I guess I assumed cutout and transparency were the same :p
     
    hopeful likes this.
  23. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    I think before Unity 5.6 the engine wasn't sorting transparent shaders automatically with the render queue. Shaders had to communicate with each other using the extra bit of code as a workaround. This is gleaned from a few discussions about fog and water shader compatibility which also had the same transparency/z-depth sorting issues.
     
    AcornBringer likes this.
  24. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I can also confirm that these work together fine.
     
    wetcircuit likes this.
  25. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    It would be nice if high density fog blurred what's behind.
     
  26. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    +1.

    It would be nice if high density fog could be made to color what's behind it, as well. Fog basically does two things. It scatters light from light sources, some of which hits the camera and makes that pixel brighter. This is where you get the volumetric lighting effect, and it's what HXVL is for. But fog also scatters light from surfaces behind it, making them blurry and grey and generally foggy. Ordinary distance fog is a (bad) approximation of this effect.

    It isn't exactly what HXVL is all about, and I know Lexie's doing other stuff right now, so I want to make it clear this is an idea, not a really a request, definitely not something I need for my game to work. Anyway: here's a proposal with a little bit of detail.

    When you do the raymarching to figure out how much light is bouncing into each pixel, also keep track of how much total density a ray has gone through regardless of light level. With that information, optionally:
    • Fade the scene to a color based on how much fog it's gone through and (perhaps) how bright the scene is (bright surfaces penetrate fog better)
    • Bloom bright surfaces behind fog a little bit
    • Blur the scene based on how much fog it's gone through
    • Reduce the brightness of light being bounced in from farther away based on how much density lies between it and the camera. I think this is basically what Extinction does right now.
    The goal isn't necessarily to physically represent the scattering of light entering the camera from the world in the same way HXVL represents the scattering of light from light sources. That could be cool but I imagine it's a whole can of worms. The goal is just a few simple optional relatively-cheap effects for "foggier fog" using the raymarching that's already happening.
     
    Last edited: Nov 1, 2017
    laurentlavigne likes this.
  27. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    77
    Does it support metal? Has anyone tried if it works, it's not in the requirements.
     
  28. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    304
    I haven't noticed any issues with metal in my project.
     
  29. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    77
    This is promising, thank you for the info
     
  30. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    304
    But I haven't been playing super close attention since I swap back and forth between openGL & metal so YMMV
     
  31. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    Has anyone tried it on VR headset recently? It is working on Unity Editor but it is not working after I build it. Is there any settings I need to pay attention on?

    P.S I am using Unity 2017.2, Forward rendering and have disabled MSAA
     
  32. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    77
    Tried it. But I'm getting these errors on both metal and OpenGL.
    Also got a warning but I guess that's due to maintaining compatibility with older versions of unity.

    Shader error in 'Hidden/HxVolumetricPointLight': 'texCUBElod': no matching 2 parameter intrinsic function; Possible intrinsic functions are: texCUBElod(samplerCUBE, float4|half4|min10float4|min16float4) at line 92 (on metal)

    Compiling Vertex program with DENSITYPARTICLES_ON
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING


    Shader error in 'Hidden/HxVolumetricPointLight': 'texCUBElod': no matching 2 parameter intrinsic function; Possible intrinsic functions are: texCUBElod(samplerCUBE, float4|half4|min10float4|min16float4) at line 92 (on glcore)

    Compiling Vertex program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING

    Shader warning in 'Hidden/HxVolumetricPointLight': Use of UNITY_MATRIX_MV is detected. To transform a vertex into view space, consider using UnityObjectToViewPos for better performance.
    Use of UNITY_MATRIX_MV is detected. To transform a vertex into view space, consider using UnityObjectToViewPos for better performance.
     
  33. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    I got it fixed now. It was somehow been put into lowest quality settings by default. I did change it ultra but still didn't work. I had to remove the settings from the selections.
     
  34. Black_Raptor

    Black_Raptor

    Joined:
    Nov 3, 2014
    Posts:
    181
    When i build my game, the volumetric light on my Directional Light stop working, but she's work right in editor, any idea ? ( Using Steam VR 1.2 and Unity 5.5.3 )
     
    Last edited: Nov 10, 2017
  35. Black_Raptor

    Black_Raptor

    Joined:
    Nov 3, 2014
    Posts:
    181
    Did you fix your problem ? Because i have the same issue
     
  36. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    I am hoping that you guys are working on a Multipass VR version. I want to buy this but so many other VR FX tools DON'T work well on Single Pass VR. So I would have to cut out most of my other tools if I switched to single pass VR mode.
     
  37. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    Would there be any way to get this to work with Valves The Lab renderer?
     
  38. Black_Raptor

    Black_Raptor

    Joined:
    Nov 3, 2014
    Posts:
    181
    I work on multipass but is still don't work

    PS : It's seem the light work only on one eyes for HTC Vive
     
    Last edited: Nov 17, 2017
  39. tryptic

    tryptic

    Joined:
    Nov 13, 2012
    Posts:
    55
    Hi, we've integrated Hx Volumetric lighting into our project and really like it a lot.

    We discovered an issue that appears to be related to our camera setup, we're making an FPS game and have a 2nd camera that renders the gun/hands. The game uses Deferred rendering and HDR.

    So Hx Volumetric is set up on the main Scene camera, but noticed that in the 2nd (gun/hands) camera the effect is drawing twice.

    Any suggestions on how we could address this would be greatly appreciated. I can submit a simple test case if that helps.

    Thanks, -H
     
  40. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    The effect works with single pass rendering only in VR


    This is due to you running the game on low settings which disabled unitys shadows, Go into the quality setting in unity and make sure shadows are enabled for all quality levels.
     
    laurentlavigne likes this.
  41. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Would you be able to create a test scene with your setup? There are many ways to do two camera setups so its hard to test my end. The effect should only be rendering one time per hxVolumetricCamera.
     
    laurentlavigne likes this.
  42. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Effect only works with single pass rendering, The effect would be too expensive with multi pass support.
     
    laurentlavigne likes this.
  43. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I'm working on a fix for unity 2017.3 beta, The point lights have changed the format of the shadow maps and how they are sampled. Should be ready sometime this week for those that are using the beta.

    Edit: its been submitted, Should be live in a few days. Fixes issues with WiiU compiling and compatibility issues with Unity 2017.3 beta
     
    Last edited: Nov 20, 2017
    punk and hopeful like this.
  44. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Is MSAA with this asset still not viable? In that case, for those using this with a VR project, what AA solution do you use instead?
     
  45. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Edit: See post below this for real answer.

    MSAA Should work fine, It just means custom shaders will be needed to look up the GI data during the forward pass.
    I might be able to modify unity's included files to make it automatic in unity's lighting model. But I haven't looked into it much.
     
    Last edited: Jan 17, 2018
    tapawafo likes this.
  46. tryptic

    tryptic

    Joined:
    Nov 13, 2012
    Posts:
    55
    Thank you for your help with this, I've uploaded a simple project example of our camera setup. Please let me know if I can provide anything else.

    Best regards, -H
     

    Attached Files:

    Last edited: Nov 25, 2017
  47. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Hi there,

    Is there a way to get rid of this noise that covers the entire screen ?
    It´s not very noticeable if the game is dark, but once we use it lighter areas, we can see this noise.
    The problem is higher if we increase the Mie Scattering.
    Is there a way to eliminate it ?

    Thanks,
    Bruno Cesteiro
     
  48. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Can you provide a picture? I imagine it's hard to know what you are talking about without seeing an example.
     
  49. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Sorry this is the wrong forum post, thought it was for something else, No MSAA wont work unless you want to make custom shaders to look up the volumetric effect using nearest neighbor search. Unity's directional light suffers from the same issue as well as it uses the depth buffer to test for shadows.
     
    tapawafo likes this.
  50. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    There is a checkbox called "remove color banding" this introduces some noise into the effect to help with banding. turning that off should remove it. It really shouldn't be noticeable at all though, are you doing some strange tonemapping or something thats blowing the noise out?