More 2021-07-27-procedural-meshes rambling

This commit is contained in:
Chris Hodapp 2021-08-08 09:13:23 -04:00
parent 99a68b246f
commit 68e1b3c3a2

View File

@ -38,14 +38,23 @@ way to learn things in a new language. (I think it's similar to
I've also played around in 3D graphics, particularly raytracing, since I've also played around in 3D graphics, particularly raytracing, since
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 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 from 1999]] are mostly garbage. POV-Ray is probably what led me to
learn about things like implicit surfaces, parametric surfaces, and learn about things like procedural geometry and textures, especially
procedural geometry - its scene language is full of constructs for implicit surfaces and parametric surfaces, as its scene language is
that. Naturally, this led me to wonder how I might extend Context full of constructs for that. The images below are some of my POV-Ray
Free's model to work more generally with 3D geometry, and let me use scenes from way back in 2005, with the first two done completely with
it to produce procedural geometry. its implicit surfaces.
# TODO: Link to some POV-Ray scenes here with implicit & parametric {{< gallery >}}
# surfaces? {{< figure page="images" resource="portfolio/2005-07-05-spiral-isosurface2.jpg">}}
{{< figure page="images" resource="portfolio/2005-07-08-vaguely-celtic-metalwork.jpg">}}
{{< figure page="images" resource="portfolio/2005-08-23-shear6.jpg">}}
{{< /gallery >}}
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.
# ../2011-02-07-blender-from-a-recovering-pov-ray-user ?
[[http://structuresynth.sourceforge.net/index.php][Structure Synth]] of course already exists, and is a straightforward [[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 generalization of Context Free's model to 3D (thank you to Mikael
@ -69,9 +78,9 @@ was trying to work with it:
{{< figure page="images" resource="placeholder/appleseed_spiral_thing.jpg">}} {{< figure page="images" resource="placeholder/appleseed_spiral_thing.jpg">}}
{{< /gallery >}} {{< /gallery >}}
That's a "Hello World" tier design I try out when something gives me That's a "Hello World"-tier design I try out when something gives me
geometric transforms and recursion. The first image (the Blender one) geometric transforms and recursion. The first image (the Blender one)
snhould show the bits of unconnected and half-connected and should show the bits of unconnected and half-connected and
self-intersecting geometry - that is what I wanted to work around. self-intersecting geometry - that is what I wanted to work around.
You can look at this and say, "That really makes no difference, and You can look at this and say, "That really makes no difference, and
Structure Synth is capable of anything you /practically/ want to Structure Synth is capable of anything you /practically/ want to
@ -98,27 +107,49 @@ this geometry is even fairly mild. This really isn't surprising, as
tools like this were made for practical applications in CAD, and not tools like this were made for practical applications in CAD, and not
so much for my silly explorations in generative art. so much for my silly explorations in generative art.
But wait! Implicit surfaces handle almost all of this well! (Or call But wait! *Implicit surfaces* handle almost all of this well! (Or see
them one of the many related-but-not-identical things around this, any of the related-but-not-identical things around this, e.g. [[https://en.wikipedia.org/wiki/Function_representation][F-Reps]]
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...) They express or distance bounds or distance fields or [[https://en.wikipedia.org/wiki/Signed_distance_function][SDFs]] or isosurfaces...) They
[[https://en.wikipedia.org/wiki/Constructive_solid_geometry][CSG]] operations, they can be rendered directly on the GPU via shaders, express [[https://en.wikipedia.org/wiki/Constructive_solid_geometry][CSG]] operations, they can be rendered directly on the GPU via
operations like blending shapes or twisting them are easy... for more shaders, operations like blending shapes or twisting them are easy,
on this, see [[http://blog.hvidtfeldts.net/][Syntopia]] again, or nearly anything by [[https://iquilezles.org/][Inigo Quilez]], or and when generalized to things like distance functions, they can be
look up raymarching and sphere tracing, or see [[https://ntopology.com/][nTopology]], or Matt used to render shapes like fractals that are infinitely complex and
lack an analytical formula for the surface, like the [[https://www.skytopia.com/project/fractal/mandelbulb.html][Mandelbulb]]. 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 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. wonderfully elegant, and I'll probably have many other posts on them.
(TODO: Link to my CS6460 stuff) (TODO: Link to my CS6460 stuff)
However, there is one big issue: turning implicit surfaces to good Many renderers can render implicit surfaces directly. POV-Ray is one
meshes for rendering /is a huge pain/. While many renderers can of them - see [[https://www.povray.org/documentation/view/3.6.1/300/][Isosurface Object]] which a few of my examples above
handle implicit surfaces directly, Blender's renderers cannot. I will use. The appleseed renderer can sort of do it via a [[https://github.com/appleseedhq/appleseed/blob/master/sandbox/examples/cpp/distancefieldobject/distancefieldobject.cpp][custom object via
have other posts going into more detail on this subject, but for now, a plugin]]. [[https://www.shadertoy.com/][Shadertoy]] is also full of user-created examples of ad-hoc
take it on faith. If you don't believe me, believe Matt Keeter in realtime rendering of implicit surfaces, mostly in the form of sphere
[[https://www.mattkeeter.com/research/mpr/keeter_mpr20.pdf][his paper]] when he says in a rather understated way, "Having implemented tracers, done completely in [[https://en.wikipedia.org/wiki/OpenGL_Shading_Language][GLSL]]. Keeter's work on [[https://www.mattkeeter.com/research/mpr/][MPR]] is all about
many of these algorithms, we've found it extremely difficult to make realtime rendering of this sort in a much more scalable way.
them robust." This is why I did not try to use implicit surfaces for
this project. # TODO: Why not move the spiral isosurface from POV-Ray here, and give
(TODO: Make those posts.) # its formula and explain a little? Or - should this be for another
# post?
Many renderers don't handle implicit surfaces at all. Blender's
renderers, [[https://www.cycles-renderer.org/][Cycles]] and [[https://docs.blender.org/manual/en/latest/render/eevee/introduction.html][Eevee]], are among them. Using implicit surfaces
there means converting them to a form of geometry that Blender /can/
handle - typically a polygon mesh.
This leads to a pretty big issue: turning implicit surfaces to good
meshes for rendering /is a huge pain/. If you don't believe me,
believe Matt Keeter in [[https://www.mattkeeter.com/research/mpr/keeter_mpr20.pdf][his paper]] when he says, "There is significant
literature on converting implicit surfaces into meshes for
visualization. Having implemented many of these algorithms, we've
found it extremely difficult to make them robust." I'd love to tell
you that I saw this advice before wasting my time trying to turn
implicit surfaces to meshes, first with various libraries and then
with ad-hoc conversions and optimizations of my own, but I didn't. I
may have other posts talking about my failures here, but for now, take
it on faith that this is why I gave up trying to use implicit surfaces
for this project. (TODO: Make those posts.)
With these limitations in mind, around 2018 June I had started jotting With these limitations in mind, around 2018 June I had started jotting
some ideas down. The gist is that I wanted to create some ideas down. The gist is that I wanted to create