SHARE
TWEET

(Fix) Tear in SDF movement WIP

a guest Sep 22nd, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float get_floor(vec3 p) {
  2.     vec3 q = p; /* save input p */
  3.     float d = 1000.0; /* total distance */
  4.     for (int i=-1;i<=1;++i){
  5.         for(int j=-1;j<=1;++j){
  6.           float space = 6.;
  7.           float item = floor(abs(mod(p.z,0.)) / space);
  8.           item += abs(float(j)); /* offset cell index */
  9.  
  10.           p.y += sin(iTime + item * PI / 2.) * 4.0;
  11.           p.xz = mod(p.xz,space)-.5 * space;
  12.           p.xz += vec2(float(i), float(j)) * space; /* offset local coordinates */
  13.  
  14.           float displacement = sin(15. * p.x) * sin(15. * p.y) * sin(15. * p.z) * .04;
  15.           float floorBox = boxSDF(vec3(p.x,p.y + 3.,p.z), vec3(15.5, .2, 15.5));
  16.           //+ displacement;
  17.           float circleCut = sphereSDF(vec3(p.x,p.y + 3.,p.z),2.);
  18.  
  19.           float dd = max(floorBox,circleCut);
  20.           d = min(d, dd); /* keep track of total distance */
  21.           p = q; /* restore input p */
  22.         }
  23.     }
  24.     return d;
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top