1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Greetings Guest!!

    In order to combat SPAM on the forums, all users are required to have a minimum of 2 posts before they can submit links in any post or thread.

    Dismiss Notice
  3. Greetings Guest, Having Login Issues? Check this thread!
    Dismiss Notice
  4. Hail Guest!,
    Please take a moment to read this post reminding you all of the importance of Account Security.
    Dismiss Notice
  5. Author Wes Locher has teamed up with Stratics for a giveaway of his new book Braving Britannia. This book explores the history and impact of Ultima Online and includes interviews from current and past dev team members as well as many UO and Stratics community members. Click here for more details!
    Dismiss Notice

[Developer Blog] Re-inventing the trails

Discussion in 'EVE News' started by EVE News, Nov 25, 2011.

  1. EVE News

    EVE News RSS Feed
    RSS Feed

    Apr 12, 2011
    Likes Received:
    I remember trails in EVE. A long time ago we really had them. In my memory they were cool. And beautiful. So I installed Empyrean Age again and played a little bit on one of our reference servers, “Classic client” of course. And it was then I realized that the old trails were actually really cool, but not exactly what I would call beautiful. Take a look, does this bring back memories?


    Figure 1: Trails in Empyrean Age (click to enlarge)


    Figure 2: Trails in Empyrean Age (click to enlarge)

    So last summer, when the office was really quiet and I had some time, I started thinking about trails in EVE again: why they were removed a while ago in Apocrypha, how I could bring them back, and most important…how to make them look better and render faster.

    My initial plan was to get them done during summer. Turned out I was a little bit too optimistic. Actually way too optimistic…

    Splines to the rescue!

    From the beginning it was pretty clear we should use splines for the new trails. They give you some nice smooth curves and are positioned only by a couple of control points and normals. And their math is simple enough to be done in a vertex shader, so no need to update a vertexbuffer every single frame for every single ship in the scene. By the way, that was how the old trails did it.

    See for yourself how simple cubic hermite splines are:


    Now I knew how to generate a smooth curve, but certainly not what actual geometry would be bent by it. Single billboards? Star-shaped planes? Or a chain of particles? To be honest I had no idea and I think I pretty much tried it all. Here are some of the more promising looking results:


    Figure 3: Planes facing the camera (click to enlarge)


    Figure 4: 3 star-shaped planes (click to enlarge)

    As you can see: not very beautiful. Definitely they render faster than the old ones, but they look like you would want to immediately turn them off in the options menu.


    So obviously any form of solid geometry will break or look ugly if bent and viewed from certain angles. So now I knew how not to do it. At that point you usually should take a big step back and start thinking about what it is you want to achieve: drawing a smoothly bent cylinder, (because that’s what a trail basically is) a glowing cylinder. And then I had an idea: why not solve it with ray tracing in the pixel shader? At first this sounds a little bit crazy, but when you look at the math it’s not that difficult. Intersecting a ray with a finite cylinder is certainly doable in a shader and given a fairly high number of those finite cylinders per trail the result is going to be a smoothly bent cylinder.

    The math for intersecting a view ray with an infinite cylinder:


    Click to enlarge

    Now we need to turn this infinite cylinder into a finite one by solving two more intersections: the eye ray with both of the capping planes:


    Click to enlarge

    This will eventually get us the entry and exit point of the eye ray at the finite cylinder, resulting in the length of this ray inside the whole trail. It is easy to derive some color value based on that:


    Figure 5: Ray traced finite cylinders (click to enlarge)


    Figure 6: finite cylinders form trails (click to enlarge)

    The rest is easy: close the gaps, apply some fading and let the art director play around with size, length and color:


    Figure 7: Looking nice and polished... (click to enlarge)

    Ignore the EVE server

    Now I knew how to render the trails, but I still had to figure out where the actual positions of all the spline control points would come from.

    (Btw, the summer was long gone now…)

    One reason why the old trails would sometimes get all messed up was that they relied on the exact ship’s position as dictated by the server. All MMO players know this can lead to some strange behavior of your ship’s movement, especially in lag situations. So for positioning the trails I had to ignore the absolute positions of the ship, instead relied on the smooth movement info interpolated in the client (for example the speed you see in the HUD, it never changes abruptly). If your ship is suddenly repositioned by the server, the trails now just “jump” with it! You will hardly notice. Finally, the spline control points are merely the position offsets from your ship to where it has been before. Thus, the faster the ship, the longer the trails.

    All this came together just in time to be released in Crucible, so I really hope that you will enjoy the new trails. I know I do, because now they are as good as I remember them.


    Figure 8: Wolf with trails (click to enlarge)


    Figure 9: Trails from the Punisher (click to enlarge)

    Future improvements

    Of course there is always more. Some animation on the trails, adding light absorption, refraction, etc. I would like to spend more time on the trails, so if you guys appreciate the new trails I might get the time I need to do all of this…

    New to EVE? Start your 14-day free trial today.
    Returning pilot? Visit Account Management for the latest offers and promotions.