Raytraced SDF Metaballs for infinite resolution on meta-surfaces
Something I was thinking about and couldn't get out of my head was the possibility of adding the ability for Cycles to use a metaball's SDF to calculate "infinite resolution," of a metaball at render time.
I don't know Cycles internal code, and have a limited knowledge of SDF raytracing, but from my understanding the metaball pipeline goes something like: Metaball properties > Math > Calculate points for mesh > Mesh > Raytrace by calculating ray intersection with mesh.
What if instead at render time we simply used the SDF to calculate the position of the ray intersections? It would not only provide infinite resolution for meta-surfaces, but it might even be faster considering the pipeline would be simplified down to: Metaball properties > Raytrace by calculating ray intersection using SDF.
7 Comments
SDF (signed distance fields) with ray marching require a completely different architecture from ray training . I have been experimenting with it myself and find that they can be combined but easily. The way metaballs etc work in blender and others is by generating a (temporary) mesh that represents the zero-isosurface of the SDF. Then, not the SDF but the representing mesh is sent to the renderer.
* @Ivo * I've never heard of raytraining before, can you link to some resources about it? I can't seem to find anything by googling but really curious to look into it.
* @Zach Hixson * Curious typo that is... I obviously meant ray tracing - sorry for that.
* @Ivo * And did you mean "Combined, but not easily"?
The way I envisioned it working was flags could be set on the BVH nodes which contain objects that require raymarching, so the majority of the raytracing could be done like normal, but only specific BVH nodes would switch to raymarching, and continue from the intersection point.
I'd be interested to do some research into this myself as I don't have much experience with programming raytracers, so it's something I've wanted to try for awhile
* @Zach Hixson * Well, give it a go. Clone the git repository and take a look at the source code. I believe that the recently added volume-objects already use some form of SDF so it could be a nice starting point.
I've seen pure GPU implementation of raymarching (this example is Unity IIRC). Metaballs should be possible, too. I think this guy even got it to work with arbitrary fractal surfaces.
* @Josephbburg * Yeah, it's a pretty simple process, and most of this is implemented in Cycles already as it's required for raytracing, so it shouldn't be that massive of a feature to add. Again though, I haven't looked much into Cycles code myself, so maybe it would be difficult.