Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Render Queue not working on Android

Discussion in 'Shaders' started by PotatoWiz, Jan 8, 2022.

  1. PotatoWiz

    PotatoWiz

    Joined:
    Aug 26, 2021
    Posts:
    7
    Hi,

    I've tried using Render Queue to render certain objects on top of another. It works nicely on the editor viewport however, whenever I build to my android device, it suddenly stops working as if the render queue just disappears.


    Code (CSharp):
    1.  
    2.  
    3.             "RenderPipeline" = "UniversalPipeline"
    4.             "RenderType" = "Opaque"
    5.             "UniversalMaterialType" = "Unlit"
    6.             "Queue" = "Geometry"
    7.         }
    8.         Pass
    9.         {
    10.             Name "Pass"
    11.             Tags
    12.             {
    13.             // LightMode: <None>
    14.         }
    15.  
    16.         // Render State
    17.         Cull Back
    18.     Blend One Zero
    19.     ZTest Always
    20.     ZWrite On
    21.  
    22.  
    I am using URP, this shader is the one that renders on top of the other one with lower render queue.

    This one sits at render queue 2000 and the one which is meant to render behind of the this object sits at render queue 1995 with ZTest LEqual and ZWrite On.

    The effect works on editor, however not the android device I built it to. I am using GLES3 Graphics API, I tried removing Vulkan from it with no luck, also tried various texture compression with no luck either.

    Thank you very much.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,366
    GPUs that use Tile Based Deferred Rendering, as most android devices have, may not always respect render queues for "opaque" objects.

    Desktop GPUs render using what's know as immediate mode rendering, meaning objects render one at a time in the exact order they're sent to the GPU. For better efficiency, sorting the opaque objects to be sent to the GPU starting with the closest and ending with the furthest away helps prevent rendering pixels of objects that won't be seen. This is called over shading.

    Tile Based Deferred Rendering doesn't work like that. Instead most mobile GPUs render opaques in two passes. After calculating the vertex positions for all meshes sent to the GPU for the frame, it renders the depth for all visible opaque triangles. Then it renders the color for all visible opaque triangles. So there's no reason to sort opaque objects before sending them to the GPU as that first depth only pass prevents almost all over shading. So Unity doesn't sort them before sending them on most mobile devices. Unfortunately this means opaque queue stuff that relies on a specific draw order often breaks.