- Home /
Access skinned mesh vertices
Hi,
I want to access the mesh of a skinned mesh - not the shared mesh, but the actually deformed one.
In my particular case I need to get and change the vertex positions and vertex colors, but I can think of some situations where this would be nice to do:
- snapshotting a mesh to use it for something else (e.g. as new MeshCollider mesh)
- adding morphs after meshes are skinned
Is skinning done on software or on hardware? If Unity uses hardware skinning, I assume I cannot acccess the vertices as they are only deformed by the graphics card. Then the only way would probably be to write my own software skinning algorithm (and I don't want to do that).
But I read that Unity since 2.5 uses "multithreaded mesh skinning" , and that would mean it is done software-side and is somehow accessible. But how?
Answer by mattirwin · Jan 26, 2011 at 09:30 PM
I know this is an old question, but I was looking to do something similar and found a good script on the Forum. This code is working for me, although my current mesh and bone setup is fairly simple.
Have a look here:
http://forum.unity3d.com/threads/14378-Raycast-without-colliders
Thanks! I still have to test whether this kind of "software skinning" is fast enough for my purposes, but maybe I can reanimate the project now :)
Weird follow-up: The script when compiled into a Windows standalone seems to be sensitive to the Api Compatibility Level. Everything is cool in the editor, but make sure you have the above set to ".NET 2.0" and not ".NET 2.0 Subset".
The latter was giving me false hits on the updated mesh collider. I have no idea what would cause this.
Answer by Aras · Jul 11, 2010 at 11:20 AM
Yes, skinning is performed on the CPU (and multiple skinned meshes are transformed on separate threads to exploit multicore CPUs). However, right now there's no API to access post-skinned meshes.
Would your "extra modifications" be possible to do in a vertex shader? This would not solve "I want to create colliders" problem, but some types of deformations should be possible to do in a shader.
What I want to to is to set the vertex color based on the motion of the vertex in the last frame. I don't think it can be done in a shader because the changed vertex colors can't be "written back" to the colors for the next time drawing. It works perfect for normal $$anonymous$$eshFilter objects, and I had not thought it would be harder to do for skinned meshes...
Your answer
Follow this Question
Related Questions
Manipulate skinned mesh? 1 Answer
Mesh from Vertices (Polygon from Spline) 3 Answers
Mesh Vertex 0 Answers
skinmesh component is not in mesh? 0 Answers