Advertisement
karpik

random scatter in torus

Nov 22nd, 2020
1,830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float hash( vec2 p ) {
  2.     float h = dot(p,vec2(127.1,311.7));
  3.     return fract(sin(h)*43758.5453123);
  4. }
  5.  
  6. vec3 randTorScatter(vec4 tex_pos){
  7.     vec2 tor_param = vec2(cut_radius,tor_in_radius);
  8.  
  9.     float u = hash(vUV.st + tex_pos.xw/1000. + u_time);
  10.     float x1 = hash(vUV.st + tex_pos.yx+ u_time)*2.-1.;
  11.     float x2 = hash(vUV.st + tex_pos.xz+ u_time)*2.-1.;
  12.     float x3 = hash(vUV.st + tex_pos.xw+ u_time)*2.-1.;
  13.  
  14.     float mag = sqrt(x1*x1 + x2*x2 + x3*x3);
  15.     x1 /= mag; x2 /= mag; x3 /= mag;
  16.  
  17.     float c = sqrt(u)*tor_param.y*0.2;
  18.  
  19.     float angle = hash(vUV.st + tex_pos.xx+ u_time);
  20.     float x_big = tor_param.x*sin(angle*2*PI)*1.1;
  21.     float z_big = tor_param.x*cos(angle*2*PI)*1.1;
  22.  
  23.     return vec3(x1*c + x_big, x2*c , x3*c+ z_big);
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement