Guest User

G'MIC Code For 3D Tunnel Animation

a guest
Sep 2nd, 2025
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.22 KB | Source Code | 0 0
  1. tunnel3d :
  2.  
  3.   # Generate random 3D coordinates for tunnel center.
  4.   8,1,1,2,"f = sin(2*pi*x/(w-1)); 2.5*f*[g,g]" r. 64,1,1,2,5 b. x,3,2 => coords
  5.  
  6.   # Create 3D tunnel mesh.
  7.   +r[coords] {2*w#$coords},1,1,100%,0,2 s. c store[-2,-1] _X,_Y
  8.   curve3d "begin(X = get('_X',2*w#$coords)); X[t]",\
  9.           "begin(Y = get('_Y',2*w#$coords)); Y[t]",\
  10.           t,1.25,{2*w#$coords},0,{2*w#$coords-1},16 rv3d.
  11.   l. { # Set colors and opacities
  12.     s3d
  13.     1,100%,1,3,"xor(int(y/16),y)%2?[ 255,0,y/1000 ]:[ 255,255,255 - y/1000 ]" permute. cyzx y. rv[-3,-1] rm.
  14.     f. "y<h-32?1:0"
  15.     a y
  16.   } => mesh3d
  17.  
  18.   # Display animation.
  19.   nbf=200
  20.   r[coords] {coords,w+1},1,1,2,0,2
  21.   repeat $nbf { f=$>
  22.     e[] "\r  > Frame "{$f+1}/$nbf
  23.     cx,cy,cz:="cz = lerp(0,w#$coords - 1,$>/$nbf);
  24.               cx = i(#$coords,cz,0,0,0,2);
  25.               cy = i(#$coords,cz,0,0,1,2);
  26.               [ cx,cy,cz ]"
  27.     ++3d[mesh3d] {-[$cx,$cy,$cz]}
  28.     r3d. 0,0,1,{180*cos(2*pi*$>/$nbf)}
  29.     600,600,1,3 j3d. ..,50%,50%,-500,1,4,0,0,500
  30.     600,600,1,3 j3d. ...,50%,50%,-500,1,2,0,0,500 g. xy,1 a[-2,-1] c norm. !=. 0 b. 1 n. 0,1
  31.     100%,100%,1,3 j... .,0,0,0,0,1,..
  32.     rm[-4,-2,-1]
  33.     w.
  34.   }
  35.   k[2--2] a z n 0,255 contrast 20 s z rs 50%
  36.  
Tags: gmic
Advertisement
Add Comment
Please, Sign In to add comment