I've been working on a lightning effect/attack! I used #UE5 and #Houdini, here is the breakdown on how to generate the meshes, render them in unreal, and also make them movable without a rig!
First I used Houdini to generate a mesh containing all the lightning bolts I needed.
To do so, I have a network that starts with a line, distorts it with two layers of noise mixed together, but weighting those noises so that it distorts 100% of the center and 0% of the tips. This is because I want to make an attack that starts at one point and ends at another.
To render the lightning in UE5 we need more information on the mesh, we could store this in the UVs or in the vertex color, but for the sake of visualization, I’ll do it with the vertex color.
We need to encode two things:
First, a “Bolt Id” that differentiates each bolt from each other, to be able to iterate over them, I equally distributed all of them from 0 to 1
Then another one that tells us in which direction the bolt will travel, if it is always from top to bottom you could assume this information, but having it rendered gives more flexibility
With this ready, we can start rendering the mesh in #UE5.
The first part of the effect is rendering only a few bolts at a time, the key here is to step our “Bolt Id” with time (modulated to 1) to get a mask like this one:
And then if we combine this mask with other one with a little offset we can mask only the bolts that fall in between, like this:
This is the logic inside the material:
Then to light them, I went with having two colors that will be flickering, using the same module masks we used for masking, but without stepping, with this, we can lerp between colors and give variety.
With this we are already rendering a flickering light bolt, we are only missing deformation. But before we move on I added a flickering light that moves at the same rate as the bolts and changes color the same way to make it blend in a bit more.
Since this is an attack and I only need to adjust the tips to make full contact, with a simple displacement we can fake the effect, rotation will not be perfect if deformed to much but this will never be the case.
So the logic behind the deformation is using the “up” gradient to lerp between two positions, the start and the end, as simple as that.