Trailrenderer shader stacking issue?
Hi guys
This has been an ongoing source of annoyance for me, and I did some searching and haven't found a 100% solution yet.
So when trailrenderers overlap itself you get these annoying artifacts:

I found this thread that made a shader that got rid of that but it also got rid of transparency over other instances of transparency: https://answers.unity.com/questions/1138967/trail-renderer-overlap-changes-trail-colour.html#answer-1227662
So two bits of transparency over each other results in a them both looking solid in their own

The question is: Is getting rid of the limitations around the trailrenderer a big problem, that's why it (seems like) it hasn't been solved broadly yet?
This has been an ongoing source of annoyance for me, and I did some searching and haven't found a 100% solution yet.
So when trailrenderers overlap itself you get these annoying artifacts:

I found this thread that made a shader that got rid of that but it also got rid of transparency over other instances of transparency: https://answers.unity.com/questions/1138967/trail-renderer-overlap-changes-trail-colour.html#answer-1227662
So two bits of transparency over each other results in a them both looking solid in their own

The question is: Is getting rid of the limitations around the trailrenderer a big problem, that's why it (seems like) it hasn't been solved broadly yet?
Shader "TrailWithZWrite" { Properties{ _Color("Main Color", Color) = (1,1,1,0.5) _AlphaTex("Base (RGB) Trans (A)", 2D) = "white" {} //_ExtrusionAmount("Z Extrusion Amount", Float) = 0 } SubShader{ Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } LOD 100 ZWrite On ZTest Less Blend SrcAlpha One //Offset 0, -5000 Pass{ CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" fixed4 _Color; sampler2D _AlphaTex; //float _ExtrusionAmount; float4 _AlphaTex_ST; struct v2f { float4 pos : SV_POSITION; half4 color : COLOR0; float2 uv : TEXCOORD0; }; v2f vert(appdata_full v) { v2f o; //float3 camDirObjSpace = normalize(ObjSpaceViewDir(v.vertex)); //v.vertex.xyz += _ExtrusionAmount * camDirObjSpace; o.color = v.color; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv = TRANSFORM_TEX(v.texcoord, _AlphaTex); return o; } fixed4 frag(v2f i) : SV_Target { fixed4 texcol = tex2D(_AlphaTex, i.uv) * i.color; return texcol * _Color; } ENDCG } } FallBack "Unlit/Transparent Cutout" }


73042-screenshot-32.png
357 x 294 - 16K


trails.png
142 x 142 - 9K
Comments
Looks better than those rendering artifacts I think.