UV offset based on the rotation of the head bone

Hi. I was reading the material expressions guide but I couldn’t find something that can help me on the following setup:

GENERAL IDEA: Rotate the head bone of a character and offset the UV map texture for the face.
CONDITION: Every 15° rotation the UV offset “SNAPS” to its following coordinate offset.

The UV map is a 2560 x 512 pixels wide picture (512x5 in X).
From 0 to 15° head bone rotation, the UV coordinate stays in its origin. If the bone goes beyond 15°, the uv coordinate will be offset in X by the 512 amount of the next position.

I did this quick screenshot so you can get the idea. Each “colored” region will be the offset to which the UV coordinate should be moved based on the angle of the head bone rotation of the character.

Is it possible to set an expression that reads the bone rotation in X, passes that value to the UV offset coordinate, conditions it to evaluate if it has passed a 15-degree rotation, and if it has, it will “snap” the UV coordinate immediately by (x-amount) offset value?

Please help.

bump.

I would like to know how to read (any) bone rotation from a character, to use that value in a shader offset for the UV coordinate, please.

There’s a ‘get bone rotation by name’ node.

You can send it as a parameter to the shader.

I would recommend making the texture a square, and make the smaller squares part of it, a bit like a flipbook.

You can also use a flipbook node to read the data from the textue.

1 Like

Yes, I looked at the flipbook and the panning node. But all I need to understand is how to pass the value from the bone Y (yaw) rotation to the shader UV coord to offset. I can use an “add” depending on the roll.

Also, if you read on my original post, the rotation angle is to be evaluated. Once it reaches an increase of 15º, it should “snap” the uv coord to a new value offset (generally 0.2 in a 4 UV image flipbook)

1 Like

The snapping will happen courtesy of the flipbook node. As long as you convert the head angle into a float between 0 and 1.

I don’t know what nodes I could use to do that. (convert angle to float)

1 Like

An angle is already a float, so they’re both floats :slight_smile:

There’s a node ( I seem to recall, not at a machine rn ) ‘map range float’ or something like that. You can use it to scale from one to the other.

The only real ways to “send” the variable value onto the shader is going to be via:

  1. MPC - material parameter collection.
  2. Dynamic material, created from an instance in code, to which you can set a scalar value over tick or during an event.

CONDITION: Every 15° rotation the UV offset “SNAPS” to its following coordinate offset.

you can frac the value you input in, then range-remap from 0 to 15.
I doubt it will work as you intend though.

Also non-square textures are a no-no.

1 Like

bump. still waiting for someone who is actually in front of their screen to share a screenshot.

This is the blueprint of the 3rd person, which prints to screen the current head rotation in Y


This is to continue the thread.

Now, how do I pass the value of the local Y rotation of the “head” bone from the 3rd person mannequin (Quinn) to a shader, so I can offset the UV coordinates by 0.5 every 15º head rotation?