Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shader_type spatial;
- uniform int count = 3;
- float rand(vec2 n) {
- return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
- }
- float noise(vec2 n) {
- vec2 d = vec2(0.0, 1.0);
- vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
- return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
- }
- float fbm(vec2 n) {
- float total = 0.0, amplitude = 1.0;
- for (int i = 0; i < 7; i++) {
- total += noise(n) * amplitude;
- n += n;
- amplitude *= 0.5;
- }
- return total;
- }
- float get_line(vec2 t, vec2 uv){
- float ycenter = mix( 0.5, 0.25 + 0.25*fbm( t ), uv.x*4.0);
- float diff = abs(uv.y - ycenter);
- float c = 1.0 - mix(0.0,1.0,diff*20.0);
- return c;
- }
- void fragment( )
- {
- vec4 col = vec4(0,0,0,1);
- vec2 uv = UV;
- float c = 0.;
- for(int i=1; i <=count; i++){
- vec2 t = uv * vec2(float(i) * 2.0,1.0) - TIME*(3.0+float(i)/2.0);
- float tmp_c = get_line(t, uv);
- if (tmp_c > c){
- c = tmp_c;
- }
- }
- col = vec4(c,c,c*1.2,1.0)*2.0;
- col.a = c;
- ALBEDO = col.rgb;
- ALPHA = col.a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement