2D Lightning, Electric Arc, plasma

Simple configurable lightning, electric arc, plasma shader. 

  • Add a gradient to define the color of the arc.
  • Add a noise texture.
  • Adjust the remaining parameters to get the effect you’re looking for.
Shader code
shader_type canvas_item;

uniform sampler2D color_gradient;
uniform sampler2D noiseTexture;
uniform float speed: hint_range (0.0,5.0);
uniform float variation: hint_range (0.0,1.0);
uniform float width: hint_range (0.0,1.0);

void fragment(){
	
	vec2 noise_uv = vec2(UV.x+TIME*speed, UV.y-TIME*speed);
	float noise_sample = texture(noiseTexture, noise_uv).r;
	float x_offset = noise_sample*variation - variation/2.0;
	COLOR = texture(color_gradient, vec2((UV.x-0.5)/width + 0.5 + x_offset/width, UV.y));
}
Tags
2d, beam, Electric, electricity, lightning, plasma, voltage, zap
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Electric arc effect

Lightnight arc

Radial plasma shield segment

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
lmao
lmao
1 year ago

ok, it took me awhile to understand how it works. first of all set speed to 0. then i got decent results with variation 0.5, and width 0.3. you can play with lightning shape, by adjusting noise frequency but keep it very low about 0.004. animation is possible by changing noise seed.