[gd_resource type="ShaderMaterial" load_steps=4 format=2] [ext_resource path="res://Resources/gas_planet_flowmap.png" type="Texture" id=1] [ext_resource path="res://Resources/gas_planet_base.png" type="Texture" id=2] [sub_resource type="Shader" id=14] resource_local_to_scene = true code = "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; } " [resource] shader = SubResource( 14 ) shader_param/color = Color( 1, 0.890196, 0.172549, 1 ) shader_param/flow_speed = 0.2 shader_param/flow_intensity = 0.8 shader_param/base_texture = ExtResource( 2 ) shader_param/flowmap = ExtResource( 1 )