I am currently working on bringing in the Vector Displacement functions of Mudbox and Zbrush into Rhino and am encountering quite a few issues. The primary issue is in the compression of a three-dimensional mesh into an unwrapped pattern. This would function similarly to the squish command in order to associate 3D vertexes with their flattened 2D counter parts. Has anyone worked on this issue previously or does anyone have suggestions for tackling some of the conceptual issues associated with Vector Displacements in Python for Rhino? Below are links to Mudbox and Zbrush pages for their Vector Displacement functions. Thanks!
Also, the reason for writing it with Python in Rhino is for the control of specific input and output parameters to work with learning models, which will be integrated at a later time.
I think the best guy to say something about displacement is @Jussi_Aaltonen, but here goes my understanding of what you should do:
For an object you want to apply a vector displacement map to:
get the current render meshes for the object
ensure you get texture coordinates in these meshes
for each vertex:
figure out the texture coordinate
sample the map
modify the vertex according the sampled data
For a good displacement you probably need to control the density of the render mesh being created. You can tell Rhino how dense the render mesh needs to be when requesting it for the given object.
Since you are working with IronPython you’re probably best of creating this as some sort of simple command that acts on selected objects, creating new mesh objects based on the given inputs (objects + map) and add those to the document.
Here is how you can request meshes from an object in Rhino using Python
If you need this to work automatically for a selected object you’ll have to create a plug-in that implements a CustomRenderMeshProvider2, but I think you’ll be able to get started with a ‘simple’ script.
I don’t know of any functionality that would do this automatically. Unwrap command in Rhino uses LSCM for this but it requires user to pick the seam edges. And this functionality is not accessible in SDK or RhinoCommon.
Jussi, thanks for the reply! The LSCM reference is very helpful, I’ve found a few tips regarding this and boundary first flattening methods that should help me out. Thanks again!