Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. advectOnGPU = gpu.createKernel(function (q: number[], u_x: number[], u_y: number[], u_z: number[], dt: number) {
  2. let z = this.thread.x % 15;
  3. let y = Math.floor(this.thread.x / 15) % 15;
  4. let x = Math.floor(this.thread.x / (15 * 15));
  5.  
  6. // Look at the vector (a,b,c) in self.u in position (x,y,z)
  7. let a = getWithClipping(u_x, x, y, z);
  8. let b = getWithClipping(u_y, x, y, z);
  9. let c = getWithClipping(u_z, x, y, z);
  10.  
  11. let norm = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) + Math.pow(c,2));
  12.  
  13. // origin_coords = (x,y,z) - dt*(u,v,w)
  14. return norm * trilinearlyInterpolate(q, x - dt * a, y - dt * b, z - dt * c);
  15. }).setOutput([15 * 15 * 15]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement