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
    Lower the shadow bias on the light to an acceptable level. If your roof is just a quad it would be worth extending it to have some thickness. The artifact you are seeing are due to the shadow maps.
     
    hopeful likes this.
  2. Miguel-Herrero

    Miguel-Herrero

    Joined:
    Jan 19, 2015
    Posts:
    19
    All prefabs are cubes, so they have depth. I tried tweaking both shadow bias and shadow normal bias up and down, and the issue still happens.

    It improves using no shadow cascades, though, as there's more space for the shadows in the distance, but it looks horrible up close. I'll try changing the cascade levels individually and try to get a decent enough behaviour, but I haven't found the sweet spot yet.

    I may have to do it some other way on indoors environments (like using independent spotlights for the ceiling holes.
     
  3. Lexie

    Lexie

    Joined:
    Dec 7, 2012
    Posts:
    646
    Chances are your final cascade distance was turned up way too high.
     
  4. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    93
    Any news about upcoming update of HX Volumetric Light for LWRP render?
     
  5. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    169
    Hi @Lexie, any chance you can take a look here? It's still a common problem that causes tons of unnecessary conflicts in work.
     
  6. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    14
    Hello! I'm working on a very simple shader that snaps vertex world positions. Naturally the HxVolumetric camera doesn't recognize the custom vertex positions out of the box as seen with this rotating cube:


    Is it possible / not overly complicated to get the HxVolumetric shader to draw around my new vertex positions? If so could you point me in the right direction on what I'd need to do?

    Here's my current shader (didn't include the properties for readability)
    Code (Cg):
    1.                
    2.                 #pragma surface surf Standard fullforwardshadows vertex:vert
    3.                 #pragma target 3.0
    4.  
    5.                 void vert(inout appdata_full v)
    6.                 {
    7.                     float4 vertexWorldCast = mul(unity_ObjectToWorld, v.vertex);
    8.                     vertexWorldCast.x = floor(vertexWorldCast.x * _XSnap) / _XSnap;
    9.                     vertexWorldCast.y = floor(vertexWorldCast.y * _YSnap) / _YSnap;
    10.                     vertexWorldCast.z = floor(vertexWorldCast.z * _ZSnap) / _ZSnap;
    11.                     v.vertex = mul(unity_WorldToObject, vertexWorldCast);
    12.                 }
    13.        
    14.                 void surf (Input IN, inout SurfaceOutputStandard o)
    15.                 {
    16.                     fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    17.                     o.Albedo = c.rgb;
    18.                 }
    Thanks!
     
  7. AcornBringer

    AcornBringer

    Joined:
    Mar 22, 2015
    Posts:
    65
    Hey there!

    I ran across a post on the Hitbox Team website about colored light cookies with volumetric light. I'm trying to create a scene with some light shining through stained glass and was curious if this is somehow possible with this package since I already have it.

    Thanks :)
     
  8. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    225
    Is anyone getting huge framerate drops with Hx after extended playtime? After approximately 1 hour of play, I am getting hammered by frame drops, despite there being no changes in the scene. If I disable Hx, the framerate returns to normal.
     
  9. Abuthar

    Abuthar

    Joined:
    Jul 12, 2014
    Posts:
    92
    OMFG thank you, you just saved me so much time. I wish you 1000 years of good fortune!!!
     
  10. sabojako

    sabojako

    Joined:
    Jul 7, 2017
    Posts:
    12
    Hello @Lexie ,

    Very impressive system, love the deep controls that are available!!

    I have 2 concerns however that I would need support for my project:
    1- Would you be able to support Orthographic Camera projection, using the orthographic depth texture?
    2- On Nintendo Switch, the effect does not seem to work when using Resolution.full (2019.3)

    Thanks :)
     
  11. sabojako

    sabojako

    Joined:
    Jul 7, 2017
    Posts:
    12
    This is a surface shader, so simply add the addshadow parameter in your surface declaration should do it. It will generate your shadowcaster pass using the vert shader.
    Code (CSharp):
    1.                 #pragma surface surf Standard fullforwardshadows addshadow vertex:vert
    More on this: https://docs.unity3d.com/Manual/SL-SurfaceShaders.html
     
    glenneroo and wyatts like this.
  12. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    78
    Is there a way to make the Hx density not render through geometry without having to use shadows? Or is it possible to do it without having expensive (real-time?) shadows. We have a lot of static point lights as shown in the attached video, but I think it's overkill to have shadows enabled on all of them just to not render through walls and ceilings.
     
  13. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    14
    Sabojako -- wow, that was incredibly simple and straightforward :) Thanks so much for the help!
     
  14. Elliott-Mitchell

    Elliott-Mitchell

    Joined:
    Oct 8, 2015
    Posts:
    56
    Any support for Single Pass Instanced rending in VR? Unity 2019.2.8f1 - Thanks!
     
  15. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    137
    How does HX Density Volume Script work?
     
  16. Miguel-Herrero

    Miguel-Herrero

    Joined:
    Jan 19, 2015
    Posts:
    19
    Is there a way to make a custom surface shader with alpha:fade work with the volumetric lights? I'm adding the lines

    #ifdef VTRANSPARENCY_ON
    albedo = VolumetricTransparencyBase(albedo, IN.projectedPosition);
    #endif

    to the surf function and it seems to not be doing much (I have the define enabled and the projectedPos should be ok, as I'm using it to do soft particles and that works fine).

    Is there a way to use it with a transparent surface shader?

    The example in the docs show a way to do it with regular vert/frag shaders, and the plugin includes a modified Standard shader that works fine, but I need a couple of modifications and I don't want to redo the whole Standard shader.
     
  17. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    28
    Unity 2019.3 has been released. Can we expect an update soon for URP support?
     
    BATTLEKOT likes this.
  18. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    674
    Not officially it is, 2019.2.14 is still the latest official version, but 2019.3 will be right around the corner.
     
  19. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    28
    Weird - I could swear when I opened Unity Hub this morning, 2019.3 was in the top "Official Releases" section, and now it's back down below. I wonder if the 2.2.1 hub update moved it, haha :-D
     
  20. Rotecks

    Rotecks

    Joined:
    Dec 17, 2014
    Posts:
    57
    Hello! I have a big problem.
    Rays pass through the junctions of polygons and light rays appear in these places.I checked the model, there are no any gaps in the corner.
    https://imgbbb.com/image/LXOnzd (Sorry, idk how to attach this image)
    Red arrow shows a ray that should not be here. Green arrows show the direction of a direction light.
    I downloaded the latest version of HX Volumetric Light.
    How to fix this bug?

    UPDATE: Changing "Bias" / "Normal Bias" helps, bus some wrong light rays still exist :/
     
    Last edited: Dec 3, 2019
  21. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    How do I prevent interior scenes from getting Volumetric lighting from the directional scene light? I have an outdoor area and some interior spaces that you can get to, but the volumetric lighting is present everywhere, including indoors where it shouldn't be seen at all.
     
  22. rostik1975

    rostik1975

    Joined:
    May 14, 2015
    Posts:
    30
    Hi.
    What is HxUsedShaderVariantCollection.shadervariants in HxVlumetricLighting / Resources folder and why it created hundreds of empty materials in my project? Can I somehow clean up these materials?
    Thank you.
     
  23. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    28
    Ugh. I feel like this project has been abandoned. :-(
     
    Anticleric likes this.
  24. BATTLEKOT

    BATTLEKOT

    Joined:
    Oct 2, 2016
    Posts:
    93
    maybe we will get some news after Christmas
     
  25. rostik1975

    rostik1975

    Joined:
    May 14, 2015
    Posts:
    30
    Another issue: build stuck on "packaging assets" stage, and I have several "Unity Shader Compiler" processes in task manager.
     
  26. cubrman

    cubrman

    Joined:
    Jun 18, 2016
    Posts:
    194
    The build version of the game seem not to be able to account for shadows:

    While playing in the editor:

    1.JPG

    When running the build:

    2.JPG
     
  27. cubrman

    cubrman

    Joined:
    Jun 18, 2016
    Posts:
    194
    Clarification: the above effect was achieved in the editor by playing with Fog Height and Above Fog Percent.

    EDIT/UPDATE: changed this:


    Code (CSharp):
    1. float GetFogDensity(float3 worldPosition)
    2. {
    3. #ifdef HEIGHTFOG_ON
    4.     float fogDensity = lerp(1 * FogHeights.z, 1, (smoothstep(FogHeights.y, FogHeights.x, worldPosition.y)));
    5.  
    6.     fogDensity = Noise(worldPosition) * fogDensity;
    7.  
    8.     return  GetVolumeDensity(worldPosition,fogDensity * Density.x);
    9. #else
    10.     return GetVolumeDensity(worldPosition, Noise(worldPosition) * Density.x);
    11. #endif
    12. }
    into this:


    Code (CSharp):
    1.  
    2.  
    3. float GetFogDensity(float3 worldPosition)
    4. {
    5. //#ifdef HEIGHTFOG_ON
    6.     float fogDensity = lerp(1 * FogHeights.z, 1, (smoothstep(FogHeights.y, FogHeights.x, worldPosition.y)));
    7.  
    8.     fogDensity = Noise(worldPosition) * fogDensity;
    9.  
    10.     return  GetVolumeDensity(worldPosition,fogDensity * Density.x);
    11. //#else
    12. //    return GetVolumeDensity(worldPosition, Noise(worldPosition) * Density.x);
    13. //#endif
    14. }
    in "HxVolumetricLightCore.cginc" and now fog height is working in the build.
     
    Last edited: Dec 31, 2019
    hopeful likes this.
  28. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    169
    Hi, in case anyone has issues with HX Volumetric Lighting serializing runtime-only matrices to the scene (and thus causing merge conflicts when using a VCS), there is an easy fix, just add [System.NonSerialized] to the following matrices (LastMatrixVPInv,VP2 and VPInv2 are not used in the code, you could delete them but I prefer to make minimum changes to plugins' source).

    Code (csharp):
    1.  
    2. +    [System.NonSerialized]
    3.      public Matrix4x4 BlitMatrix;
    4. +    [System.NonSerialized]
    5.      public Matrix4x4 BlitMatrixMV;
    6. +    [System.NonSerialized]
    7.      public Matrix4x4 BlitMatrixMVP;
    8. +    [System.NonSerialized]
    9.      public Vector3 BlitScale;
    10.  
    11.      [HideInInspector]
    12. +    [System.NonSerialized]
    13.      public Matrix4x4 MatrixVP;
    14. +    [System.NonSerialized]
    15.      public Matrix4x4 LastMatrixVP;
    16.      public Matrix4x4 LastMatrixVPInv;
    17.      public Matrix4x4 LastMatrixVP2;
    18.      public Matrix4x4 LastMatrixVPInv2;
    19.      [HideInInspector]
    20. +    [System.NonSerialized]
    21.      public Matrix4x4 MatrixV;
    22.  
     
unityunity