shader_type spatial; uniform sampler2D base_texture: hint_albedo; uniform sampler2D flowmap; uniform vec4 color: hint_color; uniform float flow_speed = 0.1; uniform float flow_intensity = 0.1; void fragment(){ // Flow vec2 flow = texture(flowmap, UV).xy; flow = (flow - 0.5) * 2.0; // We use two phases which are exactly halfway offset from one another, and we blend between those. // That way, the animation seems to go on infinitely (similar to a Shepard tone) float time_phase_1 = fract(TIME * flow_speed); float time_phase_2 = fract(time_phase_1 + 0.5); float flow_mix = abs((time_phase_1 - 0.5) * 2.0); // Read the color values based on the offsets from the flowmap samples and mix them vec3 base_tex_1 = texture(base_texture, UV + (flow * time_phase_1 * flow_intensity)).xyz; vec3 base_tex_2 = texture(base_texture, UV + (flow * time_phase_2 * flow_intensity)).xyz; vec3 base_tex_mix = mix(base_tex_1, base_tex_2, flow_mix); // Apply the custom color scaled by that previous greyscale sample vec3 final_color = (0.05 + base_tex_mix.x * 0.95) * color.xyz; ALBEDO = final_color; }