Search Unity

Trail Rendere Draw On Top Of Trail

Discussion in 'General Graphics' started by At09em, Jul 4, 2022.

  1. At09em

    At09em

    Joined:
    Mar 25, 2021
    Posts:
    5
    The Trail Renderer draws under previously drawn trail. How do I make it draw on top? I have attached pictures of the problem, inspector and material.



    Inspector


    Material
     
    DungDajHjep likes this.
  2. At09em

    At09em

    Joined:
    Mar 25, 2021
    Posts:
    5
    Any idea?
     
  3. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Unfortunately I don't think it's easy with the built-in trail renderer (and particle trail renderer).
    They both draw the trail from head to tail, so later parts of the trail end up drawing over the earlier parts.

    Ideally we would have an option to choose which end to start drawing from.. but we don't :(

    One random idea i have is (assuming the trail is writing depth), set the depth test on the material to be Less instead of LessEqual. It would required a custom shader though I think. You could probably copy the standard unlit particle shader you are already using, put it in your project, rename it, and change the ZTest line in the shader file. (https://docs.unity3d.com/2019.1/Documentation/Manual/SL-CullAndDepth.html)