Hudo1979 Posted July 28, 2016 Share Posted July 28, 2016 Hello have anyone did any lightning effect in bbabylonjs? such as lightning beam, chain lightning etc, can someone give me a push in the direction? Quote Link to comment Share on other sites More sharing options...
chicagobob123 Posted July 28, 2016 Share Posted July 28, 2016 You can apply the concept of lightning from other applications to Babylon. I looked at this for a small amount of time yesterday. What you need is a small glowing sphere white in the inside and blue on the outside I dont know how to do this. I checked this out but its not right http://www.babylonjs-playground.com/#1HECPU#52 . You need a direction and allowance for randomness in that direction. You use the random position to make the lightning bolt look real. You precreate the particles with 0 opcity. When its want a bolt to be shot you adjust the opacity position on the fly. lightning effect look this up via google. This has a generic version of what you need to do via math. http://webcache.googleusercontent.com/search?q=cache:IdgpUg97ajAJ:gamedevelopment.tutsplus.com/tutorials/how-to-generate-shockingly-good-2d-lightning-effects--gamedev-2681+&cd=1&hl=en&ct=clnk&gl=us Quote Link to comment Share on other sites More sharing options...
chicagobob123 Posted July 28, 2016 Share Posted July 28, 2016 forgot. Sorry I am buried at work otherwise I would try to code up an example. If you remove the random positioning you can make an easy laser shot with particles. Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted July 28, 2016 Share Posted July 28, 2016 If you're fear of maths, i think you can test the sprite system, with a nice texture (examples). Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted July 28, 2016 Share Posted July 28, 2016 Hi @Hudo1979 Very interesting question, I'm sure there are many ways of achieving this, it can probably be done with a shader, but the particleSystem should also be able to achieve it Edit: a quick proof of concept : http://www.babylonjs-playground.com/#Q1CAF#3 and with a start/stop interval & timeout for "life-like" lightning flashes.. http://www.babylonjs-playground.com/#Q1CAF#5 adam 1 Quote Link to comment Share on other sites More sharing options...
Hudo1979 Posted July 29, 2016 Author Share Posted July 29, 2016 Thank All!! For all the wonderfull tips. I just have some consideration, if I need lightning in a game, I probably for performance using a texture with lightning sprite? The particle really looks cool, but is is difficult to like set emitter and target to draw the lightning Quote Link to comment Share on other sites More sharing options...
chicagobob123 Posted July 29, 2016 Share Posted July 29, 2016 Hudo 1979 , you have to consider several things. Do you want the effect to be seen as growing and reaching out or just a flash? Do you want the effect to be somewhat random controlled by parameters. These are some of the artistic choices you need to decide before you derive a solution. Quote Link to comment Share on other sites More sharing options...
Hudo1979 Posted July 30, 2016 Author Share Posted July 30, 2016 more or less I want it as a beam weapon effect, with a starting point and a targeting point, that have an animation that looks like a lightning. Quote Link to comment Share on other sites More sharing options...
MarianG Posted August 1, 2016 Share Posted August 1, 2016 Here is done with sprite: http://playground.babylonjs.com/#1IQ6A5#5 Quote Link to comment Share on other sites More sharing options...
Hudo1979 Posted August 7, 2016 Author Share Posted August 7, 2016 @bulisor Looks great! I will look more into it, thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.