Skin/Flesh Simulation

Ideas, enhancements, feature requests and development related discussion.

Re: Skin/Flesh Simulation

Postby sascha » Sun Jul 27, 2008 8:22 am

I really like the idea of being able to "bake" the results of the cloth simulator out as morphs. This would be a lot faster than running the simulation each time. You wouldn't get true secondary actions, but you'd get nice wrinkling an stuff, which is what you're probably after most of the time. So once you fit the character, you'd run the simulator for hours and hours, and it would eventually come up with a set of morphs that could be driven from bone angles.

JPatch's new morph system should be able to do just that. You could define morph targets in several "dimensions" - i.e. use any combination of bone rotations to define the target. We'd need to perform some experimentations to find out which works best. I don't think that using the entire skeleton would make much sense, but perhaps splitting the skeleton into 5 parts - spine, two legs, two arms - will do the trick.
David, IIRC you've wrote some cloth simulation code in the past. If yes, we could test this sort of "cloth baking" as soon as the new morph system is working.

I think this should work for all kings of "stiff" or tight-fitting clothes (like a suit, or the superhero-dresses from The Incredibles). It won't work for Marylin Monroe's dress though, or any situation where wind or acceleration has to be simulated.
sascha
Site Admin
 
Posts: 2792
Joined: Thu May 20, 2004 9:16 am
Location: Austria

Re: Skin/Flesh Simulation

Postby John VanSickle » Mon Jul 28, 2008 2:20 pm

As this talking has gone on, I'm coming to the idea that any sim module should be something that runs scripts as directed by a modeler or scene building application, acting on a database supplied by that application, and then handing the results either to the calling application, another application, or to a file. The idea is to have it flexible enough to do the following:

  • View the effects of different poses on a bulging muscle in a scene building application;
  • Automated generation of morphs based on a physical simulation;
  • Testing ideas for a particle system, by passing each frame of the sim to a renderer, thereby creating an animation;
  • And so on.
As should be apparent, this project gets more ambitious as I think about it. Most projects do.

Since the app will be focused on running scripts, I could use some kind of scripting language for the sims (either borrow one or roll my own) and make the app in something that runs fast (C++), or write the sims in Java, with one class for each sim, and have the app call these Java classes that do the actual sim work (advantage of Java: The whole Internet can help with distributed sims).

I also did an Internet search for possible names for the application. Holosarx (from Greek for "whole flesh") suggested itself, but it sounds too much like "wholly sucks," and I really don't need that kind of talk. So I called it Holosome (which means "whole body").
John VanSickle
 
Posts: 189
Joined: Sat Feb 16, 2008 2:17 am

Re: Skin/Flesh Simulation

Postby dcuny » Mon Jul 28, 2008 5:01 pm

John VanSickle wrote:As should be apparent, this project gets more ambitious as I think about it.

Just because you'd discussed it doesn't mean you actually have to do it. :)

Since the app will be focused on running scripts, I could use some kind of scripting language for the sims (either borrow one or roll my own)...
Lua is a popular scripting language. After having hand coded my own language, I've come back to the conclusion that using existing tools (such as Yacc) is really the best way to go. Java also has several scripting languages.

So I called it Holosome (which means "whole body").

Sounds like a cross between holodeck and chromosome - not necessarily a bad thing. But I doubt the name will have much meaning to anyone who doesn't speak Greek. It's not nearly as evocative as LionSnake. :|
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Re: Skin/Flesh Simulation

Postby dcuny » Fri Aug 01, 2008 6:22 pm

sascha wrote:David, IIRC you've wrote some cloth simulation code in the past. If yes, we could test this sort of "cloth baking" as soon as the new morph system is working.

I didn't get the code to the point where it was useful. I learned about all the "classic" problems of cloth: stretching, numeric instability, self-intersections and how difficult it is to properly detect collisions.

If I were to try again (certainly not until Marin is working), I'd try the approach by Matthew Fisher. My main issue with his approach was that while the individual frames looked good, his cloth didn't move like cloth - it looked like it was in slow motion. His approach is:
  • Collisions: Detecting collisions is hard, because there are so many ways to fail. So instead, he detects if a cloth vertex is inside of an object, and repels it out. This is a different sort of problem, and the problem becomes how to determine where "inside" is - especially if you are working with an animated character. Using proxy objects can help, but there's the problem of getting them to match the base object, and repelling properly when the object they are inside of is also moving. Voxelization might be a good approach here.
  • Cloth/Cloth Collisions: His approach is fairly simple: each vertex gets a boundary the size of it's spring that other cloth particles aren't allowed to interpenetrate. This seems to give pretty good results, and is fairly simple to implement. It doesn't handle the problem of cloth "pinching", though.
In retrospect, I don't think you can divide cloth into "floppy" and "wrinkly" parts. For example, bending at the knee causes cloth to wrinkle, but it also pulls the cloth up, so you've got both things happening at the same time. You can bake the dynamics, but the question is: how much resolution do you need to get convincing wrinkles? If it turns out the answer is "a lot", that means there's going to be a lot of data to load with the model. So it might make sense to offload this to another program that would generate the geometry points.
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Re: Skin/Flesh Simulation

Postby dcuny » Thu Aug 07, 2008 9:09 am

I picked up a copy of Inspired 3D Advanced Rigging and Deformations from the library in the hope that it might contain some useful information about rigging and deformation. For my purposes, it turned out to be worthless. It related only to Maya, and did nothing to explain the concepts behind rigging. For example, the chapter Matrix Math contained no matrices, and IK Solvers and Their Application did nothing to explain IK , but instead focused on equations to maintain volume for a "squooshy" IK rig . :roll:

One possibly useful bit of information it had was for the cgmuscle.com, an attempt to create an open-source muscle system for Maya. I don't know if the project is still active, but it looks like it might be a useful resource.
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Re: Skin/Flesh Simulation

Postby John VanSickle » Fri Aug 08, 2008 1:35 pm

As I think about it, there is no reason to focus the purpose of the application on simulating living things, or even simulating anything, for that matter. If the sim part works by taking the output from a modeler, running a script on the output, and then passing the results to file or renderer, then why care if the script is a sim?

So what I find myself coming to is an integrated computer graphics environment, rather than a tool to do any of the specific tasks related to CGI work; or, to do for CGI what IDE's do for software development. This shouldn't be too hard, as there are only about fifty thousand different modeling, posing, and rendering applications out there.

Oh well. Back to RuneScape...
John VanSickle
 
Posts: 189
Joined: Sat Feb 16, 2008 2:17 am

Re: Skin/Flesh Simulation

Postby dcuny » Fri Aug 08, 2008 9:28 pm

I'm sorry... Either you're being very sarcastic, or very oblique. :|
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Re: Skin/Flesh Simulation

Postby sascha » Sun Aug 10, 2008 8:40 pm

Using proxy objects can help

Hmmm...
I've given this some thought, and I think that using (scaled) spheres (i.e. ellipsoids too) should be straightforward to implement.
but there's the problem of getting them to match the base object

This puzzled me for years - I've once bought a copy of Poser-3 (or was it 4?). It featured basically nude woman and man models, and you could dress them with different clothes - the cloths were automatically bound to the skeleton, but this didn't work very well - it was common that the skin intersected the cloths and vice-versa.
My problem with that approach is this: Assuming that the animations we're all interested in do not feature naked humans, why on earth would anybody model a naked human model? Assuming furthermore that we don't use see-through dresses, and ignoring special lighting conditions (sunlight from behind) where most clothes would become semi-translucent, there's no need to model any body-part that's clothed.

Long story short - my approach to cloth simulation would be:
Add a collision primitive to JPatch - I'd suggest (scaled) spheres, but cylinders might also work. You'd then model everything that's visible using SDS, and everything that's beneath garment using these spheres and/or cylinders - these would be used for the cloth simulation, but not for rendering.
The collision primitives are also bound to the skeleton, so they're fully animatable.

What's wrong with that?
sascha
Site Admin
 
Posts: 2792
Joined: Thu May 20, 2004 9:16 am
Location: Austria

Re: Skin/Flesh Simulation

Postby dcuny » Sun Aug 10, 2008 10:03 pm

sascha wrote:Assuming that the animations we're all interested in do not feature naked humans, why on earth would anybody model a naked human model?

In the case of Poser, I think the interest is in naked - or nearly naked - humans. ;)

Assuming furthermore that we don't use see-through dresses, and ignoring special lighting conditions (sunlight from behind) where most clothes would become semi-translucent, there's no need to model any body-part that's clothed.

But the bounding should be a fairly close match.

My recollection is that the program Shave and a Haircut used bounding spheres for hair intersections. At this point, it uses a mesh.

Add a collision primitive to JPatch - I'd suggest (scaled) spheres, but cylinders might also work.

It's probably a very good solution, and certainly much better than the alternative - nothing at all.

As I mentioned before, it's a lot simpler to determine if a point is inside of a geometric primitive (and which direction to repel it) than for an arbitrary mesh.

You've still got the problem of "pinching" to deal with, where cloth gets caught between to surfaces. On option might be to create proxies in "no collision" zones, such as under the arms and behind the knees. Another option would be to check for multiple collisions, and lock those points into place, similar to how Pixar "flypapers" pinched points.

Computer graphics are just one big "cheat" anyway, so as long as it looks good enough and is usable, that's all that's needed.

Edit: I ran across this image on an old CGTalk thread:
Spherize_muscle.gif
Spherize_muscle.gif (264.82 KiB) Viewed 9367 times
I think it does a good job showing off that, with a little work, spheres can do a very good job as proxy objects.

If you're really ambitious, you could write a program which could automatically generate the sphere proxies for you. There's code out there that'll do it, but it's definitely not a real time process. I'll see if I can dig the web site up again.
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Re: Skin/Flesh Simulation

Postby dcuny » Mon Aug 11, 2008 7:13 am

I was thinking about Sphere Trees. Here's an example of some auto-generated sphere trees at different resolutions (more examples on the linked website):
dragon-1-tn.gif
dragon-1-tn.gif (3.95 KiB) Viewed 9359 times
dragon-2-tn.gif
dragon-2-tn.gif (3.82 KiB) Viewed 9359 times
dragon-3-tn.gif
dragon-3-tn.gif (3.63 KiB) Viewed 9357 times
This method looks like it would present a very good fit for organic models.

I've picked up a book on real-time collisions from the library, but haven't had a chance to read through it yet. I'll see if there's anything useful in there.
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Re: Skin/Flesh Simulation

Postby dcuny » Sun Aug 17, 2008 7:12 am

I stopped by the local bookstore and had a look at Bounce, Tumble, and Splash!: Simulating the Physical World with Blender 3D (there's a mouthful!). It was light on details on how things are implemented in Blender, so I guess I'll need to look at the source code at some point. Things I did note:
  • Blender's hair looks very good. It can also bring your computer to a grinding halt if you're not careful.
  • The best tool for simulating hair physics is the softbody tool. However, there's a problem with hair falling into the scalp. The best solution is to make the hair stiffer toward the root, and softer toward the top.
  • Unsurprisingly, the cloth simulator does better than the softbody simulator.
  • Binding the cloth to bones helps a lot.
  • Cloth can be weight painted to be pinned to the character. This prevents slipping, and specifies which parts are "floppy."
  • Cloth collision detects collision through the faces. I'm not sure what it detects - perhaps a vertex penetrating the face. I'll have to check the code at some point.
A point of interest: it took three years of work to get a working cloth system in Blender. The author spent an insane amount of time working on it. He also suffers from carpal tunnel syndrome. It flared up in one wrist, and then the other. He ended up having to take six months off the project.

Edit: I had a look at the Blender source. The cloth include file mentions a paper, but doesn't include any citations. It looks like a pretty standard spring model, with structural, shear and bending springs. The collision code cites Robust Treatment of Collisions, Contact and Friction for Cloth Animation (2.2 Meg pdf), a paper published in 2002. It's been a while since I've read the paper, but here's the abstract:
We present an algorithm to efficiently and robustly process collisions, contact and friction in cloth simulation. It works with any
technique for simulating the internal dynamics of the cloth, and allows true modeling of cloth thickness. We also show how our simulation data can be post-processed with a collision-aware subdivision scheme to produce smooth and interference free data for rendering.
It's been a while since I've read through the paper, and it's late (I've nodded off about three times just now reading through it - I'm dead tired). But it's pretty well written, and from what I've seen, the results look quite good.

It's not clear that this approach offers a solution to "pinching" that you get in cloth. It generates more realistic results that using simple proxy geometry, but is more complex to implement.
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Re: Skin/Flesh Simulation

Postby dcuny » Fri Aug 22, 2008 6:39 pm

I ran across a set of notes on collision objects. Using a triangular mesh is probably the most general method, but it gets complicated quickly when you have to account for the fact that both the cloth and the object are moving. :?
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Re: Skin/Flesh Simulation

Postby John VanSickle » Sat Aug 23, 2008 4:29 am

dcuny wrote:It's not clear that this approach offers a solution to "pinching" that you get in cloth. It generates more realistic results that using simple proxy geometry, but is more complex to implement.

It may be that some of the solutions that we look for in the sim may be more easily solved in the modeling phase. For instance, when I bend my finger, the skin folds in a particular place, where I can see a crease. The skin there is structured differently so that it bends there every time.

In a like manner, a model designing a coat or something can put a place in the sleeve where the relaxed position is very slightly bent; not enough to notice when the arm is straight, but when the arm bends, the difference causes the cloth to fold there first, and then the rest of the cloth can pull into position without any popping.
John VanSickle
 
Posts: 189
Joined: Sat Feb 16, 2008 2:17 am

Re: Skin/Flesh Simulation

Postby dcuny » Sat Aug 23, 2008 6:37 am

John VanSickle wrote:The skin there is structured differently so that it bends there every time.

I understand what you're getting at, but I don't think that's the core of the problem. The problem is when the skin folds, it self intersects. Here's the graphics from the Pixar paper Untangling Cloth:
intersect01.png
intersect01.png (27.99 KiB) Viewed 9278 times
intersect02.png
intersect02.png (23.71 KiB) Viewed 9277 times


Here's a more "realistic" example from the paper - the back of the upper leg passes through the back of the lower leg:
pinch.png
They tried various approaches to get the opposing forces to cancel out:
Given a set of pinching surfaces, we attempted to distill the multiple contacting surfaces into a single planar constraint, approximately midway between the surfaces. We found, however, that even for pinching between a pair of solids, the opposing surface normals were rarely opposite enough for this to be effective; moreover, there was a great lack of consistency in the constraints generated for neighboring pinched particles. This led to unnatural distortions of the pinched cloth, with pinched particles still free to move in a plane. The resulting particle movements caused the planar constraints on a particle to vary from step to step, even if the pinched solid objects were motionless. In other words, everything wiggled.
and
We next considered abandoning constraints and simply using standard repulsive forces to push particles away from surfaces. This has intuitive appeal, since it naturally handles any number of pinching solid surfaces; we hoped the generated repulsive forces would balance, leaving cloth roughly midway between solid surfaces without any computational effort at all. This approach failed as well; the cloth/solid repulsive forces were left to compete with all other forces in the system (and most notable with the cloth/cloth forces). The result was again a system which often wiggled even when the solid objects were motionless.
In other words, the solutions that failed had issues with cloth not staying still.

Their "flypaper" approach addresses this problem:
If we simply consider the case of cloth particles pinched between motionless solid objects, an obvious solution presents itself: pinched particles should not move. The rationale for this is that the friction forces generated by the pinch are a match for any other forces acting on the cloth, and adjust to eliminate any motion. From an algorithmic standpoint, enforcing a hard constraint which “flypapers” these particles so that they remain in place is trivial.
A similar solution could probably be reached using proxy objects - if the cloth is contained by multiple proxies, the trapped cloth could be "locked" in place. (Of course, it's not quite that simple).
dcuny
 
Posts: 2902
Joined: Fri May 21, 2004 6:07 am

Previous

Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron