Started by Feb 05 2009 03:06 AM

,
5 replies to this topic

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]

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.

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]

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

Thank you for your help

Posted 05 September 2013 - 08:39 PM

I think you're missing a second cross product.

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

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"