zalo / libfive-unity

A CSharp wrapper for libfive with Unity bindings
Mozilla Public License 2.0
103 stars 15 forks source link

New to libfive, what's the scoop? #2

Closed MostHated closed 3 years ago

MostHated commented 4 years ago

Hey there, This is the first I have heard of this library. It looks rather neat. I can't help but notice that right off the bat you mentioned it was amazing, do you mind sharing some info/background about what makes it so amazing? I noticed that it seems relatively easy to create interesting geometry, but is that the only purpose/benefit of using it, or does it have other beneficial qualities/features/performance benefits over the built-in capabilities of Unity that makes it worthwhile?

I definitely appreciate your time! Thanks, -MH

andybak commented 4 years ago

Hard to answer this without knowing a bit about your current understanding of the topic.

Are you familiar with CSG/boolean modelling?

Do you know anything about SDFs (signed distance fields)?

Have you come across marching cubes or similar algorithms?

Have you done much procedural generation of geometry?

The short answer is "libfive uses a much better way of turning SDFs into meshes that preserves clear, sharp edges" but that might not mean much to you if you're new to the whole topic.

If you know about CSG but not about SDF then a better answer might be "libfive gives a really fast clean way of constructing CSG meshes from a bunch of primitives". That's a bit less specific but might be easier to understand if you haven't messed around with SDFs before.

Take a look at this:

http://longbunnylabs.com/mudbun/

That asset can use dual contouring to make clean meshes and in that mode works similarly to libfive.

MostHated commented 4 years ago

Thanks for the reply, I appreciate it.

I have been a systems/infrastructure guy for about 15 years, so I got a bit of a late start into actual development (as opposed to just writing system automation scripts and similar things) as I only relatively recently (two or three years ago) decided to finally try out Adderall. I missed out on so many years of concentration, lol. That said, I have been trying to catch up, working my way through the things I have always wished I could do all those years, which has me touching upon bits and pieces of the things you have mentioned more and more.

While not intimately familiar, I have worked with SDF between Houdini and Unity, but only to the extent of being able to generate point cloud data when learning to use Houdini and the VFX graph to make this.

I am familiar with the basics and overall concepts of boolean modeling, such as taking a target object and removing geometry based on the intersecting space from another. Though, it has not been something I have actually had the need or opportunity to actually use much in many projects.

While I don't really have any sort of end-goal, I just love learning and trying out new things. high up on my list of "what next?" is digging deeper into different forms of proceduralism. Over the last year and a half or so I have been familiarizing myself with ECS/Jobs, and trying to keep up with the advancements in the DOTS ecosystem as leveraging those technologies seems to be key in doing some of the neatest things. Having come across and playing around with packages such as Unitys newer mesh api and seeing a few ray-marching videos and examples has definitely piqued my interest.

Unfortunately, I am not quite up to that level yet. Primarily due to the fact that once highschool was over, the most math I have had to deal with day-to-day is calculating how much I should leave as a tip. I realize that I probably have a long way to go before I can properly utilize, and possibly even understand packages such as this, but I have been trying to refamiliarize myself as I go along. The more I learn about these types of things, the more motivated I am to try my hand at it.

Thanks for the link, I stumbled upon that early this year when I started using Houdini and was doing some research on SDF and related things but had completely forgotten about it. I didn't realize there was a free trial until just now, so I definitely will be checking it out. 👍

(My apologies for the length of my reply, I didn't realize just how long it ended up being until I scrolled up to look at the link again.)

andybak commented 4 years ago

(apologoes to the repo owner for using this as a chat. I'll stop after this I promise)

Sounds like we share a few interests in common (and a shared problem with focus and concentration!). You might be interested in taking a look at my project which is procgen/geometry related. I'm keen to find users/collaborators. https://github.com/IxxyXR/polyhydra-upm

If you want to chat further my Twitter username is the name as my Github.

zalo commented 3 years ago

As you've probably gathered, libfive takes structured trees of 3D Distance Field operations and turns them into high-quality meshes. This evaluation of CSG operations in implicit-space, and then the creation of the mesh as the final step allows for higher speed and robustness.

libfive, in particular, is unique for the high-quality and sharp-edge reproduction of these meshes. Naive marching cubes implementations often leave blurry or messy corners.

Inigo Quilez's technical blog and examples on Shadertoy are the primary source of truth for the whole Signed Distance Field community.

Converting distance fields to meshes (rather than raymarching them directly) allows for faster rendering and use in other programs and 3D printing.