Godot Version
4.5.1
Question
Is there a way to get local vertex position before skeleton deformation in shader?
I was able to pass the local vertex position by capturing it in an expression as varying in vertex by passing the VERTEX variable. The issue is that VERTEX is already skinned at this point. I’d like to be able to apply surface patterns based on local vertex position, and not have the texturing change when an animation plays back. Is there any way to isolate that local vertex position?
Here’s an example of the results from this on a model with animation

Multiplying VERTEX by inverse model matrix should bring it back to undeformed model space. If you need normals as well, you’ll have to do the same for NORMAL.
Thats not my question. In the vertex stage you dont even need to apply the inverse matrix because it’s still local. What im asking is about reversing the armature deformation influence from bones. It’s baked into VERTEX in the vert shader, and we aren’t provided the bone transforms to reverse them.
Pass the vertex position via the vertex color attribute or bake it to a texture.
1 Like
yeah I ended up just copying the vertex position information to the custom0 channel at runtime in script. It’s not performant.
I’ll probably follow your advice baking it to texture or vert color as an optimization. Surprised there’s no hooks for getting vert position before deformation.
I’ll look at putting together a PR to add it.
You could possibly inject it into mesh data via an import script so you don’t need to do it at runtime.
1 Like
There are BONE_INDICES and BONE_WEIGHTS shader built ins. So if you pass all of the skeleton matrices via an uniform array you may be able to reverse transform the vertex back into bind pose. Sounds tedious though, I’d still opt for baking the original positions one way or another.
1 Like
You could possibly inject it into mesh data via an import script so you don’t need to do it at runtime.
oh this is the winner for my short term needs! I’ll look into the tooling needed for that, but this seems like an intuitive way to inject the data I need without a ton of overhead. I appreciate your thoughts!
1 Like