Announcement

Collapse
No announcement yet.

[WIP] Procedural lightning

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [WIP] Procedural lightning

    I've been having some fun with procedurally generated lightning Based on a simple L-system concept I found outlined on this blog: http://drilian.com/2009/02/25/lightning-bolts/

    Click image for larger version

Name:	Lightning_WIP2b.JPG
Views:	1
Size:	25.8 KB
ID:	1137459

    Everything is done in C++, currently using instanced cylinder meshes. I want to do this in a more optimal way and I'm thinking about either a custom particle system (similar to the beam type) or using a method like the cable component uses to draw the cable. Any ideas or suggestions?

    There are also a few things I need to fix with the branching logic to make it more detailed.


    I just finished the first pass at animation, later on I want to put a bit of upwards movement in the bolts between flashes (click download, the Dropbox preview is low quality):

    https://www.dropbox.com/s/y7iygf7py4...ightning01.mp4
    Programmer at Klang Games | Ex-CCP (EVE Valkyrie / Sparc) | @SiggiGG
    Check out my procedural mesh examples

    #2
    Once the bolts are finished I plan to add a component that will detect objects in range and send bolts out to those randomly.
    Programmer at Klang Games | Ex-CCP (EVE Valkyrie / Sparc) | @SiggiGG
    Check out my procedural mesh examples

    Comment


      #3
      Fantastic! It is procedural and it looks great, which doesnt happen too often. ^^ Keep us posted!
      FREE VR Drum Kit Project
      FREE Color LUT Collection
      FREE Physics Driven Spacecraft Project
      FREE GTA Style Vehicle Interaction
      Dynamic DoF(Depth of Field)
      Camera Crossfade

      Comment


        #4
        Originally posted by SiggiG View Post
        I've been having some fun with procedurally generated lightning Based on a simple L-system concept I found outlined on this blog: http://drilian.com/2009/02/25/lightning-bolts/

        [ATTACH=CONFIG]8938[/ATTACH]

        Everything is done in C++, currently using instanced cylinder meshes. I want to do this in a more optimal way and I'm thinking about either a custom particle system (similar to the beam type) or using a method like the cable component uses to draw the cable. Any ideas or suggestions?

        There are also a few things I need to fix with the branching logic to make it more detailed.


        I just finished the first pass at animation, later on I want to put a bit of upwards movement in the bolts between flashes (click download, the Dropbox preview is low quality):

        https://www.dropbox.com/s/y7iygf7py4...ightning01.mp4
        Maybe use splines and the spline/mesh rendering?

        Looks awesome!
        Storyteller - An immersive VR audiobook player

        Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes

        Comment


          #5
          Wow...that looks really nice man!
          Check out UNREAL 4 Lighting Academy
          https://forums.unrealengine.com/show...ng-like-that-)

          Comment


            #6
            Made with lightning, real lightning, POWERTHIRST!

            Sorry, looks good!

            Comment


              #7
              Originally posted by SiggiG View Post
              I've been having some fun with procedurally generated lightning Based on a simple L-system concept I found outlined on this blog: http://drilian.com/2009/02/25/lightning-bolts/



              Everything is done in C++, currently using instanced cylinder meshes. I want to do this in a more optimal way and I'm thinking about either a custom particle system (similar to the beam type) or using a method like the cable component uses to draw the cable. Any ideas or suggestions?

              There are also a few things I need to fix with the branching logic to make it more detailed.


              I just finished the first pass at animation, later on I want to put a bit of upwards movement in the bolts between flashes (click download, the Dropbox preview is low quality):

              https://www.dropbox.com/s/y7iygf7py4...ightning01.mp4
              Hi SiggiG,

              Very Nice. I have two questions:
              1. Will you be scripting this in Blueprints?
              2. Will you be sharing your script?


              I ask these questions because Lightening is a desired core element for Yet Another Zombie Survival FPS which features Frankenstein-like Flesh Golem Monsters that feed off electricity and have an insatiable desire to rip the living to pieces for spare body parts.

              If you answer no, not a problem. I would probably give it a go scripting a simple L-system in Blueprints using Cascade Beam Particles for segments (example). I could be biting off more than I can chew. Keep up the awesome work.
              ExORION: The Most Active [Rev-Share] Sci-Fi FPS Project in this Forum ...Join the Fight!

              Comment


                #8
                This looks pretty cool, nice work!

                Comment


                  #9
                  Fantastic job SiggiG! The procedural lightning looks superb. Keep up the fantastic work and can't wait to see what the next pass with the animation will look like. Be sure to keep us posted. Have a great day!

                  Comment


                    #10
                    Originally posted by TechLord View Post
                    Hi SiggiG,

                    Very Nice. I have two questions:
                    1. Will you be scripting this in Blueprints?
                    2. Will you be sharing your script?


                    I ask these questions because Lightening is a desired core element for Yet Another Zombie Survival FPS which features Frankenstein-like Flesh Golem Monsters that feed off electricity and have an insatiable desire to rip the living to pieces for spare body parts.

                    If you answer no, not a problem. I would probably give it a go scripting a simple L-system in Blueprints using Cascade Beam Particles for segments (example). I could be biting off more than I can chew. Keep up the awesome work.
                    Thanks all

                    1. No, not really. After going through a BP phase I prefer to do must my work in native code and using BP more for setup and hookup of assets.
                    2. If I manage to get this into a good state I see no reason not to share it, and you could certainly use that from BPs (just create a new BP inheriting my class).

                    I don't have any immediate plans to finish or release this so that might still be a bit off, and I'm only working on this from time to time.

                    Besides my fascination with fractals I'm also doing this to learn some new areas of Unreal, and currently thinking about the most efficient way to render this. A Cascade emitter like the Beam one is one approach, but for now I'm going with some kind of mesh generation.
                    Programmer at Klang Games | Ex-CCP (EVE Valkyrie / Sparc) | @SiggiGG
                    Check out my procedural mesh examples

                    Comment


                      #11
                      This looks great Siggi! I could use some great looking lightning soon for my project in case you share it.

                      Do the beams "seek" for a surface or only take a general direction? Anyway nice project!
                      Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-source template)

                      Comment


                        #12
                        Originally posted by Tom Looman View Post
                        This looks great Siggi! I could use some great looking lightning soon for my project in case you share it.

                        Do the beams "seek" for a surface or only take a general direction? Anyway nice project!
                        Thanks no they don't do that yet, but easy to add and is on my todo list.
                        Programmer at Klang Games | Ex-CCP (EVE Valkyrie / Sparc) | @SiggiGG
                        Check out my procedural mesh examples

                        Comment


                          #13
                          Hi SiggiG

                          Found a nice Particle Beam tutorial & Instanced Parameters on the Unreal Wiki. I have everything needed to construct a Procedural Lightening Blueprint translating the L-System Psuedo Code w/3D Vectors into BP Nodes:

                          Code:
                          BeamArray.Add(spawn Beam(startVector, endVector));
                          offsetAmount = maximumOffset; // the maximum amount to offset a lightning vertex.
                          ForEachLoop generation (some number of generations)
                            ForEachLoop Beam that was in BeamArray when this generation started
                              BeamArray.Remove(Beam); // This Beam is no longer necessary.
                          
                              midVector = Average(startvector, endVector);
                              // Offset the midvector by a random amount along the normal.
                              midVector += Perpendicular(Normalize(endVector-startVector))*RandomFloatInRange(-offsetAmount,offsetAmount);
                          
                              // Create two spawn Beams that span from the start vector to the end vector,
                              // but with the spawn (randomly-offset) midvector.
                              BeamArray.Add(spawn Beam(startVector, midVector));
                              BeamArray.Add(spawn Beam(midVector, endVector));
                            LoopBody
                            offsetAmount /= 2; // Each subsequent generation offsets at max half as much as the generation before.
                          LoopBody
                          Code:
                          direction = midVector - startVector;
                          splitEnd = Rotate(direction, randomSmallAngle)*lengthScale + midVector; // lengthScale is, for best results, < 1.  0.7 is a good value.
                          BeamArray.Add(spawn Beam(midVector, splitEnd));
                          I think using UE4 Cascade's Beam Particle is going to make for some really interesting lightening effects. I'll provide a download when I get something tangible working.
                          Last edited by TechLord; 08-23-2014, 05:22 PM.
                          ExORION: The Most Active [Rev-Share] Sci-Fi FPS Project in this Forum ...Join the Fight!

                          Comment


                            #14
                            Originally posted by n00854180t View Post
                            Maybe use splines and the spline/mesh rendering?

                            Looks awesome!
                            Does that exist yet? I tried looking into splines for the first time last week and the only thing I could fine were landscape splines which have a very specific purpose.

                            Comment


                              #15
                              Originally posted by Antidamage View Post
                              Does that exist yet? I tried looking into splines for the first time last week and the only thing I could fine were landscape splines which have a very specific purpose.
                              It does, as Spline Component in blueprints.
                              FREE VR Drum Kit Project
                              FREE Color LUT Collection
                              FREE Physics Driven Spacecraft Project
                              FREE GTA Style Vehicle Interaction
                              Dynamic DoF(Depth of Field)
                              Camera Crossfade

                              Comment

                              Working...
                              X