I’m would like to perform on operation in blender that I don’t think I can yet, I would like some help on how I can develop it in the right way.

I would like to delete geometries depending on a texture and following the UV map. Imagine the Displace Modifier, where you indicate the texture and that you want to use the UV but instead of extruding vertices based on the grey level, it would delete or keep vertices based on a threshold.

Because you can’t create modifier as addon, I’m already making my own from blender source code. I believe it is actually ready, what do I need to do so that my modifier appears with the other ( precisely ) ?

Also after that I will aim do the same thing but with subdivide operation, where my mesh will be subdivided more in specific area depending on a grey level texture.

Any help is welcome.


How to add a Modifier

(This answer is for 2.7X versions, 2.8 has made some changes to modifier code, and I haven't got around to looking at them)

A while back, Campbell Barton created a patch template for a deform modifier, which provides a great place to start when looking at creating a modifier, it can be found here. In general, once you know which files to look in, you can just follow what has been done for other similar modifiers, as it tends to be fairly systematic.

I will assume a working knowledge of Blender's DNA/RNA system (See https://wiki.blender.org/wiki/Reference/FAQ for a starting point if you are unfamiliar)

In essence you need to do the following:

  1. Define a struct and appropriate exports in source/blender/makesdna/DNA_modifier_types.h for your modifier properties. Make sure you follow DNA byte alignment rules (the compiler will check and and help you)

  2. Create your modifier file in source/blender/modifiers/intern/ (And don't forget to add it to CMake). This is the file where you will do most of the work. The most important thing you need to do is to define a ModifierTypeInfo struct which describes how your modifier behaves and provides access to the methods that actually execute it. See other modifiers for examples. This includes indications on what sort of data the modifier accepts, how to construct the modifier data, and depsgraph relationships and many more bits and pieces. Be aware the deform only modifers are different that onces that change vertices.

  3. In source/blender/modifiers/MOD_modifiertypes.h add a reference to the above ModifierTypeInfo

  4. In source/blender/makesrna/RNA_access.h define the RNA mapping for your modifier data DNA struct so that it can be accessed by the UI.

  5. Add a UI for the modifier panel in release/scripts/startup/bl_ui/properties_data_modifier.py

  6. If you have added any pointers in your DNA struct, you will need to update the source/blender/blenloader/intern/writefile.c and source/blender/blenloader/intern/readfile.c files to define save and load behavior. This is also used in undo.

Suggestions for your particular Modifier

For the particular modifier you want to add, you should actually be able to do this by combining two existing modifiers.

  1. The Vertex Weight Edit modifier supports a texture mask option that you could use to define which vertices you want mask. If it doesn't provide enough control, I would suggest looking at enhancing this modifier.
  2. Them just use the ordinary mask modifier with the generated vertex group.
  • $\begingroup$ even though i'm working on doing it with the python API at the moment, I'm marking this as the current answer as it's the first time seeing a proper guide on creating a modifier. Thanks good sir. $\endgroup$ Jul 11 '19 at 9:08

A possibility (to avoid a bit difficult coding), more than a real answer:

Use a displacement modifier on a cutting object.

Then use this cutting object for a boolean 'difference' operation on the object you want to cut (or remove some vertices).

This is illustrated in this animation:

enter image description here

  • $\begingroup$ thanks but my issue with this approach is that the booleen operation will create new vertices because the edges that are cut make additional geometry. I was aiming for an approach that will cut "clean" similar to selecting the vertices and deleting it. $\endgroup$ Jul 10 '19 at 8:54
  • $\begingroup$ I could probably make a script that select those vertices who are in a volume created by the method you show case, hmm I will try this approach. $\endgroup$ Jul 10 '19 at 8:56
  • $\begingroup$ @EdmondBoulet-Gilly. OK, I should have presumed that. But what about faces if for a face only part of its vertices are deleted? $\endgroup$
    – lemon
    Jul 10 '19 at 8:56
  • $\begingroup$ Yes my goal is also to delete them, I tried the volume selection but I'm not working with closed volume so it's no working for me. Is there a way to select vertex using a grey scale texture ? $\endgroup$ Jul 10 '19 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.