How to construct a laser beam for space scroller
I need some help when it comes to constructing a laser beam for our game. I want it to be smooth, so that when the ship is moving up and down the beam will bend nicely, ideally each part of the beam is one pixel wide.
I am not sure how to proceed, so any pointer would be appreciated.
A real laser beam would not appear to bend as the ship moved up and down because light travels so quickly.
If instead you want a stream of water effect without gravity, you can emit particles at regular intervals from the tip. These particles can be stored in a depth-limited rotating buffer so that you always have a constant number of particles. On each frame you would move each particle in the buffer by its associated velocity vector.
In order to render the stream you can just draw a line between each consecutive particle. If you want the line to have more of an interesting laser look you could render the lines as texture mapped view-aligned quads.
If instead you want a stream of water effect without gravity, you can emit particles at regular intervals from the tip. These particles can be stored in a depth-limited rotating buffer so that you always have a constant number of particles. On each frame you would move each particle in the buffer by its associated velocity vector.
In order to render the stream you can just draw a line between each consecutive particle. If you want the line to have more of an interesting laser look you could render the lines as texture mapped view-aligned quads.
What you want is a spline or a bézier curve...
By iterating small steps along the curve you draw with a simple line as Yahastu said. The smoothness of the curve depends on the size of the iteration.
http://en.wikipedia.org/wiki/Spline_(mathematics)
http://en.wikipedia.org/wiki/Bezier_curve
By iterating small steps along the curve you draw with a simple line as Yahastu said. The smoothness of the curve depends on the size of the iteration.
http://en.wikipedia.org/wiki/Spline_(mathematics)
http://en.wikipedia.org/wiki/Bezier_curve
If you use a curve like Molle suggests then you guarantee that it will look smooth without using as many points. However, you could also make it look smoother by just increasing the rate of particle generation. I haven't tested it, but I think using a smaller number of points with a smooth curve interpolation might look weird, because it would result in each pixel of the stream appearing to have non-uniform velocity.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement