diff --git a/content/posts/2021-07-27-procedural-meshes/index.org b/content/posts/2021-07-27-procedural-meshes/index.org index 7d5b80f..5405f89 100644 --- a/content/posts/2021-07-27-procedural-meshes/index.org +++ b/content/posts/2021-07-27-procedural-meshes/index.org @@ -13,24 +13,40 @@ draft: true # (TODO: pictures will make this post make a *lot* more sense, and it # may need a lot of them) -Context Free is one of my favorite projects since I discovered it -about 2010. It's one I've written about before (TODO: link to my -posts), played around in (TODO: link to images), presented on, as well -as re-implemented myself in different ways (see: [[https://github.com/hodapp87/contextual][Contextual]]). That is -sometimes because I wanted to do something Context Free couldn't, such -as make it realtime and interactive, and sometimes because -implementing its system of recursive grammars and replacement rules -can be an excellent way to learn things in a new language. (I think -it's similar to [[https://en.wikipedia.org/wiki/L-system][L-systems]], but I haven't yet learned those very well.) +{{< load-photoswipe >}} + +[[https://www.contextfreeart.org/][Context Free]] is one of my favorite projects since I discovered it +about 2010. It's one I've [[../2011-08-29-context-free/][written about before]], played around in (see +some of the images below), presented on, as well as re-implemented +myself in different ways (see: [[https://github.com/hodapp87/contextual][Contextual]]). That is sometimes because +I wanted to do something Context Free couldn't, such as make it +realtime and interactive, and sometimes because implementing its +system of recursive grammars and replacement rules can be an excellent +way to learn things in a new language. (I think it's similar to +[[https://en.wikipedia.org/wiki/L-system][L-systems]], but I haven't yet learned those very well.) + +# TODO: Set captions? +{{< gallery >}} + {{< figure page="images" resource="placeholder/dream20191115b.jpg" caption="Something">}} + {{< figure page="images" resource="placeholder/2011-11-25-electron.jpg">}} + {{< figure page="images" resource="portfolio/2011-11-04-crystal1.jpg">}} + {{< figure page="images" resource="placeholder/2011-11-03-feather2.jpg">}} + {{< figure page="images" resource="placeholder/2011-11-03-feather1.jpg">}} + {{< figure page="images" resource="portfolio/2011-09-09-conch.jpg">}} +{{< /gallery >}} I've also played around in 3D graphics, particularly raytracing, since -about 1999 in PolyRay and POV-Ray. POV-Ray is probably what led me to +about 1999 in PolyRay and POV-Ray... though my [[../../images/portfolio/1999-12-22-table.jpg][few surviving]] [[../../images/portfolio/1999-12-21-moo.jpg][renders +from 1999]] are mostly garbage. POV-Ray is probably what led me to learn about things like implicit surfaces, parametric surfaces, and procedural geometry - its scene language is full of constructs for that. Naturally, this led me to wonder how I might extend Context Free's model to work more generally with 3D geometry, and let me use it to produce procedural geometry. +# TODO: Link to some POV-Ray scenes here with implicit & parametric +# surfaces? + [[http://structuresynth.sourceforge.net/index.php][Structure Synth]] of course already exists, and is a straightforward generalization of Context Free's model to 3D (thank you to Mikael Hvidtfeldt Christensen's blog [[http://blog.hvidtfeldts.net/][Syntopia]], another of my favorite things @@ -50,16 +66,16 @@ these, but I quickly ran into a problem: they were made for actual practical applications in CAD, not so much for my generative art, and they scaled quite poorly with the sort of recursion I was asking for. -Implicit surfaces (or one of the many -equivalent-except-for-when-it's-not names for this, e.g. F-Reps or -distance bounds or SDFs or isosurfaces) handle almost all of this -well! They express CSG (TODO: link to CSG) operations, they can be -rendered directly on the GPU via shaders, operations like blending +Implicit surfaces (or one of the many related-but-not-identical things +around this, e.g. [[https://en.wikipedia.org/wiki/Function_representation][F-Reps]] or distance bounds or [[https://en.wikipedia.org/wiki/Signed_distance_function][SDFs]] or isosurfaces) +handle almost all of this well! They express [[https://en.wikipedia.org/wiki/Constructive_solid_geometry][CSG]] operations, they can +be rendered directly on the GPU via shaders, operations like blending shapes or twisting them are easy... for more on this, see [[http://blog.hvidtfeldts.net/][Syntopia]] again, or nearly anything by [[https://iquilezles.org/][Inigo Quilez]], or look up raymarching and sphere tracing, or see [[https://ntopology.com/][nTopology]], or Matt Keeter's work with [[https://www.libfive.com/][libfive]] and [[https://www.mattkeeter.com/research/mpr/][MPR]]. They're pure magic, they're wonderfully elegant, and I'll -probably have many other posts on them. +probably have many other posts on them. (TODO: Link to my CS6460 +stuff) However, there is one big issue: turning implicit surfaces to good meshes for rendering /is a huge pain/, and while many renderers can @@ -79,8 +95,8 @@ self-intersection, no high-degree vertices, no triangles of extreme angles) - rather than attempting to patch up the mesh after its creation, or subdividing it to the necessary detail level. For something similar to what I mean (though I didn't have this in mind at -the start), consider the [[https://en.wikipedia.org/wiki/Marching_squares][marching squares]] algorithm, which is -guaranteed to produce closed, manifold meshes. +the start), consider the [[https://en.wikipedia.org/wiki/Marching_cubes][marching cubes]] algorithm, which is guaranteed +to produce closed, manifold meshes. (TODO: Illustrate this somehow) @@ -90,29 +106,30 @@ them at least) by way of inductive steps. My meandering path to implementing it went something like this: -- Write some very ad-hoc Python to generate a mesh of a parametric +- Wrote some very ad-hoc Python to generate a mesh of a parametric conversion of my annoying spiral isosurface from 2005 by breaking it into planar "slices" or "frames", which move along the geometry and then are connected together at corresponding vertices. (TODO: Add link to the automata_scratch repo, whatever it's renamed to) -- Explore [[https://github.com/thi-ng/geom][thi.ng/geom]] and pretty quickly give up - but in the process, - discover [[https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.8103][Parallel Transport Approach to Curve Framing]]. -- Implement that paper in Python, reusing the basic model from my +- Explored [[https://github.com/thi-ng/geom][thi.ng/geom]] and pretty quickly gave up - but in the + process, discovered [[https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.8103][Parallel Transport Approach to Curve Framing]]. +- Implemented that paper in Python, reusing the basic model from my prior code. (See [[https://github.com/Hodapp87/parallel_transport][parallel_transport]]) -- Again continue with this model, allowing more arbitrary operations +- Again continued with this model, allowing more arbitrary operations than parallel frame transport, eventually integrating most of what I wanted with the recursive grammars. (See [[https://github.com/Hodapp87/automata_scratch/tree/master/python_extrude_meshgen][automata_scratch/python_extrude_meshgen]]) -- Keep running into limitations in python_extrude_meshgen, and start +- Kept running into limitations in python_extrude_meshgen, and start [[https://github.com/Hodapp87/prosha][Prosha]] in Rust - partly as a redesign/rewrite to avoid these limitations, and partly because I just wanted to learn Rust. -- Realize that Rust is the wrong tool for the job, and rewrite *again* - in Python but with a rather different design and mindset. +- Realized that Rust is the wrong tool for the job, and rewrote + *again* in Python but with a rather different design and mindset. (this is, of course, ignoring many other tangents with things like shaders) -(TODO: Maybe split these off into sections for each one?) +(TODO: Maybe split these off into sections for each one? That'd make +explanations/pictures easier.) I put some serious effort into [[https://github.com/Hodapp87/prosha][Prosha]] and was conflicted on shelving the project indefinitely, but the issues didn't look easily solvable.