Created
November 30, 2022 11:19
-
-
Save RPicster/f7da77bccaf930df2fcaca2c2be35ad0 to your computer and use it in GitHub Desktop.
Polar Coordinate Shader - Godot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| shader_type canvas_item; | |
| render_mode unshaded; | |
| uniform sampler2D image_texture; | |
| uniform sampler2D image_multiplier; | |
| uniform sampler2D image_add : hint_black; | |
| uniform sampler2D image_gradient_tint : hint_black; | |
| uniform float extra_power = 1.0; | |
| uniform float effect_scale = 1.0; | |
| uniform float effect_repeat = 2.0; | |
| uniform vec2 effect_center = vec2(0.5); | |
| uniform vec2 uv_mod = vec2(1.0); | |
| uniform vec2 scroll_speed = vec2(0.0); | |
| const float TAU = 6.2832; | |
| vec2 coordinates(vec2 uv, vec2 center, float scale, float repeat) { | |
| vec2 dir = uv - center; | |
| float radius = length(dir)*2.0; | |
| float angle = (atan(dir.x, dir.y) / TAU)+0.5; | |
| return vec2(angle*repeat, radius*scale); | |
| } | |
| void fragment(){ | |
| vec2 uv = uv_mod*coordinates(UV, effect_center, effect_scale, effect_repeat); | |
| vec4 image_tex = texture(image_texture, mod(uv+(TIME*scroll_speed), 1.0)); | |
| image_tex *= texture(image_multiplier, UV); | |
| image_tex += texture(image_add, UV); | |
| COLOR *= textureLod(image_gradient_tint, vec2(clamp(image_tex.r, 0.0, 1.0)*extra_power, 0.0), 1.0)*extra_power; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment