Last active
September 9, 2022 15:36
-
-
Save ianthehenry/318435900ccd1d7b1cb2f1ed1e12358d to your computer and use it in GitHub Desktop.
Bauble: hot air balloon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def bottom (+ -100 -50)) | |
(defn quantize [x y] | |
(x * y | round / y)) | |
(def envelope | |
(sphere 100 | |
| union :r 50 (cylinder :y 25 50 | move :y -100) | |
| scale | |
:y (ss p.y bottom 100 1 0.80) | |
:z (ss p.y bottom (+ bottom 75) 1 0.50) | |
| onion 0.1 | |
| subtract :r 1 (half-space :-y (+ bottom 7)) | |
| radial :y 18 (fn [$ i] | |
(resurface $ | |
(shade (hsv (/ p.y 100 | quantize 8) 1 1) | |
| rotate :x -0.75 | |
) | |
| scale :z (mod i 2 * 2 - 1))) | |
| color (* c (ss occlusion 0 0.75 0 1)) | |
| fresnel)) | |
(def flame | |
(cone :-y 50 403 | |
| union :r 10 (cone :y 31 148) | |
| bounded-offset 30 :threshold 10 | |
(perlin (- (* p [0.05 0.025 0.05]) [0 (* 5 t) 0])) | |
| color (+ (* [1 1 0.7] (ss p.y 0 243)) | |
(mix [1 0.25 0] [1 1 0] (- normal.y))) | |
| slow 0.25 | |
| move :y -72)) | |
(def basket | |
(box 50 | |
| onion 10 | |
| subtract :r 10 | |
(half-space :y (+ 29 (pow (p.xz / 15) 2 | sum))) | |
| offset (* 0.25 (+ | |
(cos (min (abs p.xz) * 3 + (step (sin (* 2 p.y)) 0 * pi/2)) | abs) | |
(sin (p.y * 1) | abs))) | |
| shade (hsv 0.10 0.54 0.88) | |
| union | |
(box [66 5 10] :r 5 | |
| move [0 (+ 48 (pow (p.x / 15) 2)) 55] | |
| rotate :y (- tau/8) | |
| mirror :x :z :r 10 | |
| rotate :y tau/8 | |
| shade [0.4 0.05 0.1] :gloss 3 :shine 0.5 | |
| fresnel))) | |
(union | |
(envelope | |
| color (+ c (* 0.1 [1 1 0] | |
(ss (distance p [0 bottom 0]) 0 150 1 0) | |
(perlin [(* 5 t) 0])))) | |
(flame | scale 0.1 | move :y bottom) | |
(basket | scale 0.2 | move :y (- bottom 40)) | |
| move :y 75) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment