Rotate texture around two axis

Hi!

I’m using Unreal 5.4.4.

I have this material:

Now, I can rotate around Z axis changing the value of CubemapRotation parameter, but I need to rotate around X axis.

The value I need to rotate the Z axis will always be different from the value I need to rotate the X axis.

How can I do it?

Thanks a lot!

I want to rotate a texture around two axis: first X axis, and then Z axis. Is that the way to do it?

I don’t know if I have to add it, like I did, or use the first rotation as the Position pin of the RotateAboutAxis node of the Z axis.

It’d probably be cheaper and easier to define one up vector, and just use a transformation matrix to align the whole coordinate system with that vector. I think there’s a pre-built node that can do this. Can’t remember it’s name for sure off the top of my head - transform fixed basis or something like that? Anyway, you can put in your coordinate system and an arbitrary facing normal vector, and that becomes the new up vector.

Thank you very much for your answer, but I haven’t understand anything. I’m newbie and I don’t know how to do that.

I can probably make an example later tonight if you’re still stuck by then.

Thanks. Meanwhile I will learn about transformation matrix, facing normal vector, up vector, etc.

1 Like


The camera vector would be your UVs, in this case since it’s a skybox the camera vector is a good choice. Atmosphere sun light vector would be your “Up” vector. Replace it with whatever your desired vector is. The sun vector just makes for easy testing because you can see the rotation align with the sun. The Transform to Fixed Frame just makes the coordinate system relative to the Z vector. Center should be left empty for this case.

1 Like

@BananableOffense Thanks for your answer, but I don’t see where I can set the value of the rotation for both axis.

As you can see in this image there are two parameters to change the rotation in X and Z axis independently.

How can I do that with your solution?

Not sure if this is what you are looking for but give it a try

Seeing as you are adding the vectors to get the rotations I doubt using the same absolute position would be ok as one has already taking in transformed data. Using the already transformed vector position by the earlier rotation seems to give more stable results.

Not a 100% sure the transform is correct as it causes some slight nausea so some parameter might still be off.

Time based

Alternatively you could use a mesh and a material like this:

Then internally rotate the mesh component

Another option is to input the vector parameter directly into two axis

This does not give you exact speed controls of the rotations but one axis takes on the for of a fraction of the rotation speed. (seems one of the more sane options)

1 Like

You wouldn’t set a rotation value of each axis with this method, you set the vector which is supposed to be “up”.

This allows you to rotate in any direction with a single float3 value.

It is possible to convert from rotational angles to a unit vector using trigonometry if you need, but it will add extra expense to the shader.

That’s what I finally did. I created this material:

And rotated the static mesh.

I’m not sure, because I’ve read a lot of things these days, but it could be that someone advice me that it is better to rotate the material instead of the mesh. The thing is that if I rotate the mesh it does its work.

Thank you for your time and for all of your solutions.

It boils down to two things:
Rotate material = work on the GPU
Rotate mesh = by default work on the CPU

You can rotate the object on the GPU but it’s similar to the material function with rotate about axis:

1 Like

I will rotate very, very slowly.

What I need to do is tilt the skybox and then start rotating it. To give an example, it is like the Earth, which has its axis of rotation tilted by 23.5 degrees and rotates at that tilt. This is why I need to rotate the texture (or material) around two axis.

Then most of my examples work ok in that regard. You can set both axis.

1 Like