Author Topic: Layer Sorting  (Read 64 times)

dgtlhybrd

  • Newbie
  • *
  • Posts: 1
    • View Profile
Layer Sorting
« on: February 10, 2021, 03:51:59 AM »
Ive been getting an issue with trails - where the trails are appearing behind some objects and in front of others; is there a way to adjust the sorting?

to be more specific the trails are appearing behind all objects on a specific unity layer
« Last Edit: February 10, 2021, 04:00:19 AM by dgtlhybrd »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 6630
    • View Profile
Re: Layer Sorting
« Reply #1 on: February 16, 2021, 05:59:07 PM »
Trails should be rendered behind the object if the "Draw Behind" checkbox is selected in the inspector.
Is the object transparent?

SwiftIllusion

  • Guest
Re: Layer Sorting
« Reply #2 on: February 21, 2021, 05:02:59 PM »
Having a similar/possibly same problem.
I want the trail to be behind all the squares in the scene, however even with 'draw behind' ticked, it's in front of others of the same object.
https://gyazo.com/191db954c308832434073d41aa97be63
The squares material
https://i.gyazo.com/e22eba05347737d3c08d674771469baa.png
https://i.gyazo.com/8d3c97d40382d42cb041de8e8da2e4f7.png

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 6630
    • View Profile
Re: Layer Sorting
« Reply #3 on: February 21, 2021, 05:25:04 PM »
Could you please try using the Lit shader instead of the Unlit so to verify if itís a depth buffer issue?

SwiftIllusion

  • Guest
Re: Layer Sorting
« Reply #4 on: February 21, 2021, 05:49:45 PM »
Tried Lit, same result.
https://i.gyazo.com/fbad0aefc48637ada8e8bf3bef4ee9be.png
This is also after attempting a work around by rendering the trail on a separate object further back, discovering that it was drawing over the front object.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 6630
    • View Profile
Re: Layer Sorting
« Reply #5 on: February 21, 2021, 09:30:01 PM »
It works fine on my end (Unity 2019.4.18f1 with URP 7.5.2):
https://youtu.be/H-qE2DX-l88

Could you please create a new project and recreate the issue there, then send it to me?

SwiftIllusion

  • Guest
Re: Layer Sorting
« Reply #6 on: February 21, 2021, 10:46:59 PM »
How do you want it sent? Uploaded to google drive and posting the link here, minus the default trailFX directory?

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 6630
    • View Profile
Re: Layer Sorting
« Reply #7 on: February 21, 2021, 11:12:04 PM »
Google Drive or Dropbox preferably, thanks.
Send me a pm with the download link.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 6630
    • View Profile
Re: Layer Sorting
« Reply #8 on: February 23, 2021, 09:23:35 AM »
Thanks for the repro.
Using a transparent material produce that effect, that's expected since the trails are also transparent objects so both the material and trails render according to their material render queues.

In this case, to force the trail to render behind the transparent object you need to make sure the object has a higher render queue, so it renders after the trails.

You can attach this script to the object to modify its render queue when game starts:

using UnityEngine;

Code
public class SetRenderQueue : MonoBehaviour
{

    public int renderQueue = 3600;

    void Start()
    {
        GetComponent<Renderer>().material.renderQueue = renderQueue;
    }
   
}

Trails render using queue from 3100 to 3500.

SwiftIllusion

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Layer Sorting
« Reply #9 on: February 23, 2021, 12:51:09 PM »
No worries.

Ahh right that makes sense, thanks so much for the help and script, that fixed it perfectly!