Baraff Cloth

Started by
8 comments, last by Dirk Gregorius 18 years ago
I am reading through the cloth paper of D. Baraff currently (www.pixar.com/companyinfo/research/deb/sig98.pdf). While I do understand the implicit solver and the idea of the constraints using implicit functions I really don't understand these mapping function used there. 1) How is this mapping defined? E.g. let's assume an artist models a nice cape (maybe with some folds and wrinkles). How do I generate the mapping function? 2) What is the reason of this function? 3) What is the genral idea here? A small example would be of great help... Regards, -Dirk
Advertisement
Instead of treating the cloth a discrete set of points, let's think about it as a piece-wise continuous surface which is given by w(u,v), where w:R2->R3.
I called it piece-wise because we are going to define it in a different fashion for each triangle.

Given a triangle (p0,p1,p2), we'd like w to satisfy:
(1) w(u0,v0) = p0, w(u1,v1) = p1 and w(u2,v2) = p2.

Let's try to linearize w. Using Taylor's expansion at some point (u,v) we get:
(2) w(u + du, v + dv) = w(u, v) + grad(w)(u, v) * (du, dv)T

If we assume that w is linear then grad(w)(u, v) is constant, that is it doesn't depend on (u,v).
Following this assumption let's define:
(3) A = grad(w)(u, v) = (wu, wv),
where A is a 3x2 constant matrix.

Let's rewrite (2) using (3):
(4) w(u + du, v + dv) = w(u, v) + A * (du, dv)T

Substituting (1) into (4) we get:
p1 - p0 = w(u1, v1) - w(u0, v0) = A * (u1-u0, v1-v0)T
p2 - p0 = w(u2, v2) - w(u0, v0) = A * (u2-u0, v2-v0)T

Please compare this to (9) in Baraff's paper. After solving (9) we get the matrix A.
Since w is linear we can conclude from (4) that w(u,v) is given by:
(5) w(u, v) = w(u0, v0) + A * (u-u0, v-v0)T.
Equation (5) gives you the definition of the mapping function.

Having (5) at our disposal we can treat our cloth as a continuous surface.
Equation (10) in the paper defines C(x) for each triangle. Each C(x) depends only on 3 particles (the triangle vertices).
The entire stretch energy of cloth is the sum of those C(x). Let's call this energy Eb. Notice that the stretch energy is defined using a continuous representation of our cloth!!!

Now consider equation (7) in the paper. In order to find the force that acts on some particle i due to the stretch energy we do:
(6) fi = - d(Eb) / dxi.

Eb is a sum of C(x) and only C(x) that were defined for a triangle that has xi as one of it's vertices can give you non-zero results.
It is only in equation (6) that we come back form a continuous domain back to the discrete domain.

Hope that this is enough for now. Tell me if you have more questions.
Thanks for the reply, Ury.

I understand the idea now, but I don't understand the mapping function completly.
In equation (1) you state:

Given a triangle (p0,p1,p2), we'd like w to satisfy:
(1) w(u0,v0) = p0, w(u1,v1) = p1 and w(u2,v2) = p2.

Do we only know the three vertices of the triangle or do we know (u0,v0), (u1,v1) and (u2,v2) as well and if yes, where do they come from? If not - how do I compute them?

Regards,

-Dirk
I just read over the paper again and I found the follwing quote:

"We capture the rest state of the cloth by assigning each particle an unchanging coordinate (u, v) in the plane"

So I think (u0, v0) are given in our case. A more practical question now is how do I assign the values? Could I actually simply us the texcoords of the cloth model or do I have to project the cordinates myself?

If I project myself - do I have to find a projection plane for the whole cloth or can I simply project each triangle one by one into the plane defined by p0, p1 and p2. In the case of treating cloth as a whole and finding one projection plane for all vertices it might happen that projected triangles degenerate to lines?

-Dirk
Ah.. I see now. Actually, you know them both.
Just like in real life, a cloth usually consists of several pieces of fabric which are stitched together. You can put each piece of the fabric on a table and if you are careful enough not to create any folds, you'll get a "planar embedding".

Now, if you break the piece into triangles, and think about the table as if it was a Cartesian grid, you can assign 2d coordinates to the triangle's vertices or as we'll call them from now: particles.
This is how you get your (u, v) coordinates (just like texture mapping). Each particle receives a (u,v) which is fixed during the whole simulation.

Another way to think about those coordinates as if they were coordinates in our cloth local space. If the top of our table is located on the x-y plane in world space, unless we move the particles, each particle i position in world space is given by: (ui,vi,0).

Naturally, for each configuration of the cloth, we get a different w(u,v) mapping function. You can think about ||wu|| as a measure of how the cloth was stretched (or compressed) with respect to the table's u-axis.

PS. I failed to see your last post when I wrote this. Still, I think that this post addresses all of your question, right?
Yeap, that answers my questions. In the paper Baraff states:

4.2 Stretch Forces

"Recall that every cloth particle has a changing position x in world space, and a fixed plane coordinate (u, v)"

1)
So this means that the (u, v) are constant in time - so they are preferable imported into the simulation and not created on the run-time?

2)
Though the plane coordinates are constant, the gradient is not. If I look at equation (9) the gradient depends on the local world coordinates as well. In order to find the gradient I simply build dx1 and dx2 each frame and compute with the precomputed constant inverse matrix containing du1, du2, dv1 and dv2 - correct or do I still get something wrong here?

3) How would you compute these plane coordinates? Which projection plane would you use?

-Dirk
Hey Dirk,

Quote:Original post by DonDickieD
1)
So this means that the (u, v) are constant in time - so they are preferable imported into the simulation and not created on the run-time?
3) How would you compute these plane coordinates? Which projection plane would you use?

This really depends on how you are going to import the cloth into the simulation. Tell me if you have something specific on your mind.

Quote:
2)
Though the plane coordinates are constant, the gradient is not. If I look at equation (9) the gradient depends on the local world coordinates as well. In order to find the gradient I simply build dx1 and dx2 each frame and compute with the precomputed constant inverse matrix containing du1, du2, dv1 and dv2 - correct or do I still get something wrong here?

That's right, (9) depends on local coordinates. But since du1, du2, dv1, dv2 are constant throughout the entire simulation, the only thing that change in (9) with respect to time is dx1, dx2.
Quote:
This really depends on how you are going to import the cloth into the simulation. Tell me if you have something specific on your mind.


I can think of three scenarios:

1) Simply use the texcoords defined by the artists.
2) Iterate over all triangles and find some kind of average normal and project onto this plane
3) Project each individual triangle into the plane defined by its vertices

-Dirk
Hey Dirk.

Quote:
I can think of three scenarios:

1) Simply use the texcoords defined by the artists.
2) Iterate over all triangles and find some kind of average normal and project onto this plane
3) Project each individual triangle into the plane defined by its vertices

You must take great care if you are planning to use 1 since your texcoords should have the same metric as your world space.
Using 2 and 3 is even more dangerous. Recall that the idea is to capture the "local/rest" state of your cloth. Since the initial piece of cloth is at rest, what you really need is some isometric mapping from (x,y,z) to (u,v).
Simply projecting your points on some plane won't do it unless your cloth is already embedded in a plane. You could overcome this difficulty if you reparametrize the cloth mesh using parametric surfaces and get your information from there. (Such reparametrization can be usually done using any commercial modeling software).

You can see that the easiest way is to start with a planar mesh, compute (u,v) using methods 2/3, and then let the artist do whatever he wants with the cloth.

Your last post still doesn't answer my question. Say you have an avid artist sitting around in your office nervously drinking coffee and mumbling something about giving him a tool to model the cloth. What exactly are you going to give him and what will it look like? After the artist models the cloth, how are you going to transfer it into the simulation environment?

Here's the first thing that popped when I googled for an example:
http://www.syflex.biz/tut.html.

Take a look at the flag and the laundry examples. Notice that they start with a planar mesh, turn it into a cloth object and only then alter its position.
Hey Ury,

thanks for the reply. As you probably see the authoring is the real problem currently. Because of the timeline there is no time to implement some nice plug in for Maya that generates you all data I need. So the basic idea is to generate any cloth data directly from the mesh the artist genererates. I have written some simply mesh processing function that do the following:

1) Create a particle for each vertex and assign it one third of the area of each incident triangle times some artist defined "density".

2) Create a spring for each edge of the mesh and compute the restlength and stiffness of all springs using the "Speed Of Sound Heuristic" like mentioned by Gelder or Bridson.

3) Create the bending elements for each pair of incident triangles and compute the stiffness and rest angle. Basically like the bending fore in the Baraff paper.

So this is basically what I have as input data. As you see there is by no means any regular data. I have to build my cloth simulation preferable around this data. Additionally your nervous and coffee drinking artist have nice ideas like giving weightings to the vertices and only simulate some percentage. An idea that I don't like at all since it will blow the state of the simulation and maybe violate the constraints and I have to recover from this all the time and introduce a lot of unknowns into the system.

My current plan now is to start easily. I will ignore the bending elements in the first place and only use springs generated from the edges. On this I will implement the simple Verlet method with one by one relaxation like introduced by Jacobson. This is basically for have something get going. From there I will switch to the implicit method like introduced by Baraff and will try the Jacoby like solving method like introduced by Kang and also the original CG solver in order to see how many particles I can simulate with this. After I have a feeling for this I want to bring the bending elements in again. At first I thought of adding an extra spring between the vertices that don't share the common edge. Maybe I will add some kind "twist" spring ( f = k * deltaPhi ) or whatever.
Finally I think of mixed integration like introduced by Boxerman and Bridson and using decompisition of cloth in order to utilize parallesism.

So this is my current dilemma. So many possibilities and I don't know where to go in the beginning. My major headache is that from the provided data any usuable cloth simualtion isn't possible at all...

-Dirk

PS: Thanks for the links. This will give me an idea how to author cloth. The big problem is that you actually want to let artist do what they can do best - model triangle meshes and not taylor cloth from planar cloth patches.

This topic is closed to new replies.

Advertisement