Search Unity

Resolved How to change the render queue?

Discussion in 'Shader Graph' started by zhuchun, May 21, 2019.

  1. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hello guys, I was making a screen UV distortion shader and noticed particles were not been displayed through it correctly. The render queue of that shader graph is 3000, I guess that was the point, however, I don't know where to assign that number in the shader graph. Can anyone help?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    There are several things to break down in this question.

    First thing, Shader Graph does not give any explicit control over the Render Queue, only implicit based on the rendering mode drop down: Opaque (uses queue 2000, aka Geometry) and Transparent (uses queue 3000). Ideally opaque objects using a non 1.0 alpha threshold should be using the AlphaTest queue (2450), but that doesn't appear to be the case. (That's a potentially significant performance issue for mobile.)

    You can however override the queue on the material directly if needed.


    But that doesn't address the real issue you're having of particles not showing up when using the scene color node to do diffraction. Unfortunately this is by design. Both the LWRP and HDRP make a copy of the scene after the opaque render queues have finished that gets fed into shaders that want to access the scene color. This means any thing rendered as part of the transparent queues won't be visible, and it's not really advisable that you move your particle effects into the opaque queue as it can cause rendering order issues.

    From a quality perspective, this is an obvious step back compared to the Grab Pass based diffraction used in the built in rendering paths. However this is being done this way because it's significantly more efficient.
     
    Kokowolo and zhuchun like this.
  3. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Thanks for your insights @bgolus

    Regarding the copy order, doesn't it mean lots of overlay shader/ image effects are not going to work anymore? That could be a huge impact, I wish they could fix it somehow:(
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    Shader Graph does not support making shaders for image effects or UI at the moment. However most unlit shaders work perfectly fine with the LWRP and HDRP. Image effects however are all completely broken since they’ve changed how those work for the SRPs. The “OnRenderImage” function most old image effects use simply never gets called when using an SRP. The Overlay queue was completely removed early on, but may have been added back in, I’m not entirely sure.
     
    zhuchun likes this.
  5. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    In case someone needs this, Shader Graph now has a new checkbox on the HDRP master node, it provides two extra output channels called "Distortion" and "DistortionBlur". Distortion is literally a distortion effect so you can make use of it with a mask texture and scene color, works as expected. Distortion blur is an HDRP bloom-ish effect, it's a vector1 from 0 to 1, so maybe you can use it on UI blur or refraction stuff. There's another value named "sorting priority" and basically it just adds the number to the shader queue, neat!

    (Hi Unity guys, thank you for bringing these. Perhaps making that priority as output would be more useful?)
     
  6. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello zhuchun,

    Could you please post a picture showing how you use the Distortion in the shader graph? I can't make it work, I am trying to do a refractive object, but I can't figure out how to use it.

    Regards,
    Carlos
     
  7. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Here you go, but I'm not sure if this setting is specified to HDRP

     
  8. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello zhuchun,

    I appreciate your help very much! But I was asking about what is connected to the Emission node in order to make it work? I have tried all kind of inputs there but nothing distorts

    Regards,
    Carlos
     
  9. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    For example, if you're going to make a shock wave, then you can connect a node named "Scene Color" to emission output, and distortion output would be conneccted to your noise texture, like a cloud or twirled annulus, etc. I hope this snapshot makes it clear.

     
  10. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Thank you so much! That helped a lot, this is great!. I appreciate your help very much.

    Regards,
    Carlos
     
    zhuchun likes this.
  11. Baalhug

    Baalhug

    Joined:
    Aug 12, 2013
    Posts:
    32
    How??
     
  12. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    This is near the bottom of any material using a URP Shader Graph shader.
    upload_2020-3-3_22-21-42.png

    If you're using HDRP this doesn't exist and you can't really modify the queue. But you can adjust the priority and other settings related to the order it gets rendered.
     
    OlehBur and Kokowolo like this.
  13. Baalhug

    Baalhug

    Joined:
    Aug 12, 2013
    Posts:
    32
    Nah, I don´t use graph shader, i thought there was a way to do it from Inspector Window top right button -> Debug, but everytime I go back to normal the change is lost. I know how to change the shader code manually, just wondering if there was a built-in way from editor. Thank you anyway for your fast response.
     
  14. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    This is the Shader Graph subforum, so questions asked will be presumed to be related to such.

    If you’re using built in shaders, Unity chose not to expose the render queue to the inspector and instead set it to fixed queues based on the render mode. The queue is still being changed, just overridden by their custom inspector as soon as you swap back.
     
  15. justinsykes2006

    justinsykes2006

    Joined:
    Mar 12, 2020
    Posts:
    10
    Hi there, I know I'm a bit late although I was having the same problem. But I managed to find a solution for it. If you want to change the renderqueue of the shader in the shader script, you need to choose either Transparent or Geometry (or others) and add a +x behind it. (x being whatever extra number you'd like). For example: Tags { "Queue" = "Transparent+2000"}

    I hope this is helpful.
     
  16. awsapps

    awsapps

    Joined:
    Jun 15, 2021
    Posts:
    74
    Is there a way to modify the render queue in a Shader graph (not using URP nor HDRP) ?? Thanks!
     
  17. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138

    the material of a shader graph seems to expose a render queue property

    upload_2022-8-9_18-19-2.png
     
    OlehBur and awsapps like this.
  18. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    230
    Am I blind?

    Screenshot 2023-03-15 at 21.45.10.png

    [EDIT:] I updated Unity from 2022.1.19 to 2022.2.11 and now the Advanced Options appear. Weird.
     
    Last edited: Mar 15, 2023
    sivrikaya likes this.
  19. icormier

    icormier

    Joined:
    Aug 26, 2021
    Posts:
    16
    Maybe a little late but for future user you can show all inspector properties by change the inspector to debug view. then you will have access to app properties.

    upload_2023-8-7_10-19-22.png

    upload_2023-8-7_10-20-11.png
     
  20. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    194
    Can you guys change the render queue on the debug inspector? If I change it it just goes back to its previous value :/

    Update: Issue being tracked here https://issuetracker.unity3d.com/is...g-it-in-the-inspector-window-using-debug-mode

    Also, it would be great to be able to set the default render queue for a shader on shader graph. If a shader is always supposed to be used on a specific render queue (in my case, 2501 to be rendered right after the skybox), having to set that on the material every time is likely to be forgotten and cause issues.
     
    Last edited: Dec 19, 2023
    giraffe1 likes this.
  21. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    302
    Anyone know any work arounds? I ran into the same issue. Always resets back to the preset value.
     
  22. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    The work around is always use the debug inspector. As what's stomping on the change is the custom inspector code used by Shader Graph.

    Alternatively set the render queue at runtime... every tick while in the editor, on enable in standalone, because if the inspector is open it'll stomp on it again.
     
    giraffe1 likes this.