How to render VFX Graph behind everything else in the scene?

I’m attempting to create a particle system for a sphere of stars, similar to the one found in this tutorial here:

The main difference is that I’m using VFX Graph instead of a simple particle system. I’m outputting quads with a custom transparent unlit shader graph.

In the tutorial, to get the stars to render behind everything else, he gets the ParticleSystemRenderer and sets the renderQueue of the sharedMaterial to RenderQueue.Background (at around 4:35). What’s the analog for VFX Graph? Simply put, how do I make a VFX graph render before (and thus behind) everything else?

1 Like

I’m looking to do the same! Anyone have an answer?

Morning.

So I didn’t take the time to fully dig into this , but from what I quickly get I’m not sure that you can render “Transparent” before opaque with SRP projects.

I will ask my colleague who knows better about SRP on this subject.

But you can “Trick” the depth of your Transparents particles in “Shader Graph”.
I’m not sure that it’s the ideal approach and I will try to come up with the most “performant”
way later on.

So:

  • Create a VFXGraph , make sure its transforms are reset (0,0,0) and attach it to the Camera.

  • In VFXGraph, set a Position with an ‘ArcSphere Block” to set the position on the surface of a Sphere.

  • Change the Spawn to “Single Burst” and choose your number of Stars.

  • Make sure that your “Capacity” is coherent with your Spawn Number.

  • Get rid of the Lifetime so that the Particles never die.

  • Add a “Set Size” and Randomize your “Stars” size

8535455--1139777--upload_2022-10-24_11-43-43.png

You should now see Particles on a Sphere:
8535455--1139780--upload_2022-10-24_11-44-16.png

  • Create a Shader Graph and turn on “support VFX graph” in the Graph Settings

  • Still in the “Graph Settings”-> “Surface Options” turn on the “Depth Offset”.

  • Now Set up your Shader Graph and “Expose” the needed property.

  • 8535455--1139783--upload_2022-10-24_11-46-23.png

  • Apply you “Shader Graph” to your VFXGraph system.
    8535455--1139786--upload_2022-10-24_11-48-24.png

You should now have Particles on a Sphere with a custom “Shader Graph” apply on them:
8535455--1139789--upload_2022-10-24_11-49-8.jpg

To finish you can Now play with the “Depth Offset” float to fake the “Depth” of your Particles.
By doing so you should have the effect you’re looking for.

3 Likes

Here what it looks like to play with the “Depth Offset”:
8535461--1139798--Unity_qxBwquycZw.gif

Hope this solution help.
Have a great day

3 Likes

Thank you so much for the in-depth answer @OrsonFavrel ! I’ll give this a try later tonight!

Hello. I am using the latest avaliable LTS version of Unity (2021.3.13), and the Output Particle Quad node of VFXGraph has no “Shader Graph” field. Where I cna read some documentation about this version of Unity? When I check the docs on Google they all show things that are not available (the seems to be for Unity 2022.)

Hello @CPULL ,

To be able to see this field, make sure the “Experimental Operators/Blocks” is enabled in the Visual Effect Preferences.

1 Like

Hello, I can’t find the Depth Offset setting. I’m using Unity 2020.3.37f1, URP 10.9.0

5 Likes