Best practice for soft trails?

Hey folks, so I was creating some light swoosh sketches in Unity, but I struggled a bit with the large soft trail part.
I wanted to create a setup which would work for winding motion paths from a 1st person perspective, but I couldn’t find a setup that looks:

  • soft and smooth
  • with a consistend thickness
  • from all angles

This is what my final VFX sketches look like, to give you an idea of what I wanted to achieve:
LightSwooshes - Preview
(more and larger here: Klaus' VFX Sketchbook - #25 by Foxician)

These are the approaches I’ve tried, that I found to be not good enough:

  • Unity’s Trail Renderer using the alignment “View”. The generated mesh overlaps itself when you look at it from a flat angle, leading to bright artifacts:

  • Trail Renderer using the alignment “Transform Z” with a vertically oriented trail. The mesh twists at some point:
    2022-02-09 21_28_26-Seer

  • Trail Renderer using the alignment “Transform Z” with a horizontally oriented trail. The mesh looks too flat:
    2022-02-09 21_30_47-Unity 2018.4.23f1 Personal - PREVIEW PACKAGES IN USE - Scene_LightSwooshes.uni

  • Two intersecting Trail Renderers using the alignment “Transform Z” with diagonally oriented trails, one almost horizontal, the other as vertical as possible without getting a full twist. The idea was for them to complement each other. It’s still very visible where one trail flips its facing direction though, especially because it billows a bit:

    LightSwooshes - 2 TrailRenderers

  • A circular cylinder mesh (torus) using a fresnel based transparency. The gradient on the edge was either too small and not soft enough or it was too big, which made parts of the torus shape disappear:


I ended up using this approach, unfortunately it only works for a circular path:
Two intersecting cones - similar to the approach with two trail renderers, but since it’s a static mesh, I got rid of the billowing motion. It would look a bit better if I animated the the texture instead of rotating the whole object, but rotating the object was faster and doesn’t matter for this VFX piece :wink:

LightSwooshes - 2 Cones


Thoughts about further approaches:

  • Maybe a procedural mesh trail would work to get a similar result to the cones (or it would pose the same problems as the trail renderers).
    I found the following two trail tools on the Asset Store, but didn’t try them (since it was only a sketch I didn’t want to spend money on something that might work :money_with_wings:):
    Unico Mesh Trail | Particles/Effects | Unity Asset Store
    Ara Trails | Particles/Effects | Unity Asset Store

  • My last idea was to find a volumetric shader (I don’t know how to create one), but that would probably also only work for a fixed path and I’m not sure if it could be animated without too much difficulty.


So I am wondering: Is there an approach that works better? Or is this something that has no perfect solution and you would just conceal the imperfect parts with the rest of the composition?

Thank you for your time!

7 Likes

Unity trails/ribbons does not have tooling to solve these issues easily without lowish level TD & programming, which is a rare skillset seen here especially because Unity lacks a wide adoption of technical contributors.

that said ARA trails is one of the more comprehensive upgrades…

pinching must be solved on the programmatic geo side and also to help solve quadrilateral / triangulation interpolation rendering issues.

unfortunately this just doesnt exist at a satisfactory level for the entire community… some places have these tools, but they are not shared

if you can work out cam facing on the vertex level for a shader than modeling a static arc shape where the shader can spin somewhat while avoiding pinching ‘would’ be your best practice. it may also require a softparticle concept if you anticipate an oblique view

this is why static soul’r-coasters are the most common i have seen in Unity teams (this is the same as your doughnut idea, but you pan the texture, not just rotate the geo)

1 Like

Hey Torbach, thank you so much for your detailled answer, it definitely got me on the right track!

Somehow I never came across the term “soulercoaster” before, and I couldn’t find enough by “swooshes” or “soft trails”. A very helpful link, in case anyone else stumbles across this thread: Curvemesh | RealtimeVFX Wiki | Fandom

There is a way to create custom fresnel on a cylinder that doesn’t fade along the length of the mesh, only at the ‘sides’, if that makes sense. I learned this from an exceptional coiled telephone cable shader, of all things!

Here’s the link:
How To Create A Coiled Cable Shader In UE4 | by Ross Beardsall | XRLO — eXtended Reality Lowdown | Medium

And to quote:

We can do this by getting the camera vector from each pixel and transforming it from world space to tangent space. We can then evaluate the ‘G’ channel to determine the direction of the pixel for the viewing angle. From this, we can construct what amounts to another height map that spans the length of the cable horizontally.
Given these two height maps, we can then attenuate our scale value based on how close the pixel is to the edge of the cable, giving the illusion that the cable has rounded depth.
We found this method to be much more reliable than using a fresnel function, which broke the illusion at certain glancing angles.

0_bZZfR4cLkl_tP3Ij
Regular fresnel

0_OcftBd8xt5najelQ
Ross’s custom cylindrical fresnel


Back to the subject of trail rendering…

Frankly it’s the one of the most disappointing aspects of working with Unity to me. The poor line rendering functionality that is really showing it’s age constantly throws up roadblocks with UV’s, camera facing, and limited implementation with particle systems. I’ve yet to find a satisfying solution.

3 Likes

That link is a precious resource. I tried his method but don’t seem to work, could you please guide me how did you replicate this effect?

What exactly is it you need help with? The fresnel part?

1 Like

Oh thank you for your help but I figured it out. Instead of using Green channel like Ross said, I used Red channel, the result is amazing.

1 Like

@fearian Thanks a lot for your post, much appreciated! I tried it shortly after you shared it, but just now came around to write a proper response to this thread.

Ross’ approach is very interesting, as he’s using vertex tangents (as opposed to fresnel which uses vertex normals) - if I understood it correctly.
It took me a while to figure this out, because a default torus mesh (in Maya at least) has differently aligned vertex normals than a cylinder mesh.


Vertex normals, tangents and binormals of a cylinder mesh and a torus mesh. Tangents (green) are oriented along the circumference of the cylinder. If you think of the torus as a bent cylinder, the tangents are oriented along the height of the cylinder instead of its circumference.
(I used a free, handy tool by Feng Tang to visualize vertex normals, tangents and binormals in Unity.)

Therefore using vertex tangents in the shader looks correct on a cylinder, but it doesn’t on a torus:

So you can either use a bent cylinder to create a torus mesh with “correct” vertex tangents or you use a torus mesh with “wrong” vertex tangents, but in the shader use vertex binormals instead of the vertex tangents. Both ways will look like this:
2022-03-12 16_29_51-Window

So yes, plugging Ross’ approach into the opacity of a shader to create a soulercoaster is more stable than using fresnel for opacity, but if you put it on a cylinder which from a certain perspective overlaps itself, it’s also not ideal:
ezgif.com-gif-maker (3)

Anyways, I had fun following Ross’ tutorial and I’m always happy to learn different approaches! :+1:

2 Likes