- Category: Blueprints
- Update: 1.0 (011.02.2020)
- Unreal Engine: 4.18 - 4.24
- Platforms: VR, PC, Console, HTML
Lightning Fast is an powerfully combination materials and blueprints that implements wide range of realistic and stylized electricity effects.
Lightning effects has plenty of uses in games, from background ambiance during a storm, electronic fences to the devastating lightning guns and spells. This system is designed in mind to achieve all those effects with high performance, AAA quality at the same time.
- lightning flashes
- lightning bolts
- lightning chains
- lightning strikes
- lightning discharges
- lightning beams
- lightning trails
- lightning guns
- lightning electrocute
- GPU friendly and optimized for all platforms
- Wide range of high quality effects
- Two types o beam rendering (spline mesh/spline billboard mesh)
- Integrated with UE4 dynamic lights and material light functions and splines
- Over hundred parameters in materials to customize final effect
- Spline based shape of bolt easy to adjust to scene
- Character electrocute discharges effect
- Advanced lightning mesh editor tools
- Multiple animated lines rendered in single beam
- Depth fade/direction fade effect
- Glow and line color
- Refraction based distortion
- Procedural beam texture
- Dynamic branch masking and fading effect
- prototype pack – textures and materials created for demonstration purposes
- mesh generator – advanced tool prepared for editing and generating lightning meshes, allows to implement external lightning propagation class
- demo example map – showcase of 14 use cases
- Procedural mesh lib – Additional library of functions that helps to create static meshes in UE4
Basically everything starts from the geometry (meshes) and effect (materials) rendered using geometry.
The Lightning Fast mesh combined with material has some useful features and properties that are very important in the production.
- can be used witch spline meshes
- can be skinned and used as skeletal mesh
- can be scaled and keeps proper shape
- can be used in particle system
- can be watched from every angle
That gives us wide range of effects that system can handle so package is divided on multiple blueprint specialized in custom effects.
All of the effects can be found in the Blueprint folder and are presented on ExmapleMap (Demo/Maps/LightningFastMap)
- Find folder Blueprints/LightningBolt
- Drag end drop BP_LightningBolt on scene
- Effect is ready to use. Now you can adjusting parameters to get the effect that you need.
Blueprints folder contains multiple lightning effects that shows how the system works with materials and meshes is should be treated as example content or templates prepared for general use cases. Some of the effects contains blueprints the other are represented only by particle effects used that main character is using.
Check the Demo/Manequin/ThirdPersonCharacter blueprint to analyze the skills implementation.
The list of effects will be extended in the future updates.
It’s good practice to create your own effects by inheriting Blueprint classes and copy material instances to your project folder.
The Blueprints/BP_LightningSpline blueprint is a simple combination of mesh spline effect and lights. You can combine any mesh created using lightning fast package with splines even bending the lightning bolts si allowed.
Drag and drop BP_LightningSpline on scene and modify parameters. [Editing splines]
|Static Mesh||Mesh used to bend|
|Material||Material used on mesh|
|Forward Axis||The axis of mesh that is directing forward of bending.|
|Translucency Sort Priority||Rendering priority|
|Fix Spline Direction||Additional correction of spline UP direction. Fixes some twist bugs.|
|Texture Scale||Scale texture UV for beam start and end.|
|Glow Color||Override material glow color.|
|Line Color||Override material line color.|
|Lights Count||Number of lights created for spline|
|Light Snap Curve||Importance of snapping the lights to curve (0-1)|
|Light Color||Override color of light|
|Light Falloff||Fall off parameter of light.|
|Use inverse squared falloff||Fall of mode switch.|
|Light Function||The light material function used for blinking|
BP_LightningBolt is an complex example of lightning bolt effect implementation based on lightning spline blueprint. The biggest advantage of this blueprint is that can be easily integrated with every weather system.
|Animation||Bolt animation curves describes how parameter changes during update. R – time offset, G – fade, B -(not used yet), A- lightning intensity|
|Animation Rate||Speed of animation update.|
|Activation Loops||-1 (infinite), 0 – not active at start, 0> loop counts|
|Activation Delay||Delay until first activation.|
|Preview Time||Draw debug preview at some time of animation.|
|Retrigger Time||Random time in range (x-y) that system wait until next activation.|
|Use Randomization||Whether system should randomize rotation and location in Random Volume.|
|Rotation Range||Range of rotation change during randomization.|
|World||World that manages the light intensity on scene|
Use parameter World to register blueprint in BP_LightningWorld. The BP_LightningWorld actor is the manager that changes directional light intensity and skylight intensity during the stormy weather according to all managed lightning bolts.
To activate Lightning Bolt by hand (from events) use Activation function and set ActivationLoops = 0.
Dynamically updated chain of splines that connects target points in the closest range.
Simple use case of working with beam:
- Drag and drop BP_LightningBeam on scene
- Drag and drop few targets actors (BP_lightningTarget) on scene near to lightning beam actor.
- Select BP_LightningBeam and edit parameters:
- Find InitChain array and add one element. Setup the chain element:
TargetActor can be any actor or even empty then TargetLocation will be used.
Complex example of Lightning gun implementation based on Lightning Beam blueprint.
Particle emitter that presents discharges effect.
Effect of trail attached to the actor example content was used as ribbon behind the character during slow motion run.
Object targeted by lightning gun and other skills. Target also spawns example discharges particle when is attacked by lightning beam or lightning gun.
Folder contains base class of dynamic light source component and light materials.
M_LightningFast is the heart of the package and all material sub types derive functionalities from this advanced master material.
Creating material instance in UE4 is really simple. Click right on the material (M_LightningFast) and chose option “Create Material Instance”. After that operation the newly created material will be ready to configure and use on Lightning Fast meshes. You can do the same with all material instances created for specific cases stored in the blueprints folder which I am recommending to do first.
The material has a very high potential for setting up and create wide range of effects effects. The following list includes all available configuration options with usage recommendations. Some of the parameters can be hard to describe and understand at first but I am encourage you to test it in the engine and check the results of changes. 🙂
List of general basic options.
|MeshWidthScale||Scales the geometry of billboarding besh.|
|OpacitClamp||Opacity clamping for high values.|
|UseBillboardMesh||True – use billboarding system for rendering, false – render original mesh|
|UseDebugMesh||Draw debug mesh|
|UseRefraction||Use refraction effect.|
|RefractionClamp||Clamp intensity of refraction effect.|
|UseVertexInterpolators||Optimization that forces system to use interpolators (does not work with particle emitters)|
Group of parameters that helps to fade effect in some specific conditions. Close to wall or unpleasant angle.
|UseNormalFade||Normal fade i the feature that helps to hid beam when its in bad wrong related to mesh. The fade is calculated based on normal vector of mesh. For the mesh in billboard mode the normal means axis of rotation. When Axis is similar to the camera direction then mesh should be invisible because we can notice some bugs.|
|NormalFadeScale||Scale the effect makes it fade faster or lower|
|NormalFadeOffset||Offset the effect to make it more visible.|
|Fade||Makes effect translucent.|
|UseDepthFade||Whether lightning should fade when intersecting scene meshes.|
|DepthFadeScale||How fast lightning should fade when intersecting scene meshes.|
|UseVertexFade||Vertex color of lightning meshes contains additional information about fade this option allow to use the for fading begin and end of node.|
|VertexFadeStart||Scale vertex fade start|
|VertexFadeEnd||Scale vertex fade end|
Lightning beam is build of four branches that can be displayed at the same time or one after one. This section covers the basic settings.
|UseBranchFading||Activate algorithm of asynchronous fading of branches.|
|BranchFadngAlpha||Alpha multipliers of each branch of beam stored separately in RGBA channels.|
|BranchFadingOffsets||Time offsets in fading animation.|
|BranchFadingPower||Exponential fading speed of endpoint.|
|BranchFadingSource||Fading blend in of start point.|
|BranchFadingScale||Scale of fading uv.|
|BranchFadingTimeScale||Branch fading animation speed.|
|BranchFadingOffset||External controller of branch fading time.|
|UseBranchCombine||Combine branches into one beam. Set False to use separate colors.|
|UseBranchCombineMax||Combine branches by max function. False forces system to use sum function.|
|UseAlphaChannelBranch||Use fourth branch from alpha channel.|
Masking is the feature implemented for randomly hiding the branches of lightning. Even static meshes can look dynamic and various thanks to masking some of the nodes during update.
Beam configuration focused on UV mapping transformations.
UV mapping of distortion texture:
Additional skew UV offset stretches the distortion.
|UseBeamBlend||Beam blend is the effect of fading beam on start and end.|
|BeamBlendStart||Intensity of start beam blending.|
|BeamBlendEnd||Intensity of endbeam blending.|
|UseVertexColorUVOffset||Adding UV offset based on vertex color R value. Parameter helps to make mesh beam look more variable.|
|BeamUVScaleSpeed||Most important parameter|
Bolt is the effect that allows animated offsetting of the beam position on the mesh.
Whether the bolt animation should be active.
|BoltStart/BoltEnd||Start/end position of bolt.|
|BoltMoveOffset||Sets the offset of bolt animation (can start from any point)|
|BoltMoveRange||Sets the value range of bolt animation.|
|BoltMoveSpeed||Speed of bolt animation.|
Each beam is created of multiple light lines that are distorted by noise texture. The texture is moving so the effect look dynamic and chaotic.
|DistoritonScale||Scales the distortion effect.|
|DistortionTexture||Texture used for distortion offset and detail distortion offsets.|
|UseDistortionDetail||Whether distortion detail should be active.|
|DistortionDetailUVScale||Scales the uv mapping of detaled distoertion.|
|DistortionDetailScale||Scales the intensity of detailed distortion.|
Describes basic parameters of the line that is distorted and generates glow.
|LineColor||Color of line|
|GlowColor||Color of glow effect around the line|
|GlowTexture||Texture used for masking glow.|
|GlowTextureScaleMove||Animating glow texture RG-Scale, BA-Move|
|UseGlowTexture||Whether the glow texture effect should be active.|
Width of line.
Line disappearing in distance from start point of lightning.
Material supports two modes of rendering glow effect around line Hard/Soft. First one based on smoothstep function and second one based on division by distance.
Lightning Fast package contains mesh editor BP_LightningMesh that allow to create unique lightning meshes. Drag and drop blueprint on scene Blueprints/LightningMesh/BP_LightningMesh to start creating lightning mesh.
Each mesh is generated form node list (attribute Nodes array). Node list is an array that contains graph of connections between nodes described using special structure called BS_LightningNode.
|Parent||This attribute describes the index from array of parent node. Ech node has a parent. If the parent of node has the same index as source node than the parent is root(starting point) of the hierarchy generated from the node list.|
|EndPos||Location of ending point. Can be edited visually in the main view-port as well by selecting and using translation gizmo.|
|Loop||Value highe or equal 0 describes with Node is the index of loop.|
|Priority||Higher priority means that node describes main branch.|
|TangenInOut||Scale of tangent input output vector.|
The package comes witch additional tools that helps to create unique lightning meshes in the Unreal Engine 4 editor. There are two methods of editing Nodes array.
- Editing by hand using Tree Editor
- Editing using Tree Generator
Tree editor is the basic method of editing the node list there are multiple buttons that increases the speed of building the new branches of lightning mesh.
|Node Append||Append the child to selected node (selected node index).|
|Node Insert||Divide the selected node (selected node index) by inserting node in the middle.|
|Node Remove||Removing the selected node (selected node index).|
|Node Selected Get||Load data from selected index to Selected node Data.|
|Node Selected Set||Save data from Selected node Data to node as under selected node (selected node index)|
|Node transform||Transform selected node by Transform to apply attribute.|
|Reset||Clear the tree.|
Lightning Fast has advanced system of mesh generators that can be used to automatized creating of wide range meshes.
Working with generators is simple:
- Add generator to the Generator List used by the BP_LightningMesh editor.
- Chose the class of generators LTG_Branch
- Click Evaluate All Generators
- Double click on the generator instance and edit parameters and click “Evaluate All Generators” again.
BP_LightningTreeGenerator is the base lightning generator class that can be extended by other generators by overriding the Evaluate function.
Take a look on example generators provided in version 1.0 of package.
LTG_Branch – Example generation that creates branched lightning effect.
LTG_Spline – Example generator that creates lightning based on spline shape.
Create static mesh
Generated mesh can be easily converted to static mesh and used in other blueprints and particle effects. Few steps needed to do this:
- Select BP_LightningMesh blueprint and find component called ProceduralMesh
- Find option UseDynamicMaterial and se to false.
- Click button Create Static Mesh
- Select where to save the mesh
UseDynamicMaterial = false forces system to use default not instanced material. If you will skip this step then newly created meshes will contain reference to instanced material ant wont save.
Questions & Answers
Integration with Fast Stylized Procedural Sky?
Yes! Last update of Stylized Procedural Procedural Sky supports integration with Stylized Procedural Sky just place lightning bolt on map and activate it on event from build in lightning system.
It is worth buying?
Hell yes! After four mounts of:
- researching the topic,
- watching thousands of photos and videos with lightning effects,
- testing multiple solutions,
- removing huge amounts of unsatisfying effects
- hard time spend on iterations and optimizations
I can ensure you now that it's not worth to do it by yourself from the beginning when you have finished solution and my support. I would never start again if I would could... 😉