Search Unity

Transparency Sort Mode and Lightweight Render Pipeline

Discussion in '2D' started by Jack31081988, Mar 27, 2019.

  1. Jack31081988

    Jack31081988

    Joined:
    Oct 20, 2013
    Posts:
    2
    Hello,

    I have issues with the Lightweight Render Pipeline and the Isometric Tilemap

    I want my player to be rendered infront of the object, when behind the object, if want it to be rendered behind.

    You can do this with the Transparency Sort Mode, but it is disabled if I choose the Lightweight render pipeline. I need the LWRP for the sprite shader to be affected by light and the Fire which I created with the Shaker-Graph Tool

    Bildschirmfoto 2019-03-27 um 19.52.20.png

    is there a workaround for using the Transparency Sort Mode with the Lightweight render pipeline?

    Thank you!
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The settings for Transparency Sort Mode do not show up with you have a Render Pipeline Asset set in Graphics Settings. As a workaround, if you are using Graphics Settings to handle the Transparency Sort Mode, you can set the Render Pipeline Asset to None, set the Transparency Sort Mode settings now that the option is there, and reset the Render Pipeline Asset. The Transparency Sort Mode settings will still be set even though the UI is gone.

    Otherwise, you could try something like this script:

    Code (CSharp):
    1.  
    2. #if UNITY_EDITOR
    3. using UnityEditor;
    4. #endif
    5.  
    6. using UnityEngine;
    7. using UnityEngine.Rendering;
    8.  
    9. #if UNITY_EDITOR
    10. [InitializeOnLoad]
    11. #endif
    12. class TransparencySortGraphicsHelper
    13. {
    14.     static TransparencySortGraphicsHelper()
    15.     {
    16.         OnLoad();
    17.     }
    18.  
    19.     [RuntimeInitializeOnLoadMethod]
    20.     static void OnLoad()
    21.     {
    22.         GraphicsSettings.transparencySortMode = TransparencySortMode.CustomAxis;
    23.         GraphicsSettings.transparencySortAxis = new Vector3(0.0f, 1.0f, 0.0f);
    24.     }
    25. }
    26.  
     
  3. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    39
    Thanks a lot!, ChuanXin.The method to empty the asset temporarily to see the setting does not work (in 2019.1.0f2), but the script does. For other total newbies, go to to Edit > Project Settings > Graphics > Scriptable Render Pipeline Settings and empty it to test out the values you need. Then set the asset again, and make a script in your assets, name it TransparencySortGraphicsHelper, and set the values you tested out before. The script doesn't need to be attached to anything.
     
  4. chaozou2008

    chaozou2008

    Joined:
    Mar 13, 2015
    Posts:
    3
    I solved this problem, there is a file New 2D Renderer Data. upload_2021-11-10_11-17-42.png
     
  5. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    853
    While this was not part of the original question I would like to add that the same is true for the Universal Render Pipeline - to configure the Custom Sorting Axis you have to remove the asset and add it again afterwards.

    (I was struggling with this myself so I hope my comment will make this solution come up in Google search for people using URP instead of the LWRP as well ;) )
     
  6. lamp2420

    lamp2420

    Joined:
    Mar 23, 2021
    Posts:
    5
    Why this isn't working for me ? I copy the script :p
     
  7. BeginnerPolymath

    BeginnerPolymath

    Joined:
    Jul 31, 2015
    Posts:
    38
    Big thanks!
     
  8. TazmanNZL

    TazmanNZL

    Joined:
    May 10, 2014
    Posts:
    4
    For those new to this problem. If using URP. Go to your Assets folder then Settings and in there will be the Renderer 2D data object. Select it and change the Transparency Sort settings in the Inspector. (Works for both Editor and Game view)
     
  9. Kaikoura_

    Kaikoura_

    Joined:
    Nov 4, 2021
    Posts:
    5
    that´s the best and quickest solution, thanks!
     
  10. panayiotismilios

    panayiotismilios

    Joined:
    Jun 21, 2018
    Posts:
    8
    If you've setup URP on your own without starting with a URP project, Create > Rendering > URP > 2D Renderer & set the Renderer for your Camera