I tried sorting Layers, order in layers, sorting priority, sorting groups… Nothing works, it is always displayed in front of any object that has transparency (with HDRP shaders or custom shaders).
The only thing that has some effect si lowering the render queue in the shader of the visual effect:
The visual effect is no more displayed in front of all the other objects, however, the waterfalls look weird, and the light intensity coming from them changes by itself until all the scene is burned (everything is white).
Morning.
You should be able to properly order your translucent materials without touching the Sorting Priority.
As you are using HDRP, I recommend you look at this page, which explains the Renderer and Material priority in detail.
With the default settings (Mesh Renderer-> Priority = 0 && Material > Sorting priority =0 ) and your VFX and HDRP/lit Sphere both using Translucent shader, the Renderer should use the distance to the Camera .
You have to be aware that it’s from the Bounding Box center to the Camera that is used. This means that you can have sorting issues if your Mesh Bounding Box or VFXGraph bounding box isn’t properly set up.
In this simple example, my particles are using the default settings and an additive blend mode while the Sphere is using the HDRP/Lit Translucent Shader also with default settings. As you can see, the ordering is correct when the bounding box of my VFX is properly set up. As soon as I increase the Bounding box so that the Bounding Box Center is closer to the camera than the Sphere, some ordering issues happen with the Particles being drawn on top.
So, I would first suggest that you check the bound of your Sphere and your VFX Graph.
In this second example, I’m using only two GameObjects: a regular sphere and a custom mesh composed of two spheres apart from each other. As you can see the Bounds of my CustomMesh is encapsulating the two spheres.
As those translucent spheres don’t write to depth, the Bounding Box center is used for the distance to the camera, which can lead to issues in ordering with the red Sphere.
So, first, get back to default settings. Don’t use the Sorting Layer, as it’s used for 2D Rendering, and you won’t find this option in HDRP for regular MeshRenderer. From here, check the bounds of your VFXGraph waterfall and tell me if this resolves your issue.
You can look at this post if you want more information relative to Per-particles and VFX Output sorting.
Hope this helps. Wish you a sunny day
Thank you @OrsonFavrel for your answer. I’ve struggling with this issue for a long time.
I’ve checked the bounding box as you suggested. I’ve create a new sphere, a new HDRP/Lit material with transparency (no sorting priority, or groups) and here is the result:
I’ve rotated the camera so the center of the bounding box, the sphere and the camera are more or less aligned in this order. However is VFX is still displayed in front of the sphere:
For information, I have several moving objects with transparency in the scene and several waterfalls. Whenever one of these object passes in front a waterfall, the waterfall will be displayed in front of the object. In fact, the waterfall is displayed in front of all transparent objects, whatever materials or shader they are using.
I attached the scene, I opened it in a new project (HDRP - 2022-3-27f1) and the result is the same. The green sphere is opaque and displayed in front of the cloud but behind the red sphere with transparency. However, the cloud is displayed behind the green sphere and in front of the red one.
Thanks for sharing.
So in your case, your VFX Graph output is set to the Low ResolutionTransparent Render queue.
Material flagged as low-resolution will be rendered Half-resolution and composited Full-Resolution on top/after the default transparents.
So this is why your Waterfall VFX is drawn on Top of other transparent. Sadly, you cannot choose the order of the Low-Resolution pass. This is something that could be a Project Setting, but it would need to be asked to the HDRP team.
So to resolve your problem, you could either put your waterfall to the Default Transparent Render Queue. This will increase its cost, as it won’t be rendered at a Lower Resolution. To mitigate the cost increase, you can try to use the “Simple Lit” or “Simple Lit translucent”.
Or you could put your Transparent Sphere in the Low-Resolution pass. But you might have the same issue with other VFX/transparent later down the road.
Using the Simple Lit Material type, and the default Transparent render Pass.
I was aware of this setting, but as you said it has a cost and there are a lot of waterfalls …
At least now I know that there is no other way. Thanks again!