Rotate mesh through material using World Position Offset

Hi there,

I’m trying to rotate a mesh (box) around different axises, but I’m not good in this… For now I can only rotate separately by Y or Z, but when I change angles around both axises at the same time, the mesh is getting a weird shape.

How do I need to combine these operations properly?

Hello,

Use Object Position instead of Absolute World Position, this should work better.

Absolute World Position is a different position for each pixel of your mesh whereas Object Position is the position of your mesh, therefore the same for each pixel.

No, this didn’t help. Even more, with Object Position my mesh no longer rotates…

Supply rotation matrix and transform world position using it.

Can you please provide a little bit more details about how to properly combine these ones to achieve desired effect?

Hello again, I tried with Rotate about axis function but I came to nothing. An alternative is to use [rotation matrix][1].

(By the way my previous answer was completely wrong, if you want to rotate around only one axis, use Object position as pivot point and Absolute world position excluding offset as position (or an equivalent like (0,0,0) as pivot point and Local position excluding offset as position). But I found no way to combine 2 rotate about axis.)

RotateX : float3(t.x, t.y * cos(theta) + t.z * sin(theta), - t.y * sin(theta) + t.z * cos(theta))

RotateY : float3(t.x * cos(theta) - t.z * sin(theta), t.y, t.x * sin(theta) + t.z * cos(theta))

RotateZ : float3(t.x * cos(theta) - t.y * sin(theta), t.x * sin(theta) + t.y * cos(theta), t.z)

2 Likes

This info was so helpful. I’m struggling with rotating the normals, now. I see there is a FixRotateAboutAxisNormals node, but that really only pairs with RotateAboutAxis. I’ve read elsewhere that you multiply the normals by the rotation matrix but I can’t seem to get that working.

Any thoughts on getting this working?

Here is how you correct the normals with “RotateAboutAxis” for 1 direction:

And here is how you add multiple Rotations together:

As a bonus this is how you correct for non uniform scaleing:

Is there a way to add the objects “orientation” in the scene. So that the objects rotate individually in “Local space” istead of all of them rotating in worldspace?

Just wanted to post the easier solution. The reason Rotate about Axis wasn’t working for you is because you need to multiply the angle by time. Otherwise it won’t move.

Using the RotateAboutAxis node (Cheap is broken because it inverts the mesh normals if you use Y) you specify the rotation axes with a vector 3 with R = X G=Y B=Z and you can use multiple axes at once (example 1,1,0 will give you yellow and rotate around X and Y at the same time).
Normalize the RGB before plugging it into NormalizedRotationAxis.
Rotation Angle should be Time*Speed
Pivot Point should be the ObjectPivotPoint node
Position should use World Position XYZ

1 Like