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
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.
learn about things like procedural geometry and textures, especially
implicit surfaces and parametric surfaces, as its scene language is
full of constructs for that. The images below are some of my POV-Ray
scenes from way back in 2005, with the first two done completely with
its implicit surfaces.
# TODO: Link to some POV-Ray scenes here with implicit & parametric
# surfaces?
{{< gallery >}}
{{< 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
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">}}
{{< /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)
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.
You can look at this and say, "That really makes no difference, and
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
so much for my silly explorations in generative art.
But wait! Implicit surfaces handle almost all of this well! (Or call
them 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...) 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
But wait! *Implicit surfaces* handle almost all of this well! (Or see
any of the related-but-not-identical things around this, e.g. [[https://en.wikipedia.org/wiki/Function_representation][F-Reps]]
or distance bounds or distance fields or [[https://en.wikipedia.org/wiki/Signed_distance_function][SDFs]] or isosurfaces...) 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,
and when generalized to things like distance functions, they can be
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
wonderfully elegant, and I'll 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/. While many renderers can
handle implicit surfaces directly, Blender's renderers cannot. I will
have other posts going into more detail on this subject, but for now,
take it on faith. If you don't believe me, believe Matt Keeter in
[[https://www.mattkeeter.com/research/mpr/keeter_mpr20.pdf][his paper]] when he says in a rather understated way, "Having implemented
many of these algorithms, we've found it extremely difficult to make
them robust." This is why I did not try to use implicit surfaces for
this project.
(TODO: Make those posts.)
Many renderers can render implicit surfaces directly. POV-Ray is one
of them - see [[https://www.povray.org/documentation/view/3.6.1/300/][Isosurface Object]] which a few of my examples above
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
a plugin]]. [[https://www.shadertoy.com/][Shadertoy]] is also full of user-created examples of ad-hoc
realtime rendering of implicit surfaces, mostly in the form of sphere
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
realtime rendering of this sort in a much more scalable way.
# TODO: Why not move the spiral isosurface from POV-Ray here, and give
# 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
some ideas down. The gist is that I wanted to create