Search Unity

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

Discussion in 'Visual Effect Graph' started by Mortichar, May 26, 2022.

  1. Mortichar

    Mortichar

    Joined:
    Mar 30, 2017
    Posts:
    19
    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?
     
    PraetorBlue likes this.
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    I'm looking to do the same! Anyone have an answer?
     
  3. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    192
    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

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

      You should now see Particles on a Sphere:
      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.
    • upload_2022-10-24_11-46-23.png
    • Apply you "Shader Graph" to your VFXGraph system.
      upload_2022-10-24_11-48-24.png

      You should now have Particles on a Sphere with a custom "Shader Graph" apply on them:
      upload_2022-10-24_11-49-8.png
    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.
     
    ssojyeti2, Mortichar and PraetorBlue like this.
  4. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    192
    Here what it looks like to play with the "Depth Offset":
    Unity_qxBwquycZw.gif

    Hope this solution help.
    Have a great day
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Thank you so much for the in-depth answer @OrsonFavrel ! I'll give this a try later tonight!
     
  6. CPULL

    CPULL

    Joined:
    Aug 1, 2019
    Posts:
    5
    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.)
    upload_2022-11-18_11-2-26.png
     
  7. ludovic-theobald

    ludovic-theobald

    Unity Technologies

    Joined:
    Jun 3, 2021
    Posts:
    13
    Hello @CPULL,

    To be able to see this field, make sure the "Experimental Operators/Blocks" is enabled in the Visual Effect Preferences.
    upload_2022-11-18_11-40-28.png
     
    CPULL likes this.
  8. Ervo

    Ervo

    Joined:
    May 26, 2016
    Posts:
    8
    Hello, I can't find the Depth Offset setting. I'm using Unity 2020.3.37f1, URP 10.9.0