Is there an Object Rotation Material Node?

I’m looking for a material node that will retrieve the Object Rotation (Yaw,Pitch,Roll). Is there such a node?

I am Tick bound in my project, so I’m hopping that I can avoid using Event Tick to pass along the rotation to the material. Any help is appreciated!

I’m assuming this is to create a situational change in the material?

In the Content Browser, create a Material Parameter Collection. You add vector or scalar properties and name those tracks, set those properties by calling it in a BP, and then call and get those properties in your material. You could have some scenario in a BP that gets the rotation, then sets the properties of the parameter based on what’s happening.

You can simply drag the parameter into your material and hook it up however you need. Remember to click the node, go to the details, and make sure it’s using the appropriate track that you created earlier (default is none)

Let me know if you need any illustrations, or if that’s not quite what you were wanting

Hi DeviousSupernova, thanks for the response :slight_smile:

I should have been specific about my uses in my original post: I’m looking to rotate a billboarded mesh according to the actor’s Rotation (specifically the Yaw).

I do currently have it working through a dynamic material’s scalar parameter, but this requires the actor to Tick every frame. I was hoping to disable the Tick on the actor, since it is such a large bottle neck at the moment, and instead use a material node (It’s looking like this node doesn’t exist, however).

Your solution probably lies in Timelines if you’re worried about Tick. I replaced every instance of Tick in our project with Timelines and we saw a significant performance boost. They can be played/stopped/reversed, set to any length of time or loop until stopped, output values based on graphs within its editor, and fire off a final thang when it finishes. It’s a great way to keep control over process that are perpetual, but temporary

Oh okay! New answer

Although this should help with my immediate performance problem, I’m going to leave the thread opened in hopes that someone might know if there is (or isn’t) a node that can retrieve an object rotation in a material.

Thanks again Devious :slight_smile:

Does that help?

That’s nifty, I’m glad to know about it now (thanks!) :slight_smile:

It’s not quite what I’m looking for though. I don’t need the material to rotate, I need to make the material change based on the object’s rotation (an equivalent to the “Absolute World Position” node, but for rotation)

That’s almost certainly something you’d have to setup through parameters. I definitely haven’t seen any kind of material node that can pull data like that from external actors

Maybe it is possible trough the Custom node: opening the ObjectLocalBounds node you can see a couple of custom nodes with HLSL code like “” (float3), so maybe there is something like “” in HLSL.

I repeat, maybe there it is and maybe not, trying random code in the custom node (LocalObjectRotation, LocalObjectRot, etc…) didn’t give me any success, but still i can’t find online any reference to the Primitive class or any of its fileds…

I found the solution on this Japanese blog post:

Add a custom node with these contents to retrieve a Float3 containing the object’s rotation in radians (recommend making this a material function):

float3x3 WtoL = LWCToFloat(GetPrimitiveData(Parameters.PrimitiveId).WorldToLocal);
float3 R = float3(
atan2(WtoL[2].y,WtoL[2].z) * -1.0,
return R < 0 ? 2 * pi - abs(R) : R;

In this case, pi is an argument to the custom node. (the pi node is being plugged in)
To convert to degrees, multiply the result by 57.2958.

Note that if you want to use this in the “RotateAboutAxis” material node, Component Mask out the degrees value of, for example, B (yaw), divide by 360 (RotateAboutAxis uses a 0-1 scale for rotation), and input it into RotationAngle. Add the result of the RotationAngle node to the initial vector that you’re rotating in order to acquire the final rotated vector.

Edit: It looks like the above code is returning an incorrect Y value. Refer to this thread for more details: Get Actor x, y, z rotation angle in shader - #6 by mpxc

1 Like