3d Pixel Sway – Godot 4

A Sway Shader For 3D Pixel Art, you need a gradient, the black is what moves and the white is what will stay still! also to make the blender mesh just add two normal planes, join them and export! -enjoy!

Shader code
shader_type spatial;
render_mode cull_disabled, depth_prepass_alpha, depth_draw_opaque;

uniform sampler2D albedo_texture : filter_nearest, source_color;
uniform sampler2D gradient_texture : filter_nearest, source_color; // Gradient texture
uniform float sway_strength : hint_range(0.0, 1.0) = 0.1;
uniform float sway_speed : hint_range(0.0, 5.0) = 1.0;
uniform float sway_frequency : hint_range(0.0, 10.0) = 3.0;

void vertex() {
    // Sample the gradient texture using UV coordinates
    vec4 gradient_color = texture(gradient_texture, VERTEX.yz);
    float influence = 1.0 - gradient_color.r; // Assume gradient is grayscale, so use the red channel

    // Calculate sway with influence from gradient
    float sway = sin(VERTEX.z * sway_frequency + TIME * sway_speed) * sway_strength * influence;
    VERTEX.x += sway;
}

void fragment() {
    vec4 albedo_color = texture(albedo_texture, UV);
    ALBEDO = albedo_color.rgb;
    ALPHA = albedo_color.a;
}
Tags
3d, pixel, sway
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.

More from ReVybes

Perfect Retro Pixel Shader – Godot 4

Related shaders

Billboard Sprite3D Sway (Godot 4.0)

Simple Sway

2D wind sway

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments