I wang to implement a trail renderer in my course about compute graphics using OpenGL. I google this question and search it in https://gamedev.stackexchange.com/ and find nothing except unity trail renderer. However this is my course project and I really really want a trail effect in my project.Is there any website or paper to solve my question?

  • \$\begingroup\$ Do you mean something like, the mouse is moving around and it's leaving a trail behind it ? With particles or something similar? \$\endgroup\$ Apr 24, 2019 at 13:28
  • \$\begingroup\$ Yes,In short I want a simplied unity trail renderer in my project implemented by opengl and C++.I need to know the algorithm of unity trail renderer or other trail renderer. \$\endgroup\$
    – LiShaoyuan
    Apr 24, 2019 at 13:36

1 Answer 1


The Unity trail renderer is basically a procedurally created triangle strip. This should be relatively easy to do on your own. Add an array to your game object which keeps track of the past positions and rotations of your object. Then create the geometry of your trail object each frame by creating vertices from these positons and rotations. Use the rotation to calculate a point slightly to the left and another point slightly to the right of the position. If you want the trail to become thinner in the end, reduce the distance the further the point is in the past. Set an appropriate material, pass the coordinates as a vertex buffer and you are done.

  • \$\begingroup\$ Rendering from vertices to trail needs a triangulation or only rendering vertices as points/spheres? \$\endgroup\$
    – LiShaoyuan
    Apr 24, 2019 at 13:47
  • \$\begingroup\$ As I wrote in the first sentence: You render the vertices neither as points nor as spheres but as a triangle strip (each vertex forms a polygon with itself and the two previous vertices). \$\endgroup\$
    – Philipp
    Apr 24, 2019 at 13:48
  • \$\begingroup\$ Thanks very much, that sounds great! \$\endgroup\$
    – LiShaoyuan
    Apr 24, 2019 at 13:58
  • \$\begingroup\$ I think in Unity the trail's orientation is computed from its positions, not from the orientation of the object itself (so a trail emitted from the pivot of a translating, spinning object doesn't twist around itself and cause self-intersection artifacts, but instead lays flat along the path of translation). \$\endgroup\$
    – DMGregory
    Apr 24, 2019 at 15:52
  • \$\begingroup\$ This guy uses a good technique check it out blog.mapbox.com/… \$\endgroup\$ Apr 25, 2019 at 0:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .