Search Unity

Density Volume

Discussion in 'High Definition Render Pipeline' started by yusefkerr, Feb 14, 2020.

  1. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Hello, I've just tried to make my own density volume with a density texture mask as suggested here:

    https://docs.unity3d.com/Packages/c...igh-definition@6.7/manual/Density-Volume.html

    However, rather than providing 32 consecutive 32x32 slices from my 1024x32px strip, the Density Volume Texture Tool just seems to scale and repeat the entire 1024x32px for every slice:

    VDI_1.jpg
    I've tried both 32x1024px and 1024x32px, and I've tried several other things that might have worked. Is this a bug?
     
  2. Tomas-Kiniulis

    Tomas-Kiniulis

    Unity Technologies

    Joined:
    Apr 27, 2017
    Posts:
    55
    Hi!

    Could you further elaborate on what do you mean by scale and repeat? The uploaded image you've provided looks correct to me. I've checked it on my end with a gradient texture running across 1024x32px area and the Density Volume fades out as expected.

     
  3. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    I think you are mis-interpretting the result.
    What's the look of the 3D texture you expected when providing this gradient ?
    The 3D texture tool will slice it into 32 32x32 tiles, and "stack" them. If you visualize that, it explains why you end up with a gradient in 3D.
    This post is a bit old, but the steps to create a 3D density texture are still valid : https://forum.unity.com/threads/usi...-features-in-2018-2-hdrp.541085/#post-3567940
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Density texture vs a simple math SDF, I'd rather take the SDF, maybe from iq's stash. Why are we using density textures when they are better represented by SDF for better perf given the 32x32x32 resolution? you can't fit much in and it never seems to look any good.
     
  5. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Thanks for the responses, yes Tomas-Kiniulis I realised that what I was seeing was correct, I mocked up a sphere volume and that came through as expected. hippocoder, do you have a link to the SDF implementation you mention?
     
  6. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Also, is there a way to assign a density volume to a different light layer in HDRP?
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    There is no implementation for Unity, I am just referring to http://www.iquilezles.org/index.html (Inigo Quilez) :)

    The math is simple yet robust, and can handle most of the shapes one would ever want - certainly more than 32x32x32 but there is no native injection point for this, for volumetric masks/fluids/etc etc... we would still just be generating a texture for now.