# R&D Trails

## Recommended Posts

I'm currently working on implementing a trail system and I have the basic stuff working. A moving object can specify a material, width, life time, and time based curves for evaluation of colour and width. For each trail point I generate two vertices, trail point is center, vertex A is offset "left" and vertex B is offset "right", half width each. A setting for minimum distance between two trail points determines how spread out they are. This works nice until width and turning angle are so "close" that one side of trail triangles starts overlapping and in case of additive shading causes ugly artefacts.

So. I'm now playing with ideas on how to solve this:

- do some vertex detection magic and check for overlapping, maybe discard overlapping vertices or move them close by

- push both vertices on one side of trail, ie: A = point, B = point + width (instead of A = point + half_width, B = point - half_width), but I yet have to figure out how to detect that I need to do this

And other solutions or tips?

Forgot to mention, I'm doing mesh generation on cpu side.

##### Share on other sites

For our game I just do a cross product between the 2 vertices and the center vertex to figure out the facing of the triangle. Just look at the sign of the component that you use as up. If it's negative I copy vertex A into B.

Henning

##### Share on other sites

This sounds like the 'thick line rendering' problem, for which there are various algorithms that can be used to connect segments smoothly without overlap or other artifacts.

If you do e.g. a Google image search for 'thick line rendering', you'll see many images that are (or at least appear to be) related to the problem you're describing, so searching for that term might be a good place to start. If you want more suggestions, you could also elaborate on the algorithm you're using currently, and maybe post an image of what the output looks like (including artifacts).

thank you both

## Create an account

Register a new account

• 18
• 18
• 11
• 21
• 16