利用者:Mont29/Dev/WeightVGroup/Dev

提供: wiki
< 利用者:Mont29‎ | Dev‎ | WeightVGroup
2018年6月29日 (金) 04:41時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

WeightVGroup Modifiers

What?

The WeightVGroup modifiers take a vertex group of the affected (mesh!) object, and modify its weights.

Currently, they can:

  • Edit: Map the weights (either linearly, or with a curve), add/remove vertices to/from the vertex group, if they have higher/lower enough weight, and clamp the output weights.
  • Mix: Mix in another vertex group, or a constant value, using various operations (replace, add, difference, etc.).
  • Proximity: set a weight computed from the distance of the vertices, or the whole object, to another “target” object (or its geometry) of the scene.

All these operations can be further controlled by an influence value, and optionally by another vertex group or texture.

You can then use this vertex group in other modifiers below in the stack.

As a test, I used it on a plane, before a Wave modifier, using the camera as reference object. Here are small videos illustrating its effect:

Why?

In fact, I codded this modifier as the first step of a project: to make subsurf level adapt depending on the distance between the vertices and a reference object (e.g. the camera…). This would allow e.g. to vary the level of details of a displace (e.g. terrain generation), based on how far from the camera are the deformed vertices.

This would give a stack like that:

  1. A WeightVGProximity modifier sets the weights of a vertex group, depending on how far they are from the camera.
  2. A WeightVGEdit modifier maps the weights back into a valid range.
  3. A Subsurf modifier subdivides the grid based on this modified vertex group, e.g. from level 0 (most far away vertices) to level 10 (nearest ones) – obviously in discrete steps (I don’t intend to support float level of subdivisions!).
  4. A Displace modifier creates the terrain, with much more details near the camera than more far away… Many memory saved, esp. if the camera moves (and hence you cannot create a customized grid)!

So, the logic would have been to implement first the vertex group influence upon subsurf, but when I looked to the subsurf code… Ack! Too complex for a first blender work! And hence, I first created the WeightVGroup modifiers – which have proved themselves useful in many other situations, I think… IMHO, this was missing!

Notes & Projects

  • I’d like to show modified weights in Weight Paint mode, but couldn’t find a way to do it for now (except directly modifying the original defgrp layer, which is definitively not a good idea!)…
  • Texture can be used as mask… Ultimately, this might even allow for removing that tex stuff from Displace/Wave, let them use only weighted vgroups (sort of “factorization” of modifiers…).
  • I’d also like to implement a way to apply custom py functions to weights, in the Edit modifier… But this won’t be easy to implement, I think – and it would heavily slow down things. So I’ll see this later if I have time too! Right now, you already have a curve to create custom mappings…

Release Log

0.0.1

  • Built and tested against svn 34776.
  • Initial “release”.

0.0.2

  • Built and tested against svn 34904.
  • Now using BLI_strncopy instead of standard strcopy.

0.0.3

  • Built and tested against svn 34970.
  • Added a modifier icon (not the best right now, but…).

0.1.0

  • Built and tested against svn 35181.
  • Big improvements, with four new important functionality (see also the Manual page):
    • You can now use the reference object’s geometry to compute (minimal) distance to the vertices of the affected object.
    • Also, the modifier can now add/remove vertices from the vertex group, based on their final computed weight. This makes this modifier also useful for modifiers that do not use vgroup weights, like e.g. the Mask one.
    • There’s now a mapping power factor, which allows non-linear mappings between the dist and the weight factor.
    • Finally, a new mode, Static, allows you to affect the vgroup with a constant weight factor, or another VGroup weights. This allows you, among other things, to do some basic actions on vgroup, like clamp, bust-out null-weighted vertices from the vgroup, etc.
  • Added two new mix mode options, difference and average.
  • Added an optional «revert» step on weightf, before mixing it with old weight.
  • A small optimization in the mapping process, now caching the mapping factors to avoid re-computing them for each vertex!
  • Another small optimization, now getting the full vertex array instead of getting each vertex one after the other…
  • Other minor updates – note however that this might make files created with previous versions of this modifier somewhat incompatible (they’ll load, but some modifier’s property values might be lost…).
  • Fixed the steps values for UI sliders, UI changes.

0.2.0

  • Built and tested against svn 35286.
  • Another big improvements “release”, with two new important functionality (see also the Manual page):
    • Textures can now be used as weight factor sources as well (via a forth mode, Texture). Huh! Took me an hour to figure out that using texture ID implied to implement a foreachIDLink func!
    • I Added an optional custom curve mapping to affect the weight factor before mixing it with old weight. Note this implied to edit writefile.c/readfile.c, to store/load that curve!
  • Use Ref Object Geometry now also available in OBJ2OBJDIST mode (even though I’m not sure it will be most useful ;) ).
  • Moved the MOD_WEIGHTVGROUP_ZEROFLOOR def from DNA_modifier_types.h to MOD_weightvgroup.c (had nothing to do in dna stuff…).
  • Upgraded UI accordingly.

0.2.1

  • Built and tested against svn 35433.
  • Changed “0” func pointers into NULL ones (in ModifierTypeInfo struct).

0.3.0

  • Built and tested against svn 38279.
  • Major changes. Split the modifier in three:
    • Edit (mapping, adding/removing vertices from vgroup, clamping).
    • Mix (mix in another vgroup, or a constant value).
    • Proximity (set weights from distance of object (or its vertices) to another object (or its geometry).
  • Each modifier has an influence value, and optional vgroup or texture mask.
  • Now using BVH for geometry proximity weighting.
  • Slightly enhanced dm copy, by only copying MDEFORMVERT cdl (to only copy when cdl are org data yet remains to be done, though…).
Exclamation mark.png

Those changes make blend files saved with previous WeightVGroup versions « incompatible » – they will load, but WeightVGroup setups will be lost.

See Also