ucg-3d/assets/shaders/flag.gdshader
2025-02-22 19:55:12 -05:00

36 lines
1 KiB
Text

shader_type spatial;
render_mode vertex_lighting, specular_disabled, cull_disabled;
uniform vec3 color_bright : source_color = vec3(1.0);
uniform vec3 color_dark : source_color = vec3(0.0);
uniform float pivot = 0.0;
uniform float pivot_speed = 1.0;
uniform float waves = 4.0;
uniform float wave_speed = 1.0;
uniform float wave_scale = 0.25;
void vertex() {
float body = (VERTEX.x) / 2.0;
VERTEX.z = sin(VERTEX.x * waves + TIME * wave_speed) * wave_scale * body;
float pivot_angle = cos(TIME * pivot_speed) * 0.1 * pivot;
mat2 rotation_matrix = mat2(
vec2(cos(pivot_angle), -sin(pivot_angle)),
vec2(sin(pivot_angle), cos(pivot_angle))
);
VERTEX.xz = rotation_matrix * VERTEX.xz;
float color_weight = sin(VERTEX.x * waves + TIME * wave_speed);
COLOR = vec4(mix(color_dark, color_bright, color_weight), 1.0);
//VERTEX.z += cos(time + body) * wave;
}
void fragment() {
ALBEDO = COLOR.rgb;
}
//void light() {
// Called for every pixel for every light affecting the material.
// Uncomment to replace the default light processing function with this one.
//}