Created
May 4, 2020 14:44
-
-
Save jimmyjonezz/734dac5e4082bf945efe6959b1fba576 to your computer and use it in GitHub Desktop.
This file contains 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; | |
uniform vec3 color = vec3(0.35, 0.48, 0.95); | |
uniform int OCTAVES = 4; | |
float randi(vec2 coord){ | |
return fract(sin(dot(coord, vec2(56,78)) * 1000.0) * 1000.0); } | |
float noise(vec2 coord){ | |
vec2 i = floor(coord); | |
vec2 f = fract(coord); | |
float a = randi(i); | |
float b = randi(i + vec2(1.0, 0.0)); | |
float c = randi(i + vec2(0.0, 1.0)); | |
float d = randi(i + vec2(1.0, 1.0)); | |
vec2 cubic = f * f * (3.0 - 2.0 * f); | |
return mix(a, b, cubic.x) + (c - a) * cubic.y * (1.0 - cubic.x) + (d - b) * cubic.x * cubic.y; | |
} | |
float fbm(vec2 coord){ | |
float value = 0.0; | |
float scale = 0.5; | |
for(int i = 0; i < OCTAVES; i++){ | |
value += noise(coord) * scale; | |
coord *= 2.0; scale *= 0.5; } | |
return value; | |
} | |
void fragment(){ | |
vec2 coord = UV * 20.0; | |
vec2 motion = vec2(fbm(coord + vec2(TIME * -0.5, TIME * 0.5))); | |
float final = fbm(coord + motion); | |
COLOR = vec4(color, final * 0.5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment