Skip to content

Blender addon - Triangulate your textured mesh while discarding alpha zones

License

Notifications You must be signed in to change notification settings

Pullusb/Tesselate_texture_plane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tesselate texture plane

Blender addon - Tesselate texture plane

Download latest

/!\ IMPORTANT NOTES:

  • Running blender as admin might be needed at first activation to enable auto-installation of needed third party modules (tested on windows)
  • save before use ! Triangulating can crash with some images and/or settings (stable in "contour only" mode).

If it crash on your image, retry with different settings.

This addon need opencv and triangle modules At first activation, it will try to make an automatic download/installation of modules and their dependancies, if modules folder associated to your installation.
If this doesn't work, go below to manual install.

Want to support my work ? check those links


Description

Automatically tesselate a opaque zone of a texture plane mesh.
You can also just create the contour without tesselation.
The main purpose of the tesselation is to have a some vertices density in the mesh to be able to do "puppet" deformations with some rigging (similar to the puppet tool of After Effects).

Example:
With import image as plane addon, I imported this Ryu drawing image (found randomly on the web for test purpose). "contour only" option generate a mesh with stripped alpha,
otherwise it generate the same contour but fill it with internal triangles.

demo

And after some rig/skinning/animation...

paper ryu rig

...I got Paper ryu!

paper ryu idle

"Papeeer tatsumaki!"

paper ryu idle

Here is the anim pose with wire

paper ryu rig idle anim

Ryu drawing by steamboy (deviant art page), he made a superb animation with pretty much the same technique in after effect (combining multiple layers), see details here


Options detail

Contour only : No tesselation, just mesh the contour of the shape and fill with one Ngon face per separated "island" (stable, use only open-cv module).
Note : does not handle holes.

contour only

Simplify contour : 0=disabled, Approximation treshold of the contour polygon.
Higher value decimate the mesh contour shape.
Note: More simplification need also more pixel margin to avoid cutting though image.

simplify

Aeration : Limit maximum tri area, low value means more density (more triangles).

aeration

Pixel margin : 0=disabled, Dilate contour around shapes.

pix margin

Pixel cleaning : Delete surface with pixel dimensions smaller than given pixel size. (Do not use if your source is pixel art).
Usefull for cleaning unwanted rogues pixels, pushing too much can also erode surface angles.
In the example black part have alpha at 0 (smart test image isn't it ?)

pix clean

Minimum angle : 0=disabled, "quality mesh generation" value, augment the mimimum angle limitation.
The value is not given as an angle but as min/max available. Basically means more triangle with better repartition.
Note : This have a big influence on aeration ! Add more density variation (kind of like Dyntopo for sculpting).
It sizes triangles as needed (usually smaller on the mesh boundary) resulting in a better quality result.

min angle

External contour only : Discard holes or internal shapes, detect only external contour of shapes.

holes

Gift wrap : Close the convex hull of the shape

gift wrapping

UV mask : Generate geometry only on parts enclosed in the UV quad. If False the whole texture is meshed in 3D space.

uv limits

True Delaunay algo : Use another algorithm for delaunay triangulation, conforming delaunay instead of constrained delaunay Triangle module settings. Results isn't so different, but this algorithm make sure voronoï cells are at center of each triangles (can force generation of super tiny tris by complying to this rule).

Additional notes

  • If there is any uv_project modifier in stack, those will be applied automatically before running
  • Any subdivision modifiers will be deleted before applying.

Where ?

Panel in sidebar : 3D view > sidebar 'N' > Tool > Tex plane tesselation

Credits

The addon is heavily inspired by the original Tesselate addon within the rigging scripts released by "les fée spéciales" studio.

Here are the main differences:

  • Compatible with Blender 2.8+/3.0+
  • use Opencv module instead of Scikit+Skyimage (still use Triangle for tesselation)
  • better handling of holes when there are nested shapes (might still not be perfect though).
  • expose a lot of options for tweaking (This also makes it a lot less stable...).
  • Support (slightly) deformed UVs

Manual installation of needed module

This addons use two python modules to work. You have to install triangulate and opencv.
Be sure to download a version compatible with Blender 2.80's python 3.7. This means you ought to have the same python version installed and use pip install through this version. If you don't know how to do that look at "how to install module for specific python version".

If you install through pip with pip install opencv-python and pip install triangle.
You should see the folders of the modules in the python installation directory.
In <python_version>/lib/sites-packages.
Now copy opencv and triangle to the Blender module folder. If you don't know we're your Blender modules folders are, look at "Were are the scripts folder in Blender". (Or video "addons and script installation in Blender", version quick or long).

Opencv should have install some library dependency that you can see listed in console at pip install (make sure to copy them as well)

About module installation :
If triangle doesn't install properly with pip, follow this tutorial on module installation by Damien Picard.


Todo:

  • stability : Sometimes crash blender:
    • exception happen inside Triangle module when PSLG polygon is passed with certains settings or images, dont know how to fix it...

Changelog

2.0.2

  • added: print debug step documentation when enabling the addon with problem with modules.

2.0.1

  • ui: Always show panel, display help text when no object is selected

2.0.0

  • fix: compatible with blender 2.93 / 3.0.0 +
  • fix: improved module auto-install

1.1.0

  • modules auto-install using pip (tested only on windows)
  • UI: redo panel is now the same as sidebar UI
  • Exposed disply wireframe in the UI
  • Added tracker URL infos

1.0.2

  • Main version ready:
    • cv2 contour stable
    • some images/settings can still crash blender in tesselation (using triangle module)

About

Blender addon - Triangulate your textured mesh while discarding alpha zones

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages