Search Unity

[RELEASED] Hx Volumetric Lighting

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

  1. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    I'm also going to need to convert some water shaders to play nice with HX at some point.
     
  2. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I can open a callback for it, but in the end people would need to have a medium level of shader programming at least to be able to convert an assets shaders to just render depth.
     
  3. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    I have an idea, how about you make the effect happen only within a box collider that can be placed and scaled by the user, this box will be where your plugin works and not outside of it. You can have any number of these scattered throughout the scene and if the user doesn't want to have the effect happen underwater then just place the box collider slightly above the water so it's only affecting that point and above, would that be easier?

    By the way is the plugin purchasable in its current state, for example there's no major bugs or memory leaks right now are there?
     
  4. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    There shouldn't be any major bugs or memory leaks, those are all fixed in the current build on the asset store.
    There is an option for creating a density bounds already in the system, but the issue for ocean support is more complicated then that as ocean generally has waves.
     
  5. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    That's good news because my plugin has very small waves and not the large kind so that's not an issue for me.
    I hope to purchase it within the coming next few days as long as it supports forward + gamma and performance won't be an issue.
     
  6. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Spent an evening trying to get underwater lighting effects looking good. For local lights it's gone pretty well, I think. For sun light it's a little tougher -- support for cookies on directional lights would be great, that would let me do my fake caustics the same way there.

    (I use two lights, one dim green one with no caustics and one bright yellow one with them.)
     

    Attached Files:

    Last edited: Mar 12, 2017
  7. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    I think I have medium level of shader programming. I don't actually know how to do that, but I could probably figure it out when the time comes.
     
  8. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    I've also found a very very small thing that might be useful. I'm using NGSS for my shadows. It doesn't ordinarily affect the operation of HX, they work very well together.

    NGSS uses the shadow strength of the light to control the hardness of the shadows, rather than making them less dark. Sort of an odd setup, but anyway, the upshot of this is that sometimes I actually turn it down, and then I have to set shadow strength back up in the Volumetric Light script. Not hard to do, but it would be convenient if I could set it globally in the camera script like I can most other things.

    Sorry for the triple post.
     
    Last edited: Mar 13, 2017
    hopeful likes this.
  9. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Thank you for looking into it. I have filed this issue with Unity as Case 889591 and they were able to reproduce it, so I believe that should be fixed on Unity's end.
     
    hopeful likes this.
  10. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    I purchased this asset and your demo scene is running at 40fps with an average of 20 ms, this is not the 0.5 ms you claimed it to have, did I do something wrong, what settings are there to optimize this for actual game use?

    Also is it only supposed to come with 1 example scene - the Density Particles?
     
    Last edited: Mar 13, 2017
  11. drmanhattan

    drmanhattan

    Joined:
    Jul 5, 2015
    Posts:
    41
    Just wondering, is there any reason why the effects in this library wouldn't work when rendering to texture?

    Thanks
     
  12. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    It performs faster than 0.5ms for me, but I'm on very fast PC hardware. What are you running it on?

    There's only one demo scene, that's correct. There isn't much that isn't in it though -- the setup is just the script on the camera and the scripts on the lights.
     
    Last edited: Mar 14, 2017
  13. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    The rest of my pc is pretty fast, ssd, i7 processor etc, but I have a radeon 5700 series card which is from 2013. This is intentional because if it can run on this card it should run on the vast majority of hardware. Also that card can run crysis and battlefield 3 with no problem so getting 40 fps on a enclosed demo scene with a few lights definitely isn't right.

    Waiting on the dev to offer me some optimization tips.
     
  14. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Ok so while the Unity performance bug is NOT active Hx performs at about 80 fps in the sample scene untouched and that's not bad since there's a lot going on.

    It performs at around 200 fps with a bit of optimization of the light and camera settings.
    It performs at around 1000 fps by setting shadow quality to medium in the quality settings.

    That's pretty rad!

    However I am having some issues getting the results I would like. I am not really happy with the documentation and lack of video tutorial support. There's just too many settings and it's all going over my head.

    I would appreciate it if you could post some video tutorials on setting these up the correct* way and showing us how to achieve some of these really nice image results you keep posting as if we were complete noobs :).

    Update:
    Thank's for liking this comment so fast, glad to know others would benefit from the tutorials too. P.S. Getting so much fps out of setting shadow quality to medium was pretty crazy.
    This tool is supposed to allow you to have very low res shadows while still keeping them very natural looking:
    https://www.assetstore.unity3d.com/en/#!/content/79454
     
    Last edited: Mar 17, 2017
    John-G and hopeful like this.
  15. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Spiny4.PNG More tricks with multiple lights.
     
  16. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    What performance bug are you talking about?
     
  17. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    hopeful and chelnok like this.
  18. BigB

    BigB

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

    I´m having a weird behaviour when using spotlights, they are simply culled away at certain distances, or just culled away in certain spots, while everything works fine with point lights and directional lights.
    This happens when the light Spot Angle is higher than 80.
    Is this a known bug, or am I making something wrong ?

    Thanks !
    Bruno
     
    Last edited: Mar 20, 2017
  19. multimediamark

    multimediamark

    Joined:
    Mar 17, 2017
    Posts:
    30
    Hey there, I bought your asset for the Oculus Rift project I'm making and when using HX Volumetric light in a simple small room scene the framerate is locked on 45 frames even when the resolution is set to quarter. Without the asset its on constant 90+ frames.

    Any idea how I could improve the performance?

    My rig is i5 4590, 16gb RAM, GTX 1060 6GB.
     
  20. David_Knopp

    David_Knopp

    Joined:
    Jul 10, 2013
    Posts:
    10
    Hello,

    I'm using Unity 5.5.1p3 and hx 1.2.0b and I'm having some trouble getting the package to run on PS4. There are quite a few float conversion errors in one of the shaders which was easy enough to fix, but I'm also seeing "RenderingCommandBuffer: Invalid pass index 8 in DrawMesh" at runtime using the provided demo scene. Is this a known issue? and/or is this something we can fix on our end?

    Thanks!
     
  21. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Has anyone been able to use HxDummyLight ? It seems nothing happens, nothing is rendered.
     
  22. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Just tested it out to see: it is not working for me either. I think it worked on a previous patch, but it wasn't the best way to set up a dummy light even then. To make a volumetrics-only light that doesn't add light to the scene, instead of using an HxDummyLight, you can use a regular light with the color set to black and then overridden in the HxVolumetricLight script.

    The upside of this setup, other than that it works and HxDummyLight is broken, is that you can set it to cast shadows, which isn't an option in HxDummyLight, I assume because adding a light to HX's list of lights without adding it to Unity's list of lights is pretty simple, but generating a new shadowmap for that light instead of re-using one from Unity is complicated.

    The only downside is that, for a non-shadowcasting light, it incurs a little bit of overhead from Unity that HxDummyLight would not. If you use deferred it's basically free, but if you use forward it draws some stuff an extra time, and you need to do a little more to stop it. Forward draws each object once per light it's in range of (up to a maximum number, your pixel light count.) These black lights, even though they don't illuminate anything, don't get culled before that step automatically in Forward. You can force Unity not to render them by putting any geometry they might illuminate on a layer that's excluded from the light's culling mask. However, if you exclude the layer that has the HxVolumetricCamera, the light will stop rendering volumetrics, so if you go this route you have to move either all your level geometry or your camera out of the "default" layer, otherwise you'll be unable to exclude one without the other.
     
  23. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672

    Well, the all idea of using HxDummyLight for me, would be that I wanted a volumetric light without shadow casting.
    Disabling shadows on the light, also disables the volumetric effect, and right now there´s no way to do this.
    Having the ability to have volumetric lights without shadow casting would help with performance, sometimes we dont even need the shadows.
    Any ideas on how to do this ? I don´t think it´s possible at the moment.
     
  24. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    The intended use for dummy lights is to have volumetric lights that don't cast light on the environment, for use with baked lighting. If you just want volumetrics on a non-shadowcasting realtime light, you do that just by turning off shadows on the light.

    It sounds like that isn't working. If you need to enable shadows (they're off by default) on a light to get volumetrics, that's a bug. (Not one I've ever seen myself, not that that means anything.)

    Cookies are a good alternative to shadows in terms of getting good light shafts that match your environment, but if you're not getting volumetrics at all that won't help you.
     
    Last edited: Mar 23, 2017
  25. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Well, it´s a bug then, at the moment when you shut down shadowing, the volumetric light effect vanishes.
    Btw, do you know if the developer of the asset stopped working on it ?
     
  26. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    It's only been 11 days since they posted in this thread.
     
  27. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Definitely still being worked on.

    If you post your scene I'll take a quick look at it. No guarantee it'll help anything, but it might be good to know if your scene still exhibits this problem on a computer where non-shadowcasting lights are definitely working
     
  28. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Could this be related to the idea that you need a shadow casting object, even if it is a tiny sphere behind the camera and unseen, in order to get the effect to work?

    (I don't own this yet, but I remember that being a quirk of the system.)
     
  29. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277

    I think this was fixed in the newest patch.
     
  30. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Nahh, doesn´t work, nothing renders.
     
  31. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    My scene is quite big, it´s not easily shared, but if you turn off shadows on your system, you still get volumetric lights ?
     
  32. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    Thisis probably obvious already but, is this compatible with Unity version 5.6.6b? I'm testing out the Timeline feature and would like to use volumetric lighting, but don't want to get it if it won't work with 5.6. Thanks.
     
  33. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Yeah, I do. Here's screenshots of the three light types. The blue one has shadows, the red one doesn't.
     

    Attached Files:

  34. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I'll look into making some video tutorials.


    There where some bugs with the light cullings, I thought the newest version has them fixed, Ill double check though.
    Edit: this is fixed in the new build i'm pushing shortly.

    Enabling single pass stereo rendering in unity's player settings helps a lot.Lowering sample count helps a lot.
    How many lights do you have in this small room?

    The way VR works is if its slightly under 90fps it drops it down to 45fps. So its hard to gauge the cost of the effect using the fps. best to check the profiler.
    Next build coming out shortly fixes ps4 issues.

    Ill have a look at these issues.

    Unity 5.6 Beta is not supported yet, there are currently a few issues. When it comes out of beta ill fix them up. Unity tends to change a lot of backend rendering stuff in betas so its hard to support them.
     
    Last edited: Mar 30, 2017
  35. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I'm finishing up a new build that has some bug fixes along with a few additions.
    Should have it ready to submit by tomorrow as long as any new issues in the above post are easy fixes.

    Change light falloff texture of each light. By default it uses unity's light falloff but you can now override it with a custom texture instead. (This only effect the volumetric part of the light)

    Volumetric Projectors
    Supports both normal and orthographic projectors. It uses the falloff and colored cookie from the projectors material to enable volumetric rendering.

    Density areas
    now supports Cube, Sphere and cylinder.
     
    Last edited: Mar 30, 2017
    brisingre likes this.
  36. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    Bought it!
    Questions/oddities:
    1. could we get a preview of the effect in the scene view? When image effects is on it could work.
    2. sometimes, when stopping after play unity hangs (5.6 f2)
    3. it eats up 3.5 ms at full res, 2.8 at quarter res, normal? (very simple scene looking in the sun with height fog, particle fog normal gpu ms is around 0.03... gpu profiler could be very broken)
    4. Acts out in unity 5.6 mostly hanging, effects not showing up until the scene is reloaded
    5. when moving the camera during editing, the image has a trail, what is that?
    6. when I mess around with resolution half -> quarter the volumetric effect stops responding and artifacts occur (this is alleviated by switching to gaussian but the effect is very different than half res... well now gaussian makes it look blotchy... weird)
    7. noise sucks up 80% of the brightness even at very low contrast, why?
    8. ghosting happens during editing, probably the effect of temporal
    9. strange square like artifacts around high brightness volumetric particles
    10. in-editor during play there are GC spikes, and I notice a rhythmic stutter - related?
    quarter res
    Capture.PNG
    full res
    .... mmmm scene still loading after crash ... here we go
    Capture.PNG
     
    Last edited: Mar 30, 2017
  37. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    1. Ill look into adding a check box to enable it for the scene view.

    2. If there are new versions of the volumetric shader used in play mode it compiles them when you switch back to editing mode. If no new shaders were used then it shouldn't hang though.

    3. Lowering the sample count generally has the biggest impact on speed. The complexity of the scene doesn't have anything to do with the cost, its the amount of pixels each volumetric lights overlaps in the camera view. The effect is ray marching through your scene and sampling the shadow maps as it goes. This is a lot more computationally heavy then unity's default fog.

    Turning off advanced features like density particles and transparency support also help a lot.

    4. It doesn't support 5.6 yet, Its hard to support betas as they tend to change a lot of back end rendering stuff.
    I'll be looking into adding 5.6 support next week.

    5. This is due to temporal sampling. the effect uses data from the last frame to improve the quality of the effect.

    6. I'm guessing this is something 5.6 related. ill look into it soon.

    7. The 3D noise textures have less over all density then a homogeneous density (no noise).

    8. yes this is due to temporal sampling. if the system detects a change in editor mode it normally forces the game view to render out a few more frames to allow the temporal sampling to settle. It might not be working in 5.6 though. The max feed back from the temporal is set a little high by default in the current version. Id suggest lowering it to 0.5

    9. There are two types of artifacts that come from low res rendering and then upscaling into the scene.
    If you set Upsample blur pass to 1 it might get rid of them, but has a little added cost. Normally at half resolution these artifacts arn't noticeable.

    The second artifact can be improved by increasing the blur count, sample count, or rending in a higher resolution.
    This artifact is generally only visible when you have extremely high density though.

    10. There shouldnt be and GC made by the system. I'll have a look in unity 5.6 beta.
     
  38. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672

    Cool :)
    Did you had a chance to take a look at the HxDummyLight issue ?
    Thanks !!
     
  39. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Working on that stuff now.
     
  40. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    Thanks Lexie!
    Yes turning off volumetric particle ups the framerate a lot but lowering sample does nothing. I found settings that removed artifacts, essentially switching off temporal by default looks better.
    I'm trying to go all volumetric and I'm running into maybe limitations of the system or bad settings:
    1. The effect of volumetrics doesn't show up in reflection probes so I get very different diffuse lighting (LOD4) and reflection to direct image.
    2. Image behind volumetric particles don't appear blurry like it should by gas scattering. In fact I cannot understand the effect of the additive/max/min/sub modes, is it volume density add/max etc... ? It looks weird and I can't get gas to occlude background objects, they always show in some way. Are volumetric particles self shadowing? If I get this to work I'm super tempted in having all weapons and effects be volumetric! It would be very very awesome looking.
    3. Is it possible to make particles volumetric light emissive? I'm thinking plasma illuminating the surroundings
    4. Also the background objects don't show blurry behind thick volume.
    5. I just baked the GI lighting and volumetric disappeared from the scene and won't re appear after unity load, maybe a 5.6 thing. clear baking gives me back the volumetrics
    6. Is it possible to make volume of dark smoke? I can only get brightness added.
    7. have you tested it alongside the new unity post stack? I'm getting unexpected results with AO darkening everything, some settings will glow blue depending on place on the behaviour stack.


     
    Last edited: Mar 31, 2017
  41. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    Thanks :)
     
  42. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    That´s weird.
    Can you check if you enable fog height, and Noise if it still works ?
     
  43. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277

    Yeah, works fine for me. I tried setting the noise/height on the light and setting it on the camera and they both worked.

    What version are you on? I'm on 5.5.0f3 Personal.
     
  44. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    I´m on 5.5.0p3. Hopefully it´s something simple to fix.
     
  45. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    I meant
    das menu.PNG
     
  46. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Id rather it not be enabled in play mode as it would add unnecessary work. Id rather have some more advanced options then just that check box.
     
  47. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    I've looked over your issues and I'm not seeing a lot of them. Are you on Mac or linux?
    Also double check you have the latest version of the plugin on the asset store.
     
  48. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646

    1. I'm not sure its possible to apply the volumetric effect to reflection probes when they bake out. At least I haven't seen any callback i can latch onto.

    2. I haven't implemented the blurring effect when looking through fog yet. It wouldn't be too hard to add though and its on my list of features to add. If you want the fog to darken distant objects then increase extinction effect to one. This simulates the light out scattering through the fog but can make it a little more complicated to get transparency compositing correctly.

    3. Not possible with the current way the system is set up. you can kinda fake it by overriding the shadow strength on the hxVolumetricLight script and setting it to something lower then 1.

    4. see answer 2.

    5. The system can only work with realtime lights unfortunately. The data for baked lighting is not in a format that can be ray marched. It might be possible to sample light probes to gather some concept of the baked lighting, but it wouldn't be very accurate at all. Its something on my list of features to look into but I'm not sure how feasible it is.

    6. There are limitations to this method of volumetric lighting, its not really possible to mix and match particle colors. There are other methods that can support that but have other trade offs.

    7. The effect should render over the top of the AO, There is a script called HxVolumetricImageEffect that should get placed on your camera automatically, Make sure that is placed after unity's imageeffect stack.
     
  49. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    You are right.
    I had the latest version, but it seems that somehow was not working correctly.
    I had to delete the entire folder and download again, I got it all working.
    Thanks !
     
    brisingre, hopeful and Lexie like this.
  50. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    Very cool, can't wait, this way I can remove the dof and get some pretty wild effects.

    I read your other thread where you rewrote unity's light system. Have a look at 5.6, I saw a renderloop property and maybe you can retrofit your lighting system with that. How do I override that? I didn't see it in the script.

    I understand you can't use probes but can you at least allow static lightmaps so we can get the nice GI look?

    ok, so what is the use of the modes? switching them I cannot see a logic or a purpose for them. Does the volumetric cast self shadow? I'm thinnking of having missiles case plumes of volumetric smoke.

    AO works when post stack is up but dof, AA and motion blur don't work