ile-de-test/addons/waterways/shaders/filters/normal_to_flow_filter.gdshader

16 lines
385 B
Text
Raw Normal View History

2023-10-05 18:02:23 +00:00
shader_type canvas_item;
uniform float size = 512.0;
uniform sampler2D input_texture;
vec3 nm2flow(vec2 x) {
x -= vec2(0.5);
vec3 rv = vec3(sign(x.x)*vec2(-x.y, x.x), -1.0);
return normalize(rv);
}
void fragment() {
vec4 texture_sample = textureLod(input_texture, UV, 0.0);
vec3 flowmap = nm2flow(texture_sample.xy) * 0.5 + 0.5;
COLOR = vec4(flowmap, 1.0);
}