利用者:Nicholasbishop/SummerOfCode2008/MidtermReport

提供: wiki
移動先: 案内検索

Completed work as of July 12th:

Multires as a Modifier

Bishop-gsoc2008-Panel1.png

Multires has an entirely new implementation on the modifier stack. The old system, briefly described, was a parasite on the Mesh struct; it directly modified mesh elements and then pretended to be a regular (albeit very dense) Mesh. There were a number of problems with this approach:

  1. It required a lot of special code all over Blender to handle multires meshes; rendering and CustomData handling were particularly bad.
  2. The multires data was stored per-vertex, which made it very difficult to handle topology changes, so all editmode operations that affected mesh topology had to be disabled for multires meshes.
  3. Animation didn't work well; displacements were propagated in object-space, so the multires mesh deformed incorrectly (especially noticable with the armature modifier.)
  4. The amount of stored data was extremely large. Mesh faces, edges, vertices, and some CustomData were all being stored in the subdivided state.

Displacements

Multires now takes advantage of the CustomData system to store displacements. Rather than directly storing the coordinates of Mesh vertices, each face in the base mesh gets a grid of displacements. (These displacements overlap at the edges and corners of the face, which requires a bit of special handling.) The displacements are stored relative to the orientation of the face, so as the face is rotated or otherwise deformed, the displacements are automatically transformed. This makes a big difference for animation.

Additionally, since displacements are stored per-face, we get topology editing almost for free. All of editmode's tools work unmodified. However, the behavior of some tools isn't quite optimal (for example, subdividing a face should remap the displacements to the new sub-faces, rather than just copying over the old displacements.)

Subsurf

The subsurf modifier is in some ways very similar to multires, so multires now uses the CCGSubsurf code for subdivision. The mesh is first subdivided exactly as with subsurf, and then displacements from the CustomData are layered over the top. Using CCGSubsurf means that a lot of potentially complex issues are taken care of for free.

Editing Multires

Mesh displacements are only editable in sculpt mode. Although the previous implementation allowed detail editing in editmode, this wasn't a very useful feature; the higher memory requirements of editmode made it very slow with even a modest amount of subdivision. However, editmode is very useful with the new multires because topology of the mesh is now editable. This means the modeling process with multires is less linear; you can create a base mesh, add multires levels and sculpt them, then go back and add or delete faces from the base mesh, without losing any detail.

Unfinished Work

The most critical piece of unfinished work is generic subdivision of displacements. In order to sculpt multires levels, displacements have to be subdivided upwards so they can be applied at the top level of the multires DerivedMesh. Currently, sculpting works fine on the base mesh (which doesn't use displacements) and at the highest multires level (which obviously doesn't need to subdivide displacements.) I recently completed the code that allows displacements to be subdivided up one level; the next step is to make it work for an arbitrary number of levels, at which point multires will be fully sculptable.

Other things on the TODO list:

  • Better integration with sculpt mode. For example, undo and partial redraw aren't working properly. There are probably other issues that will show up with further testing.
  • Smarter topology editing in editmode. Some operations, like subdividing, should automatically apply old displacements to new faces.
  • Level deletion. Deleting higher levels should be easy, deleting lower levels is more complex, since it would modify the base mesh.
  • Conversion of the old multires data into the new displacement + modifier format.
  • Get rid of old multires stuff. There's still a lot of checks and stuff all over the code that can now go away.

Demonstrations