HDRP Local Volumetric Clouds draw order vs. other transparent objects and particles.

Setup:

  • HDRP 14 and Unity 2022.2.1
  • LOCAL volumetric clouds, relatively close to the ground.

These clouds are local, and they will correctly obscure our sun and moon physical objects in the sky, which are both opaque objects sitting at a distance beyond the clouds. So far so good!

But, we also draw stars particles at night, on a huge sphere far beyond the clouds. This is done using the VFX system. These stars are incorrectly drawn over the clouds. So it appears that the local clouds are drawn before any other transparent objects, regardless of how any render queue or priority settings are tweaked.

To demonstrate the issue in a simpler way, I placed a transparent plane (alpha 1) high above the clouds, then we look up from the ground, and notice that the plane is drawn after the clouds and thus over the clouds.

Any idea how we can control the draw order of transparent objects or particles, to force them to render before local volumetric clouds?

Hey did you manage to fix this issue? I’m struggling with this as well :confused:

Yes, the solution is the new injection point, which is already in 2023.x, and coming to 2022.3.x soon. See my thread from a few days ago:

Discussion - Can we please get this new injection point in HDRP 14? - Unity Forum

I can’t manage to get this to work. Custom pass with the new injection point, 2023.1.2f1/HDRP 15.0.6.
If someone managed to, can you please post some pointers on how to set up something like the transparent plane example in OP? (Instructions for VFX graph would be even better.)

Just for information, a proper refactor of transparent order has been implemented in 23.2 to be able to fix that without having to rely on custom passes.

Also, in 23.1+, something was done just for the water system (since it’s considered a transparent) so that it wouldn’t render in front of the volumetric clouds.

Alternatively did you try using an opaque shader with alpha clipping ?
I am not sure you really need a transparent object for this use case

I havent really used shader graph much yet. But I did manage to achieve this with the legacy particle system using the “legacy shaders/transparent/cutout/soft edge unlit” shader as the material. I used thomas koles blog post for real world star data which is easy to get working in the new system.

I am sure this would be more efficient with the new shaders and look better, so I hope the fix does come soon.

I thought overlaying the particles onto a starmap looked ok though. Before I got bored and moved on, I wanted to give the stars some more variation by more colors and adding some basic flipbook animations.

9124402--1266253--stars.gif
9124402--1266256--starswithbg.gif

Has anyone worked out how to get transparent materials behind clouds yet? I’m using it for an orbital space station which is animated to move overhead, so can’t be replaced with the other methods suggested. I’ve only managed to get the look I want with it (i.e. the look of something in orbit) by using a transparent material, but seeing it through the clouds ruins the effect somewhat. Images below demonstrating the issue.

If what you want to achieve is for clouds to occlude your space station, you might be able to do it by selecting a refractive model on your transparent object (even with 1 as an IOR to keep the same rendering).

Also, the result might be different below 2023.2.0a18 versions because a transparent refactor landed in this versions to be able to sort clouds / water and before refraction transparent… etc

You can’t draw the transparent object using a custom pass, at the new injection point (AfterOpaqueAndSky) ?

Will this incur an overhead for the refraction model? Will there be another way to enable compatibility with clouds without adding a refraction model?

There is indeed an overhead on the fragment shader of the refractive object, so depending on it’s size on screen this will have a varying impact.
There is no other way to have per pixel sorting though (and not planned). Note that this is only needed if the transparent is behind the clouds

Thanks. Is it expected to have a darkening around the screen edges with IOR of 1? In the image below there is a clear plane in front of everything with a Refraction Model of Planar and IOR of 1 and there is a dark outline at screen edges. Also is the overhead that it still samples the color buffer even with IOR of 1? And is there any way to have the Refraction Model default to None in Shader Graph but still allow users to override it on the material?

9834732--1414731--IOR1.jpg

What you are probably seeing is the “Screen Weight Distance” of the Screen Space Refraction override. The default is 0.1 and it looks like matching roughly the size of yours.
Try to play with it if that change anything about it.

Cf documentation.

Writing here because I’ve been going in circles the past few months scrambling to find a good volumetric cloud option that handles transparent sorting, and when I stumbled across this thread I was excited to try using the refraction option in my transparent material so that it could sort correctly. But when I applied it I noticed it made everything behind it blurry and hard to read even with an IOR of 1:

Since this ruined the original look of my transparent materials, I wrote this off as a possible solution and was stuck for a while investigating alternative cloud solutions (a miserable time honestly lol). But when I returned to this weeks later I did some research and it turns out that increasing the smoothness effects this “blurriness” and transparent materials look like I expect them to:

Granted this was a big blunder on my part for completely missing that setting, but considering I’ve never used refraction before this was a big discovery for me haha. So I hope that helps anyone with the same problem. Thankfully the transparent materials I need sorted like glass and such typically have a large smoothness value so this should work pretty well for my game :slight_smile: I’m excited to use these properly sorted materials finally!