Generating geometry for spaceship trails

Hi!

I’m working on a space game and want to create spaceship trails (like the yellow trails here in this Enemy Starfighter example). For now I use an interval to cache the positions and orientations for the trail in a list and use it like a ringbuffer, so that it doesn’t get too long. That part works.

But now I need to generate some geometry for it. The effect I have in mind is to make it look as if I would extrude a quad with the trail positions. So I guess I have to generate the additional vertices in every frame. What is the best way to do this in Urho? Do I have to generate the geometry and set it in a model on a separate node in every frame? Or can I feed the trail position samples to a shader and generate the geometry on the GPU?

Any particular reason why you don’t use ParticleEmitter for the trail?

There is no particular inbuilt feature in Urho for dynamic trail effects, but creating a programmatic model and updating its vertex buffers every frame should not create undue performance loss. After all, that’s what the particle emitters are using.

You can look into the 34_DynamicGeometry sample (C++ only) to see how to create models programmatically.

If you can think of a shader-based solution that wouldn’t require to modify geometry buffers every frame, that will possibly yield better performance. The drawables don’t have the concept of their own shader data, so in this case you would have to have an unique material on the trail object and update its shader parameters. But note that you only have access to vertex and pixel shaders, not geometry.

Because I have no experience with graphics programming and effects, I guess. :slight_smile: The trail-effect in the screenshot I posted earlier looks more like some ‘solid’ geometry to me, so that was my first idea. But when that doesn’t work out, I’ll try particles!

Ok, then I will do that. I just needed reassurance, that this is a good way to do this.

Thanks! :slight_smile:

There’s plenty of implementations of Ribbon Trail effect if you look around. For example, Ogre3D has a fairly straight-forward implementation that you could look into.

The TailGenerator Component by codingmonkey does exactly that.
Here was a screenshot from heXon utilizing it for the trail behind the [color=#40CF00]player[/color].