Home Artists Posts Import Register

Content

Hi all!

We hope you're doing great!

After last month's intense work on the character creator, we were quite exhausted and wanted to take some time off. So of course I spent this time creating a custom soft body physics engine, LOL. :)

Before you get your hopes up - no, we still don't have a viable method for soft characters in YL2. But this work goes to show our commitment to getting fat simulation into the app as well as reducing clipping.

Read on to discover what we have tried so far and where we may go in the future.

Soft body dynamics

Soft body dynamics is a huge topic covering the behaviour of so called "soft bodies". Unlike "rigid bodies", soft bodies are able to deform (change their shape) to adapt to external influences. This makes them suitable for simulating cloth, balloons, jelly and rubber. Our hope was that we could try to adapt this technique to work on characters.

Previous work

Soft body physics is something we have touched on before. In our previous attempt at it, we were using a very fake method to achieve this effect:

https://gyazo.com/3da2ad8fe37942de4b6824285000265d

While it may look OK for this very specific scenario, this is not a "proper" soft body system, but rather a simple shader trick. Each vertex has no concept of its neighbors. This means if you were to texture the object, distortion would become very apparent:

(Surface is distorted by this method, which is easily noticeable on a textured surface. Open the link below.)

https://gyazo.com/52e523011ae7b9e43ce740daa1049a44

This method also doesn't handle multiple collisions very well, and can start clipping if too many objects interact with it:

(Multiple intersections not working as one would expect. Notice that the cube doesn't start to "take" until it has already clipped quite a bit through the object. Open the link below.)

https://gyazo.com/afdaf95b5a983de9dc6bf57a6b1d6f0c

It's also challenging to get this technique to work universally on characters. Since we're not relying on physics but tricks, it means we have to do tons of "fake" tweaking to make it look good, and even then there will probably undesirable behaviour in certain circumstances.

Soft body realtime simulation

"Real" soft body dynamics (not the shader trick above) is very computationally heavy, which is why it has previously been the domain of film and other pre-rendered media. However, with modern hardware and greatly parallelized algorithms (often times accelerated by GPUs) this is now becoming feasible to do in real time.

Existing libraries

There are already several external libraries handling soft body dynamics in Unity. Currently, "NVIDIA Flex" and "Obi Soft body" are the two main contenders, but there have been more. Sadly, because of the very difficult and niche nature of soft body physics, the market for it doesn't seem to be the most lucrative. Several soft body libraries have been made for Unity only to be discontinued from what I assume is lack of funding and consumer interest.

Problems with external libraries

While current soft body libraries are very featured and optimized, they have the huge draw back that they're not designed with changing objects in mind. You're only meant to initialize a soft body once and then put into the simulation. That is a big problem for us, since we need to be able to support inflation, which essentially alters the shape of the character and thus would require a reinitialization. While it is possible to reinitialize shapes in these libraries, you're not meant to do it frequently, more as a pre-computation step, so there is a significant hiccup each time you do so. Furthermore, the particles are reset in the process.

Obi also has the drawback that it runs on the CPU, and since we have a custom method for skinning that runs on the GPU, it means we would have to fetch data from the GPU, process it through Obi on CPU, and then push it back to GPU which is a very slow thing to do.

Custom solution

By creating a custom soft body physics engine, we are free to design it with inflation in mind from the very start, so we're able to change shapes in it with virtually no penalty.

For the past couple of months, I've been reading up like crazy on the latest research regarding real time soft body dynamics. After our intense work on the character creator, I felt like I was about to burst unless I got a chance try out my ideas. So with the "time off", it felt like a perfect opportunity to finally have a stab at it.

Custom soft body physics engine - Results

NOTE! We recommend opening the gyazo links below each image for the experience.

Essentially how a modern soft body physics engine work is through so called "constraints". Each constraint has a very specific purpose, such as limiting the distance between particles. The engine then just steps through all the particles, applies the constraints, while also applying things like gravity and checking for collisions.

The core engine and its constraints took about two weeks to implement. We started with simple balls, which is like the "hello world" of soft body physics, before moving on to more complex shapes.

Firstly, we just wanted to get gravity, velocity and collision going:

(A soft body, w/o any constraints, colliding with a sphere.)

https://gyazo.com/9a2afdf5dd28aa29e39074172aaf709c


(Same scenario, but this time a constraint limiting distance between neighboring vertices has been added to the simulation.)

https://gyazo.com/1639f28b9f205fe899758d2455367f02

Each collider shape had to be manually implemented into our custom physics engine. Sphere is the most simple shape, but eventually we managed to get all the math and algorithms to handle box colliders as well:

(Collision against box colliders.)

https://gyazo.com/03f647c02170c10487dbed0de0676f07

Next, we started working on more constraints to better approximate a soft body ball:

(A volume constraint trying to retain the object's initial volume by simulating internal pressure.)

https://gyazo.com/3835cea594b65f3f7ed1ff967b04e2bb


(Volume constraint being applied in slow motion.)

https://gyazo.com/da63011dce8caebfb5612aad1683ba44


(A bending constraint trying to retain each triangle's angle towards neighboring triangles.)

https://gyazo.com/9b78d74ba02b9a53130e498fbba71e99


(Volume constraint + bending constraint working together.)

https://gyazo.com/dec985065be55b2b46f89f142e31dad7

(Volume + bending in slow motion. Unfortunately an older iteration, but couldn't find a more recent recording.)

https://gyazo.com/e4e956cd225acb48fa89519d1e51ebf9


(Volume + bending later iteration performance test.)

https://gyazo.com/1b3e655a9fef6d1be9e11485d4168529


(First test of soft bodies interacting with eachother using sphere proxies.)

https://gyazo.com/ef8486937a92598ae8dc97a14c0fc198


(Later iteration on soft body vs soft body collision. Using different method to better approximate collision.)

https://gyazo.com/e22995dae8bfb66d567212441de79504


(Same as above but placed closer to eachother.)

https://gyazo.com/dc499e5339482d3c0472a41c8ef6152d


(Performance test.)

https://gyazo.com/1b898e6627efba1deab955108cfe7357

Results characters

By the time we had these results, we started feeling ready to try and apply these effects on a character.

(Smashing a cube into the butt cheeks of a simulated soft character.)

https://gyazo.com/bc0d8b2ce54bc385a613d0df6bc96d0a


(There is an invisible collider on her right side, in case you wonder why her right butt cheek is being affected.)

https://gyazo.com/635edbc90011b7aaaebf7ff668abcb4f


https://gyazo.com/6276c7ec78ed00497fbc7f0a271ea4ad


https://gyazo.com/2800aed047043296a22c710d55626f02

Despite the wobbliness, there's something fun and appealing about it. But it's definitely too wobbly to be viable, unfortunately. Of course we are able to make it less wobbly and make it match the skinned position more closely, however, that would also loose its soft behavior, which is why we wanted to do this in the frist place. And this is the core of the problem which we are facing with this tech - how do we actually combine soft body physics with an animated character?

Next, we tested the very scenario that made us go for our own custom implementation in the first place - inflation.

(Belly being inflated while an obstacle is in the way. Open the link below.)

https://gyazo.com/5f1e7665f6d64e4c6372fefe9c15764d


(Smashing a box into an inflated belly. Open the link below.)

https://gyazo.com/7a1ee621ed054765849277b1ffe9a8d8


(Inflated belly reacting to multiple collider influences, and correctly adjusting its shape w/o any clipping. Open the link below.)

https://gyazo.com/025ffe3a93817aa3d0476ea666a88d1d

Even though the tech is far too wobbly to be viable, it was still fun to see it fully realized in regards to inflation.

In case you weren't convinced about the problems with this tech - a final video:

(Things going crazy when trying to match a position. Open the link below.)

https://gyazo.com/b6d3d0d061b9502bb5bdc9329d3779ff

Again, the big question here is how we're supposed to combine this technique with animated characters, because as you can see here, when moving the character around, things get crazy, and it's not simple to solve by just tweaking variables. It may very well be that this tech is fundamentally unsuitable for this type of problem, which is not necessarily that surprising when thinking about it. Essentially what we're doing here is simulating a surface and an internal pressure. But that's not how bodies work. A body is made up of bones and flesh, not a surface inflated by air. So it's not surprising this doesn't behave as flesh and bones.

Perhaps another approach to solve this problem could be to use something like NVIDIA Flex does, with simulations of volume (voxelized shapes) rather than surface. However, then we're back to square one with how we're supposed to reinitialize a voxlized soft body to match a new shape (after inflation is applied) in a fast and efficient manner, not to mention how translation between the old voxelized shape and the new one is supposed to work in order to retain particle state.

Future

Perhaps a future approach could be something more like our original one, with using a simple constraint to offset vertices, but maybe there's a way to do it without causing so much distortion. Or perhaps there's a way to combine these two technologies into a new one.

While this soft body implementation didn't pan out the way we were hoping, I'm still happy I spent this time working on it. I needed to try out these ideas. Now when we know it isn't a viable path, we are free to explore other options. We've learnt a lot from implementing it.

We may also be able to salvage parts of it, or perhaps use it for other things than characters (like cloth).

Summary

This month, we took some time off working on the character editor, and instead went back to exploring soft body physics. We implemented our own soft body physics engine. While the results are quite fun, they aren't what we were looking for. It seems we will have to look elsewhere for a more viable method.

Enjoy your weekend!

Files

Gyazo

Take screenshots, screen GIFs, and full page captures you can instantly share now and search later. Get the free app for Windows, Mac, and mobile.

Comments

Mobius Scarf

A shame it doesn't work quite the way you need it to. The physics in some of those GIFs are really impressive! If only you could just use the soft physics for an outer layer over fattier parts of the body, while the rest would work based on more rigid physics or something, but I'm guessing that's too difficult to process and/or animate in real time. It's a cool experiment, though! Hopefully something usable comes out of it.

Anonymous

Is it possible to paint weights onto each vertex to control the level of simulation affecting each vertex? You might have a 'muscular' vertex weight array and a 'fatty' vertex weight array, then blend between the two as the various body parts are morphed.

yiffalicious

We actually do have weighting! You might have noticed that the legs, arms and head are not moving. When we first started testing this, we made a weighting like this: <a href="https://gyazo.com/0d6206c2eebd5e3df218fd1e8890dfd2" rel="nofollow noopener" target="_blank">https://gyazo.com/0d6206c2eebd5e3df218fd1e8890dfd2</a> <a href="https://gyazo.com/2b8e17f493832abee3bfad0f99984980" rel="nofollow noopener" target="_blank">https://gyazo.com/2b8e17f493832abee3bfad0f99984980</a> Unfortunately, this did not look any good at all when interacting with objects: <a href="https://gyazo.com/67895eaaacc6aeccd43f5ea983c09202" rel="nofollow noopener" target="_blank">https://gyazo.com/67895eaaacc6aeccd43f5ea983c09202</a> Furthermore, the base problem was still present. Sure, it's localized to a smaller area, but it's still there: <a href="https://gyazo.com/1b525be78b939fbf67bdd59c286a7266" rel="nofollow noopener" target="_blank">https://gyazo.com/1b525be78b939fbf67bdd59c286a7266</a> (Here, we're also playing around with a stiffness property, affecting just how closely it should try to match skinned position.) Instead, we finally ended up on a weighting like this: <a href="https://gyazo.com/a52019b74002b95b3818f319f188484e" rel="nofollow noopener" target="_blank">https://gyazo.com/a52019b74002b95b3818f319f188484e</a> <a href="https://gyazo.com/92c1d5706592b0538f31257f3eef7219" rel="nofollow noopener" target="_blank">https://gyazo.com/92c1d5706592b0538f31257f3eef7219</a> Still just a test of course, but it worked the best in regards to responding to objects. The fundamental problem is that the kind of weighting we need to do is not one on the surface, but rather one inside the actual body itself (volume). That way, bones would be fully weighted, and particles next to bones would also be quite stiff but would become more and more loose the farther away from bones they are. However, such an approach has its own set of problems, as explained in the main post.

RagnaBlade

My problem would be firmness, such as if a character is pregnant rather than simply inflated or fatty, the stomach would be more taught and rigid in that instance, while restricting certain positions as the stomach, in this case, would be more an object than just a morphed bit of geometry. a part of me wonders if there is a way (and I feel it be the reason behind your research into soft-body morphing) to make the 'muscle' layer of the model have variations on how taught or loose they are at any time? I hope I worded that adequately enough.

ryu lee

I guess you and Dogson are like 90% done?

tim yuki

oooh!!! I like this

Lionheart

as a fellow thats into cum inflation, this is what ive been waiting my whole life for &lt;3.

Anonymous

Even though it didn't fully work out, I'm glad that his provided such valuable information for you! You guys are really going above and beyond, and I can't wait to see what's next!

Dorvak

one day this is going to be released, and its going to be the greatest thing ever

BlackTH

Interesting! So, the whole body has to be soft for this to work? Can't, like, only the booty, belly and boobs be affected, so the rest of the body is rigid?

Dragonisser

Nope "When we first started testing this, we made a weighting like this: <a href="https://gyazo.com/0d6206c2eebd5e3df218fd1e8890dfd2" rel="nofollow noopener" target="_blank">https://gyazo.com/0d6206c2eebd5e3df218fd1e8890dfd2</a> <a href="https://gyazo.com/2b8e17f493832abee3bfad0f99984980" rel="nofollow noopener" target="_blank">https://gyazo.com/2b8e17f493832abee3bfad0f99984980</a> Unfortunately, this did not look any good at all when interacting with objects: <a href="https://gyazo.com/67895eaaacc6aeccd43f5ea983c09202" rel="nofollow noopener" target="_blank">https://gyazo.com/67895eaaacc6aeccd43f5ea983c09202</a> "

Craket

Wow, you guys need to chill out. lol

Vandorbelt

I almost wonder if you might be able to create a more realistic fat deformation by overlaying the "fat" model over the same model with the fat slider set to zero, and then setting it so that the fat model's surface can only compress down to the base model's surface. This would be akin to having fat layered over muscle and would make it so that chubbier areas are prone to more deformation. It unfortunately would be very resource intensive, I imagine, and wouldn't solve the problem of surface friction.

Sunlight Swift

I was messing with blender soft bodies in blender using lattices over meshes with collision at one point. Then blender got the ability to use a modifier with allowed me to use any mesh as a lattice over a mesh so I could make less resource intensive colliders. However its still taxing and tricky to get right. and blenders setting for soft bodies are very confusing and unpredictable. Many hours sank into it. But really for a non-interactive setting its just better to self position everything. It would be great for interactive things but the tech is just too much for processors. I guess maybe as a toggleable feature for ultra powerful pcs it could be neat to have in a finished version if you found a decent way, but without some serious revolutionary ideas it just seems like it can't be a viable approach. I thoroughly enjoyed all your tinkering with it though. I could watch soft body jiggle posts and never get bored lol