Skip to main content
GameDev.net gamedev.net
🔒 Locked

Lightning Effect

Started by rasher_b2 Dec 30, 2008 at 5:30 PM 2 replies 3.7k views
Original Post
rasher_b2
rasher_b2
I'm trying to make a lightning bolt type effect (in 2D, though I'm sure 3D methods are similar). I can generate a lightning bolt but I'm having problems rendering the actual effect. My lightning bolt is a path that's made up of several lines. I'm basically rendering quads along these lines but the problem is where two lines (quads) meet; some ugly artifacts appear. These screenshots should explain what I mean better than words. Ugly joints: lightning00 Larger bolt showing how the quads join: lightning01 I'm wondering if I'm going about this effect completely the wrong way or if I'm not, what would be the proper way to render it. Thanks.
dmatter
dmatter
You're currently joining the ribbon sections by their adjacent edges' centre points, try connecting their outer vertices together instead.
swiftcoder
swiftcoder
It may well be easier to draw a lightning bolt texture (in Photoshop, Particle Effects, etc.), and then render the texture as an 'axis-aligned billboard' (google for technical details). As far as I know, most games depicting lightning bolts use this method.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
CPPNick
CPPNick
Visual Basic 6.0:

Private Type POINTAPI
x As Long
y As Long
End Type
Dim lightning(5) As POINTAPI
Private Sub Form_Load()
Me.ScaleMode = vbPixels
Me.BackColor = vbBlack

lightning(0).x = 0
lightning(0).y = 0

lightning(1).x = 50
lightning(1).y = 50

lightning(2).x = 100
lightning(2).y = 50

lightning(3).x = 120
lightning(3).y = 130

lightning(4).x = 200
lightning(4).y = 110

lightning(5).x = 215
lightning(5).y = 160
End Sub

Private Sub Form_Paint()
Dim w As Integer, l As Integer
For w = 0 To 10
For l = 1 To 5
Line (lightning(l - 1).x - w + l, lightning(l - 1).y + w - l)-(lightning(l).x - w + l, lightning(l).y + w - l), RGB(255 * w / 10, 255 * w / 10, 255)
Line (lightning(l - 1).x + w - l, lightning(l - 1).y - w + l)-(lightning(l).x + w - l, lightning(l).y - w + l), RGB(255 * w / 10, 255 * w / 10, 255)
Next l
Next w
End Sub


needs work though...LoL =)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.