Advertisement
Guest User

Untitled

a guest
Jul 30th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shader_type spatial;
  2. uniform int count = 3;
  3. float rand(vec2 n) {
  4.     return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
  5. }
  6.  
  7. float noise(vec2 n) {
  8.     vec2 d = vec2(0.0, 1.0);
  9.     vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
  10.     return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
  11. }
  12.  
  13. float fbm(vec2 n) {
  14.     float total = 0.0, amplitude = 1.0;
  15.     for (int i = 0; i < 7; i++) {
  16.         total += noise(n) * amplitude;
  17.         n += n;
  18.         amplitude *= 0.5;
  19.     }
  20.     return total;
  21. }
  22.  
  23. float get_line(vec2 t, vec2 uv){
  24.    
  25.    float ycenter = mix( 0.5, 0.25 + 0.25*fbm( t ), uv.x*4.0);
  26.  
  27.     float diff = abs(uv.y - ycenter);
  28.     float c = 1.0 - mix(0.0,1.0,diff*20.0);
  29.     return c;
  30.    }
  31.  
  32. void fragment( )
  33. {
  34.     vec4 col = vec4(0,0,0,1);
  35.     vec2 uv = UV;
  36.    
  37.     float c = 0.;
  38.     for(int i=1; i <=count; i++){
  39.         vec2 t = uv * vec2(float(i) * 2.0,1.0) - TIME*(3.0+float(i)/2.0);
  40.         float tmp_c = get_line(t, uv);
  41.         if (tmp_c > c){
  42.             c = tmp_c;
  43.            }
  44.     }
  45.  
  46.     col = vec4(c,c,c*1.2,1.0)*2.0;
  47.     col.a = c;
  48.     ALBEDO = col.rgb;
  49.     ALPHA = col.a;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement