0

TLDR: Can't figure out the correct Shader Graph setup for using UV and vertex displacement to cheaply animate a (unrigged) mesh.

I am trying to rotate a part of the mesh based on the UV coordinates, e.g: fromX 0 toX 0.4, fromY 0 toY 0.6. The mesh is created uv-mapped with this in mind.

I have no problem getting the affected vertices in this area. Problem is that I want to rotate these verts for customizable axis e.g. axis(X:1, Y:0, Z:1) using a weight so that the rotation takes place around a pivoted point. I want the bottom selection to stay connected to the rest of the mesh while the other affected vertices neatly rotate around this point. The weight can be painted by using split UV channels as seen in the picture: enter image description here

I multiply the weighted area with a rotation node to rotate it. And I add that to the negative multiplied position (the rest of the verts, excluding the rotated area) to get the final output displacement. enter image description here But the rotated mesh is bent. I need it to be stiff as in the whole part rotated with weight=1 except for the very pivoting vertex. the mesh with zero rotation enabled weighted poor rotation and pivot point

I can get it as described using a weight=1 based rotation, but the pivot point becomes the center of the mesh, not the desired point.

desired rotation but lacking needed pivot point

How can I do this correctly? Been at it for days, please help :')

Alx
  • 651
  • 1
  • 9
  • 26

2 Answers2

1

I started using Unity about a month ago, and this is one of the first issues I faced.

The node you are using will always transform the vertices around the origin.

I think you have two options available:

  1. Translate the vertices by the offset of where you want to rotate the wings. This would require storing the pivot point of the wings in the mesh somehow - This could done by utilizing a spare UV channel, or by using the vertex color channel.

  2. Use bones and paint the weights in your chosen 3D package. This way, you can record the animation, and use Unity's skinned mesh shader to render it.

Hope that helps.

  • Thanks for the reply. I had considered these two options, although I wish there was a better way. Another method would be to align the mesh so that the wing pivot becomes the origo 0,0,0.. Still holding out for another answer because it might be possible with some shader graph trickery I don't know about. :) – Alx Jun 01 '20 at 04:45
1

Try this:

I've used the UV ranges from your example applied to a sphere of unit size. The spheres original pivot is in the centre, and its adjusted pivot is shifted 0.5 on the Y axis.

The only variable the shader doesn't know, is the adjusted pivot position; so I pass this through the material.

I've not implemented your weight in the graph, as I just wanted to show you the process. You can easily plug that in.

The color output is just being used for debug purposes.

The first image is with the default object pivot. The second image is with the adjusted pivot. The final image is the graph. (Note the logic group is driving the vertex rotation based on the UV mask).

Default object Pivot

Adjusted pivot position

Graph

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Sorry for the late reply. I have been trying your graph in the past days and while I see how it handles the pivot nicely, I'm having problems pinpointing the pivot itself. I am now looking into converting UV coordinates to barycentric 3D coordinates so that I can define the pivot in the UV shell. What do you think about such an approach? – Alx Jun 03 '20 at 06:57