# Get Actor x, y, z rotation angle in shader

**URL:** <https://forums.unrealengine.com/t/get-actor-x-y-z-rotation-angle-in-shader/155362>\
**Category:** Rendering\
**Tags:** unreal-engine\
**Created:** [December 21, 2020, 2:08am UTC](https://forums.unrealengine.com/t/get-actor-x-y-z-rotation-angle-in-shader/155362 "2020-12-21T02:08:45Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![neofuturelabs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/neofuturelabs/32/1194562_2.png) [@neofuturelabs](https://forums.unrealengine.com/u/neofuturelabs)\
**Post date:** [October 6, 2022, 3:08pm UTC](https://forums.unrealengine.com/t/get-actor-x-y-z-rotation-angle-in-shader/155362/6 "2022-10-06T15:08:28Z")

</div>

I found the solution on this Japanese blog post:

> **[【UE4】ObjectのRotationをMaterialから取得する方法 【★★☆】 | キンアジのブログ](https://kinnaji.com/2019/08/19/getanglefrommaterial/)**

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

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

```

You will need to add pi as an argument to the custom node.  
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.

---

_[View the full topic](https://forums.unrealengine.com/t/get-actor-x-y-z-rotation-angle-in-shader/155362)._
