the existing tension map add-on apparently was having issues with armatures, shapekeys and rendering in blender 2.8+, so i decided to give a shot at making a version myself. it should work with armatures, shape keys and other deformation modifiers, and shouldn’t have issues rendering.
its still kinda frustrating how the new depsgraph seems to work, especially for rendering animations. it feels like you have to hack your way into making updates on each frame without breaking some other element of the animation.
anyway, download here:
mesh_tension.py (5.1 KB)
mesh_tension.py (10.5 KB)
- Now generates vertex groups that can be used with modifiers!
- If a modifier uses one of the generated tension vertex groups, it’ll automagically know to not use that modifier for calculating deformation tension
- Added an ‘Always Update’ option per mesh that allow instantaneous feedback while editing the scene rather than only when playing back animations.
mesh_tension.py (10.7 KB)
- Adds a ‘Bias’ option that lets you artificially favour stretching or compression
mesh_tension_1_3.py (10.9 KB)
Feature: If you tag a modifier name with the suffix ‘SKIPTENSION’ it won’t consider that modifier’s deformations as contributing to tension:
Fix: An objects’s tension updates are now paused when in edit mode; hopefully reducing errors where tension calculation ceases to function.
new vertex mask option that avoids tension calculations on an entire mesh - ie if you only need to calculate the effects on a character’s head rather than an entire body. note that in the current implementation it doesn’t factor in the individual vertex weights of the masking group, just whether the vertices are assigned to that group. it definitely provides a decent speed-up, but not as much as i’d have liked.
i also tried to do some trickery around handling mesh data in update loops. it provided some additional performance benefits in some test cases, but do test cautiously in case i’ve made any sort blunder! also in case it doesn’t appear to be working after updating the addon, try toggling the mesh tension on and off on the object, it should force a refresh of some new data structures the add-on relies on.
mesh_tension_1_4.py (12.8 KB)
Feature: Tension spread.
If the previous vertex mask helped speed things up, here’s a way to slow them down again! ‘Spread Iterations’ allow tension to propogate across the mesh. Positive iterations spread the stretching effects, negative iterations spread compression.
Higher iteration counts in either the positive or negative direction slow things down quickly, so I soft clamped the value between -4 and 4 to prevent accidentally locking things up dragging it like a slider, but you can manually type in higher values if required.
Wondering if I should allow individual controls for compression and stretching spread. might give more flexibility by allowing overlap of the two effects.
mesh_tension_1_5.py (14.3 KB)
Usage (version 1.1):
Install it in the preferences like any other add-on
Enable it per mesh in the mesh data tab:
- ‘Strength’ multiplies the intensity of the tension values.
- ‘Always Update’ allows for interactive tension updates even when not using the animation system
- In the scene properties, there is also an option to globally disable tension calculations
When enabled, it adds a vertex color called ‘tension_map’ that stores stretch in the green channel and compression in the red channel, and vertex groups ‘tension_stretch’ and ‘tension_compress’.
To use in a shader, add a vertex color attribute. You can separate out the green or red channels to multiply against corresponding maps that show compression or stretching.
To drive a modifier, select one of the tension vertex groups in the modifier’s settings.
-I discovered that to get around crashes, there is apparently a magical ‘Lock Interface’ toggle in the Render menu. So for safety the add-on interface greys itself out and presents a prompt until this is enabled.