View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Ribbon/billboard trails

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1swiftcoder  Senior Moderators

Posted 05 February 2009 - 03:06 AM

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 - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #2swiftcoder  Senior Moderators

Posted 05 February 2009 - 07:23 AM

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:

### #3swiftcoder  Senior Moderators

Posted 05 February 2009 - 08:26 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 - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #4Yeti des Bois  Members

Posted 05 September 2013 - 04:36 PM

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

### #5Kryzon  Prime Members

Posted 05 September 2013 - 08:39 PM

I think you're missing a second cross product.

### #6Yeti des Bois  Members

Posted 07 September 2013 - 12:50 AM

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"

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.