- Home /
Shader Vertex Position During Animation
I'm using a normalized local X vertex position to detect if a vertex is on the right (1) or left (-1) of the mesh, but the problem is during animations the vertexes are swapping 'sides' and it's messing up my shader. For example during an IK head turn (to the right) the left cheek crosses from negative local position X to positive during the head turn.
Does anyone know of a solution to this?
Answer by Pangamini · Dec 07, 2016 at 11:55 AM
You could store the original vertex position (or just the 'side' information) into buffers you don't need, eg. uv2, color and use that instead of skinned vertex position; To do that, you could duplicate / modify the mesh on runtime (once, in Start or somewhere) or do it offline in the editor (I haven't tried this, but I think you can modify the MeshImporter to do custom stuff to meshes created from files on import)
Thanks that worked great. I used vertex colours, painted one side red, one side blue and did R*-1 + B
No problem. Tehnically it works and there's no problem in it, but if you wanted to conserve channels (to use color for something else) you could just use Color.R, for 0 being left and 1 being right
Your answer
Follow this Question
Related Questions
Shader vertex position depends on camera ? 1 Answer
How to get the position of a vertex in a particles-shader? 0 Answers
Vertex Animation Shader Not Compatible with Android 2 Answers
Clarification on static batching a shader-animated mesh 1 Answer
How do you get the world position of a vertex in a shader? 1 Answer