Unity Trail render

It is the ability to generate UV on the fly. Currently you set X amount of tiles across the whole tail. Instead, we want to control the overall density of UV - an ability to “reveal” UVs as trail moves. Also, UV should not shrink/stretch across the whole trail. I can submit an GIF showing the behavior later.

Having the UVs in the opposite direction is how it’s easiest to describe, but that’s not actually correct either. For a trail with an “infinite” life, just having UVs start at the oldest point would “fix” it vs the existing Tile texture mode, but trails usually have a limited life span so this explanation is insufficient. More explicitly it’s that the UVs are static from when the point is spawned and never changed.

This is how trails with the Tile mode currently behave in Unity.

This is how nearly everyone expects it to behave. (Ignore the shading differences, this was a quick hack.)

It’s still world space tiling, but the texture “stays put” as the trail pans across the world rather than being dragged along with it.

The other things discussed above are “nice to haves” that increase the quality of trails, especially with out having to increase the poly count or modify older segments, specifically the negative color / “over UV” trick, neither of which would work with how Unity’s trails and general particle shaders work.

6 Likes

Some obvious programmer issues with this implementation:

“But then we have to store the UVs for each point!”
Kind of, yes. If you really don’t want to do that just accumulate the distance the trail component has traveled and counter pan the UVs. As I mentioned you can use this technique already to get the trail component to act like the “expected” example. (I didn’t do this for the example, I just used a world space shader because it was faster to write and worked in this very controlled case.)

“But the UV range is unbounded!”
Yep. A trail that keeps emitting forever will eventually start having issues with UV precision. It’s one of the reasons why having scale defined on the trail emitter itself rather than on a material is useful as you can do stuff like break the tri strip and wrap the UVs at some hardcoded limit and not have to worry about the UVs not lining up. Or you could just warn that this is a limitation, or have a UV loop setting, or counter offset the UVs across the entire trail once some limit is reached.

1 Like

Thanks Ben - that allows me to clarify our roadmap item covering the issue.

As you describe - it’s not as simple as calculating the UV’s in the opposite direction, so I’ll have to give some thought to whether to store the UVs per point, or attempt some kind of counter-panning solution.

I also want the Trails to vanish more gracefully, instead of the last point popping out once its lifetime expires. Just mentioning that in case it is something else that bothers you about Unity trails :slight_smile:

[quote=“richardk, post:12, topic:2664”]
I also want the Trails to vanish more gracefully, instead of the last point popping out once its lifetime expires.[/quote]

With the way Unity’s trails and general effects system are setup, having the oldest segment “retract” (like an inverse of how the first segment “extends” while still attached to the transform) would go a long way in improving Unity’s trails. The two methods I mentioned, negative color and “over UV” tricks are both ways to accomplish that same effect as that, but you don’t support negative colors since vertex colors in Unity are using a byte vector, and the “over UV” is for when the trail color is done via a LUT rather than stored per vertex. They all require allowing the last segment / point to exist beyond their intended lifetime, and only die when the second to last point’s life has expired.

It is, and it would let you reduce the vertex count on trails more easily if needed as with the current trail system you generally need to keep the min vertex distance small so the effective “framerate” of point spawns is around “30 fps”. My example gifs above actually unintentionally highlight the problem just because I wanted to space them out far enough to make sure the wireframe rendering didn’t hide the texture. :wink:

To be fair it probably still won’t get me to use the built in trail renderer most of the time. My ideal trail system is one that’s treated more explicitly like a particle system with control over individual point positions after spawn. Things like per “particle” starting velocity, gravity, noise, starting size, and even lifetime ranges (if handled properly) are huge for making trails useful for effects. Also having control over color and size by lifetime fraction on top of “over length”. It’s the difference between having a trail that just looks like a line drawn behind something and having a trail that looks like smoke. I also like to do things like having the main UVs be both time based and distance based and not purely one or the other so that if the trail is moving fast or slow can change the appearance of the trail to a degree, as well as have mostly stationary trail emitters for things like rising smoke.

2 Likes

If you haven’t seen it already, I’d love to draw your attention towards https://forum.unity3d.com/threads/release-ribbonized-particle-trails.488820/

It’s a step towards more controllable Trails, by offering a new Particle System option to connect particles based on their age.

All feedback welcome here: https://forum.unity3d.com/threads/feedback-ribbonized-particle-trails.488821/

1 Like

Did this ever get any further, i still can’t make the trail’s uv’s stay in world space…

Hey, no sorry it’s still not possible.
We added a few different UV modes, but we need to make a few more changes to do world space UVs.

ok, cheers for replying so quick…

Has anyone managed a method of doing this with the current tools? offsetting uv’s based on distance traveled? or similar?

Probably gonna get best results from writing your own trail renderer using the line renderer!

I have a script if you think its useful, it only works if you add length to the trail renderer but not when its length is reduced! trailrenderer

and yes it’s doing what you suggested, offsetting UV’s based on distance travelled. I just had this lying around so maybe you can modify it to fit your needs. Perhaps using a dissolve shader and dissolve it as it expires?

Pastebin link, C# code

6 Likes

Cheers Ludvig, thats look useful…

Hows things going, where about are you working these days?

thanks a lot!!!it\s useful

3 Likes

another year, and still no support for this in unity… Ludvig, finally tried your solution :smiley: it works only if the trail continues and lives forever, any short life trail and the system fails… @richardk Is this still on any roadmaps?

Hey, apologies that we still haven’t done this. The Particle System, Trail Renderer and Line Renderer are mostly is “maintenance mode” now, which means they are only receiving bugfixes and very small improvements. This is due to the development of the Visual Effect Graph, which aims to supercede these features.

I did pass this much-requested feature along to the Visual Effect Graph team some time ago, but my understanding is that the first version of trails in that tool won’t support this either.

Sorry that I don’t have any good news on this for you.

1 Like

cheers for the update…working on mobile, i’ve yet to use the Visual Effect Graph. and not sure i’ll use it any time soon :frowning:

Does anyone know of any unity store assets that would work as required.?

Hello.
Unfortunately I’m not good at scripting. Can you explain how to make this script work?

If I am not mistaken, just assign the script to a gameobject that has a trail renderer (and an assigned material) and then it should work (in play mode). You shouldn’t need to script anything to have it working like in the gif I posted

Thanks for your reply!

So I believe this gentlemen has figured this out.
https://www.youtube.com/watch?v=7tgGNUboc4E&list=WL&index=25
I do not speak Korean so it is hard to make heads or tales out of his setup. If anyone here does I would appreciate it.
It’s a combination of some shadergraph changes and a script to make the entire thing function.

This forum is an amazing resource. Thanks for everything, everyone!

2 Likes