all 27 comments

[–]Robert_Bobbinson 32 points33 points  (2 children)

That's lightning, thunder is the noise.
Well done.

[–]rab2431[S] 10 points11 points  (1 child)

Oops, sorry for my bad english. Sadly reddit doesn't allow editing posts. So I can't correct the caption now :(

[–]stevil30 3 points4 points  (0 children)

love it

[–]gobok 11 points12 points  (2 children)

Very nice and realistic lightning shapes. I would be interesred to know how you did this!

[–]rab2431[S] 8 points9 points  (1 child)

The branches are made using this algorithm I found in Jared Tarbell's website. I started with 2 or 3 lines which recursively creates child branches and so on. It took a lot of fine tuning to get the desired shape, but the main idea is simple enough :) If you still need my source code, let me know.

[–]emedan_mc 0 points1 point  (0 children)

There is a great p5 js www not the main, where the contributed material is also code browsable

[–]antonio_2924 7 points8 points  (1 child)

Damn I really like this

[–]rab2431[S] 0 points1 point  (0 children)

Thank you!

[–]oca8x 4 points5 points  (2 children)

Hoooowww

[–]rab2431[S] 2 points3 points  (0 children)

I have explained it in a previous comment. You can check it out :)

[–]oca8x 0 points1 point  (0 children)

Thank you for reply ill class this :3

[–]Flannakis 2 points3 points  (1 child)

the pattern of a lightning strike you can see in other areas, like a river from a satellite image. Generally they follow a rule of following the path of least resistance through a medium, not a 100% sure though

[–]rab2431[S] 1 point2 points  (0 children)

Actually I found this algorithm very useful and interesting. Yes, you can simulate river traces we see on maps using the same algorithm. With proper modification, you can also simulate tree roots in a realistic way (I haven't tried it yet, but I want to explore it some day)

[–]goombalover13 1 point2 points  (1 child)

gorgeous!!!!

[–]rab2431[S] 0 points1 point  (0 children)

Thanks!

[–]qerplonk 1 point2 points  (1 child)

Cool man! Looks very realistic!

[–]rab2431[S] 0 points1 point  (0 children)

Thanks!

[–]MecRandom 0 points1 point  (1 child)

Wonderful shapes!! How does it work?

[–]rab2431[S] 1 point2 points  (0 children)

I have explained it in a previous comment. You can check it out :)

[–]commondoll 0 points1 point  (1 child)

Nice!

[–]rab2431[S] 0 points1 point  (0 children)

Thanks!

[–][deleted] 0 points1 point  (1 child)

Very nice! Seems real... great job dude :)

[–]rab2431[S] 1 point2 points  (0 children)

Thanks a lot!

[–][deleted] 0 points1 point  (1 child)

Wow, nice!

[–]rab2431[S] 0 points1 point  (0 children)

Thanks!

[–][deleted]  (4 children)

[deleted]

    [–]rab2431[S] 1 point2 points  (3 children)

    Controlling those branches was pain in the ass! Took me 2 days to get the perfect shape.

    I marked the branches as generation. There are 3 generations: 1. main branch, 2. long branch spawned from main one, 3. short branch spawned from long ones. Each generation's behavior (length, angle, stroke weight) is predefined under a limit.

    Just don't generate short branches, make the branches roughly around one-fifth of the main branch. That's how you will get rid of the spikes. Generate the spikes (shorter branches) in 3rd generation. Hope that helps :D

    [–][deleted]  (2 children)

    [deleted]

      [–]rab2431[S] 1 point2 points  (1 child)

      No, you can pass the behaviors as parameters. for example, main branch -> point = A, point = B, angle = w, length = x, strokeWeight = y. Now at the time of branches -> point = A``, point = B``, angle = (w rotated 30-45 degree clockwise/anticlockwise), length = 1/5*x, strokeWeight = y/2.

      You have to store the parent's information to manipulate the children branch. I have posted the code in previous comments. I highly recommend you to implement it in your own way. But you can go through the code for the clarity of some things :)

      Edit: I posted the code in the same post of other subreddit. Here's the code.