Ribbon/billboard trails

Started by
4 comments, last by Yeti des Bois 10 years, 7 months ago
I am trying to render billboard trails for spaceship engines. The basic idea is that I record the last N positions of the emission point in world space, and then construct a quad/triangle strip along that path. This I have working well, but the tricky part seems to be keeping the strip oriented to face the camera. For each segment along the path, I generate 2 vertices, each containing the position, and the direction to the previous position, plus a direction constant indicating left or right side of the strip. In the vertex shader, I cross the camera view direction with the direction to the previous segment, which should obtain a direction vector perpendicular to both the camera and the path. I then multiply by the side constant to move either left or right, and add it to the position. This generates a pretty nice trail, in general, but it disappears when the camera is close to behind the trail (my cross product approaches zero), and it 'crinkles' during tight turns, as adjacent path segments are rotated differently. Does anyone have experience with ribbon trails, and could maybe offer some advice? I see these effects in plenty of games, so I assume I am just missing something basic.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Advertisement
You can see the issues in these screen shots. The first shows the trails disappearing as the cross product approaches zero (but for some reason, only from one side):


The second shows the jagged trail during turns:

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Gah, it turns out to have been a fairly silly mistake - with any luck others can learn from it [smile]

I was crossing the segment axis with the camera view direction, but I am now crossing the segment axis with the direction from the segment to the camera - and this corrects both the disappearing and the jagged edges.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Hello, I'm trying to reproduce your method for billboarding trails, but I've some difficulties... You mentionned "Direction constants" :


plus a direction constant indicating left or right side of the strip

Assuming direction of the segment is UnitZ, and the normal of the segment UnitY : direction constants are UnitX for thie left side and -UnitX for the right part ? I mean, these two vectors point outside the segment. But the result is not correct.

Here is how I implemented your description :


but I am now crossing the segment axis with the direction from the segment to the camera

Vector3 dir = Vector3.Normalize(cameraPosition - Position);
Vector3 dir2 = Vector3.Normalize(Vector3.Cross(dir, Direction)); //Direction = UnitZ


I then multiply by the side constant to move either left or right, and add it to the position

Vector3 final = Position + dir2 * OutSideDir; //UnitX

and then multiply by ViewProj matrix

Thank you for your help

I think you're missing a second cross product.

Read this: http://www.gamedev.net/topic/644649-bill-boarding-oriented-rectangle/#entry5072390

OK thank you I managed it, altough I still don't understand why switcoder added "a direction constant indicating left or right side of the strip"

This topic is closed to new replies.

Advertisement