Using Geodesic Voxel Skin Binding in Maya Standalone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Introduction
I aim to create a script for Maya Standalone that automatically applies weight painting using the Geodesic Voxel method. This method gives the best results compared to the other bind skin methods but relies on an OpenGL buffer to voxelize the mesh.
To recreate the current problem
This is a stripped-down version of my script currently:
## Open a new Maya Scene, import a mesh, create a basic skeleton and name the root bone "Rig Root"
## Save the file as Maya Ascii and put the path in the maya_file_to_open variable
import maya.standalone
maya.standalone.initialize("Python")
import maya.cmds as cmds
maya_file_to_open = r"path/to/test/file.ma"
opened_file = cmds.file(maya_file_to_open, open=True, force=True)
mesh = cmds.ls(tr=True, v=True)
cmds.skinCluster(mesh, "Rig_Root", bm = 3, sm = 1, dr = 0.01, name = "MeshCluster")
cmds.geomBind('MeshCluster', bm = 3, gvp = [256, 1])
Maya version: 2023.2
OS: Windows 10 Pro 64-bit
Processor: AMD Ryzen Threadripper 2950X 16-Core Processor (32 CPUs), ~3.5GHz
NVIDIA driver version 527.56 (Optix 60805)
GPUs: NVIDIA GeForce GTX 2080Ti, NVIDIA GeForce GTX 1080Ti, NVIDIA GeForce GTX 1080Ti
Memory: 64gb
To run this script I use Command Prompt and the following commands:
cd C:\ProgramFiles\Autodesk\Maya2023\bin
mayapy.exe path\to\test\script.py
Doing so results in the following error:
Traceback (most recent call last):
File "path\to\test\script.py", line 15, in <module>
cmds.geomBind('MeshCluster', bm = 3, gvp = [256, 1])
RuntimeError: Unable to create an offscreen OpenGL buffer.
Failed computing weights.
Definition of the problem
In an article by Olivier Dionne and Martin de Lasa from 2013 called "Geodesic Voxel Binding for Production Character Meshes" doi:10.1145/2485895.2485919 I found a description of how the Geodesic Voxel method for binding skin was developed.
The way they voxelize meshes is by rendering cross-sections of the model from each axis I suspect this is what they are storing as an OpenGL buffer. The voxels are created based on the position of the pixels, but since I am running the Geodesic Voxel command in Maya standalone, no pixels are created, and therefore, no voxels.
In the 2022 documentation of the geomBind command, It is mentioned that the command uses GPU acceleration and is therefore not supported on headless versions of Maya. In the documentation of the same command in earlier years it is not mentioned.
Possible solutions?
It looks to me like this method was developed quite some time ago. These days there are new ways to voxelize meshes such as described in this article: how-to-voxelize-meshes-and-point-clouds-in-python . These techniques don't seem to be relying on OpenGL buffers and therefore be applicable to a Maya Standalone script.
Another solution might be to run a secret window in the background using something like PyQT5 or PySide. I am uncertain what the window would have to display for the Geodesic Voxel command to have access to an OpenGL buffer but it might just work.
Any workarounds, solutions, ideas, or insights are welcome.