Jump to content
  • Advertisement

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 this post

Link to post
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. 


Share this post

Link to post
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).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!