This repository contains code and data to render a video using PBRT! It was done at Recurse Center by Caroline Lin and Andy Chu.
We prototyped the geometry with NumPy and matplotlib, and then rendered it with PBRT.
10 second video of a Hyperdodecahedron in a Bathroom (2.8 MB) (mirror)
$ ./count.sh code # an overview of relevant code / data
- ~900 lines of our own Python code
- ~200 lines in schlafli_interpreter.py from
aruth2
- Libraries used
- NumPy for linear algebra
- SciPy for the convex hull algorithm
- matplotlib for plotting the prototypes
- Tools used:
- PBRT for rendering
- ImageMagick for resizing frames
- ffmpeg for encoding frames to video
- MeshLab (a GUI tool) for combining the polytope with the bathroom scene
- ~500 lines of shell scripts (more motivation for Oil shell)
- To coordinate Python code and the tools above
- To render across 3 machines
- Rendering time: 4-8 hours on 33 cores/66 hyperthreads across 3 Heap machines
- mod-sharding with shell scripts!
ssh
,rsync
to distribute inputs and collect outputsxargs -P
for resizing frames in parallel
- ~5800 lines of textual PBRT description for bathroom
- 19 MB geometry
- 14 MB textures
- 21 MB blend file?
- Sky environment map (imgtool)
- 4D Toys, Miegakure
- Bathsheba Grossman -- making mathematical objects real!
Stuff Andy was fascinated by 15+ years ago!
- HyperSpace Polytope Slicer (not sure if the Java Applet still works)
- Russell Towle's 4D Star Polytope Animations
- Use schlafli_interpreter.py to generate a regular polytope. It takes as
input a Schlafli symbol -- e.g.
{5,3,3}
for the hyperdodecahedron aka 120-cell -- and generates a list of vertices, edges, faces, hyperfaces, etc.- The algorithm is recursive, and the base case of the recursion is dimension 1. So you make 4 calls to get to dimension 4.
- Intersect the edges of the polytope with a hyperplane (a 3D subset of 4D), which gives you a set of 3D points.
- Draw the convex hull of these points, which gives you triangles.
- Render the triangles somehow. We used both matplotlib's 3d facilities (mplot3d) and PBRT.
- Animate over different hyperplanes. Take the min and max along the w axis and that will give you non-empty slices. Now you can "see" the 4D polytope using time as the 4th dimension.
Also:
- Rotate the camera.
- Rotate the polytope. TODO: This can be done in different ways, and which yields surprisingly different 3D animations!
Original comment: https://news.ycombinator.com/item?id=17687033
- Export a
.pbrt
scene description and.ply
mesh per frame. - Distribute code, data, and configuration to 3 machines with rsync.
- Render to PNG with PBRT running under tmux (so we don't lose the sessions).
- Copy frames back with rsync.
- Resize them with ImageMagick.
- Use ffmpeg to create an
.mp4
video out of the frames.
- Geometry
- Schlafli symbol representation of polytopes in arbitrary dimensions.
- v-polytope vs. h-polytope
- Convex Hull gives you the h-polytope from the v-polytope (roughly).
- Linear Algebra:
- for line segment-plane intersection (this generalized from 3D to 4D easily, so we didn't need to do anything special)
- rotations in 3D and 4D
- Raytracing -- tuning the sample and size parameters
- File formats
- PLY mesh format
- EXR image format
- Tools
- matplotlib: mplot3d and animations
- ipython3 (hadn't used it before)
- More polytopes in more scenes
- Automation could be improved / more foolproof. Reduce manual work.
- Rotation about different axes (in 4D too). Look at the Polytope slicer applet again.
Maybe:
- Interactive polytopes in the browser (look at existing implementations)
- Android filament: real-time rendering?
Future Research:
- How does the Schlafli generator work, exactly?
- How does Convex Hull work? SciPy uses http://www.qhull.org .
- How to obtain triangles for star polytopes? Taking the Convex hull won't work in this case.
contemporary-bathroom
scene from http://pbrt.org/scenes-v3.html
Scene thanks to Mareck. CC-Zero (public domain) license. "contemporary_china" texture used for wallpaper thanks to Adam Charlts; texture contrast was increased for the render. "American_walnut_pxr128" wood texture courtesy Pixar Animation Studios, CC-BY license. Abstract print seen in mirror based on a smoke photograph by Vanessa Pike-Russell, CC-BY license; the photo was inverted and contrast was adjusted for rendering. Hurricane image used for photo on wall courtesy NASA Goddard Space Flight Center, CC-BY license.
aruth2
for schlafli_interpreter.py