In my project, I am creating a system for deforming a highly detailed mesh (clothing) so that it 'fits' a convex mesh. To do this I use depth maps of the item and the 'hull' to determine at what point in world space the deviation occurs and the extent.

Simply transforming all occluded vertices to the depths as defined by the 'hull' is fairly effective, and has good performance, but it suffers the problem of not preserving the features of the mesh and requires extensive culling to avoid false-positives.

I would like instead to generate from the depth deviation map a set of simple 'deformers' which will 'push'* all vertices of the deformed mesh outwards (in world space). This way, all features of the mesh are preserved and there is no need to have complex heuristics to cull inappropriate vertices.

I am not sure how to go about generating this deformer set however. I am imagining something like an algorithm that attempts to match a spherical surface to each patch of contiguous deviations within a certain range, but do not know where to start doing this.

Can anyone suggest a suitable filter or algorithm for generating deformers? Or to put it another way 'compressing' a depth map?

(*Push because its fitting to a convex 'bulgy' humanoid so transforms are likely to be 'spherical' from the POV of the surface.)

Edit: Here is an image/diagram rightly suggested that illustrates what I am trying to achieve.

Also, I should say since this question was posted I worked a lot more on this problem, and though I never solved how to the get the deformers I did eventually decide that depth maps for this were unsuitable as:

  1. If the deformed mesh is not complete, it is possible to get texels in the map that are meant to be on the other side of the convex mesh (because they are not obscured by those closer to the camera on the correct side).
  2. The efficiency was not as high as I had hoped due to the fact 6 maps were needed per deformation.

Not that these were unsolvable, but the other solution, which involved collision testing in kernels running on the GPU, resulted in higher quality results and was much simpler, even though it may not be as fast.

I still think this questions problem is interesting though and would be interested in any answers as I am sure there are situations where it would be preferred.

enter image description here

  • \$\begingroup\$ Could you please insert a picture or drawing of the effect you want to achieve ? It would be easier to understand your problem. \$\endgroup\$
    – wip
    Commented Jan 2, 2013 at 4:29
  • \$\begingroup\$ Seconding a comment made below, a picture or drawing may help a lot. There are many ways to simulate how clothing wraps body parts and maybe your “deformers” idea is only one of the several that could apply. \$\endgroup\$ Commented Jan 2, 2013 at 8:08
  • \$\begingroup\$ what is wrong with moving the whole shape? \$\endgroup\$
    – Ali1S232
    Commented Jan 2, 2013 at 16:22
  • \$\begingroup\$ Gajoo, Imagine if the shape wrapped around the mesh, moving it in one direction would cause it to only further intersect the shape on the other side - though indeed that is what the deformers are doing, just little bits of the shape at a time. \$\endgroup\$
    – sebf
    Commented Jan 2, 2013 at 16:33
  • \$\begingroup\$ SamHocevar, this question was about fitting only - you have a mesh thats slightly smaller than the character it is meant to fit, so the mesh is adjusted accordingly. The depth field implementation was chosen for performance reasons, the deformers were chosen because of that approaches ability for feature preservation. \$\endgroup\$
    – sebf
    Commented Jan 2, 2013 at 16:34

1 Answer 1


You have a depth map, which I assume is simply the distance between the convex mesh A and the neutral deformed mesh B, and you have surface normals of mesh A.

What you're missing is weights (or groupings) of how each vert on mesh B affects its neighbors. For example, when the central vert gets moved it should also drag along its neighbor verts by some amount (percentage) if they are in the same group.

If you have a group of verts affect each other 100% they will all end up pushed out by the farthest amount from your depth map as if they were all part of an unbendable steel structure that moves as a unit, set at 50% this structure may act more like thick rubber sheets and 10% like form fitting plastic wrap because each vert barely affects its neighbor (which is what you have now.

Obviously there's some blending and merging of values going on. Like @Gajoo said, "what is wrong with moving the whole shape?"


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .