Simplified 3D Wave Effect

Gradient-Based Wave Effect for quick VFX or general usage. I’ve used it to make some simple Electric Effects.

All examples used a PlaneMesh with Subdivide Width=10 and Subdivide Depth=10 or more.

Video Example (Old)

Shader code
// Credits
// Made by Vesper | https://vesperum.itch.io/ | https://twitter.com/Vesperibus
// Enjoy!
shader_type spatial;
render_mode unshaded, cull_back;

group_uniforms Wave;
uniform float x_deviation = 0.2;
uniform float x_deviation_random = 0.2;
uniform float z_deviation = 0.2;
uniform float z_deviation_random = 0.2;
// I recommend using uv values above 10 for a good spread
// It loops back when using high numbers so don't bother going above 200
uniform vec2 uv_scale = vec2(10.0, 0.0);
uniform float time_scale = 10.0;
uniform sampler2D noiseTexture;

group_uniforms Color;
uniform vec4 color_begin : source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform vec4 color_end : source_color = vec4(1.0, 1.0, 1.0, 1.0);
// By default it spreads the color from -z to z
// Enable to swap from -x to x
uniform bool swap_xz =  false;
void vertex() {
    float time = TIME * time_scale;
    float noise_sample = texture(noiseTexture, UV).r;
    
    float random_x = noise_sample * time;
    random_x *= x_deviation_random;
    VERTEX.x += x_deviation * sin(time + random_x) * sin(VERTEX.z * uv_scale.y);
    
    float random_z = noise_sample * time;
    random_z *= z_deviation_random;
    VERTEX.z += z_deviation * sin(time + random_z) * sin(VERTEX.x * uv_scale.x);
}

void fragment() {
    vec2 uv = (1.0 - UV);
    vec4 c = vec4(0.0);
    if (swap_xz) {
        c = mix(color_begin, color_end, uv.x);
    } else {
        c = mix(color_begin, color_end, uv.y);
    }
    ALBEDO = c.rgb;
    ALPHA = c.a;
}
Tags
3d, Electric, simple, Spatial
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Ring / Wave shader

QoS Style World Space Blue Noise Dither Effect

Voronoi Guard Effect Shader

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
VolTitanDev
VolTitanDev
6 months ago

Alright! I’ve been looking for a ghidorah-like effect for my dream game and its in the form of this shader.