Advertisement
Guest User

Untitled

a guest
May 27th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shader_type canvas_item;
  2.  
  3. uniform vec3 color = vec3(1,1,1);
  4. uniform int OCTAVES = 8;
  5. float rand(vec2 coord){
  6.     return fract(sin(dot(coord, vec2(56,78))*1000.0)* 1000.0);
  7. }
  8. float noise(vec2 coord){
  9.     vec2 i = floor(coord);
  10.     vec2 f = fract(coord);
  11.    
  12.     float a = rand(i);
  13.     float b = rand(i + vec2(1.0, 0.0));
  14.     float c = rand(i + vec2(0.0, 1.0));
  15.     float d = rand(i + vec2(1.0, 1.0));
  16.    
  17.     vec2 cubic = f * f * (3.0 - 2.0 * f);
  18.    
  19.     return mix(a, b, cubic.x) + (c - a) * cubic.y * (1.0 - cubic.x) + (d - b) * cubic.x * cubic.y;
  20. }
  21.  
  22. float fbm(vec2 coord){  //fractal brownian motion
  23.     float value = 0.0;
  24.     float scale = 0.5;
  25.    
  26.     for(int i = 0; i < OCTAVES; i++){
  27.         value += noise(coord) * scale;
  28.         coord *= 2.0;
  29.         scale *= 0.5;
  30.     }
  31.     return value;
  32. }
  33.  
  34. void fragment(){
  35.     vec2 coord = UV * 30.0;
  36.    
  37.     vec2 motion = vec2(fbm(coord + vec2(TIME * .5 ,TIME * -0.6)));
  38.    
  39.     float final = fbm(coord + motion);
  40.    
  41.     COLOR = vec4(color, final * .3);
  42.    
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement