Log In  9    Cart #50802 | 2018-03-25 | Code ▽ | License: CC4-BY-NC-SA 9 It's a frosted 3D donut, drawn in 265 chars of Lua!

I'm including the code here, with spacing and indents for legibility (instead of minimizing chars like in the cart).

Variable meanings:
X/Y/Z: Current sample position (moves along a camera ray), +Y is up
I/J: Screenspace position
U/V/W: Ray direction (normalized)
C: Output color of the current ray
K: Raymarch iterator
Q: Distance to the unextruded torus on XZ plane
L: Shortest distance to the surface of the extruded 3D torus
A: Angular position of sample pos around the torus (0-1, repeating)

(Both distance values are signed: a negative distance means that a point is inside a shape)

 ```cls(2) ::_:: x=0 y=2 z=-3 i=rnd(112)+8 j=rnd(66)+40 u=i/128-.5 v=-(j/128) w=sqrt(1-u*u-v*v) c=2 for k=1,20 do q=sqrt(x*x+z*z)-1 l=sqrt(q*q+y*y)-.5 if (z>4 or y<-1) then break end if (l<.08) then a=t()/64+atan2(z,x) c=(-y*5-.3+sin(a*6)/4) break end x+=u*l y+=v*l z+=w*l end pset(i,j,max(c%16,1)) goto _ ```
P#50803 2018-03-25 14:12 ( Edited 2018-03-25 20:15)  Wow! I'm fiddling around with it right now, and it's quite interesting. I should be learning from you!

P#50808 2018-03-25 16:15 ( Edited 2018-03-25 20:15)