How can I get worldMatrix in Material Editor ?

I know TransformVector node but I want to modify worldMatrix to remove rotation and assume a non-rotatable object for my special material effect .

"
If you want to modify the world matrix of an object to remove its rotation, you can use the “Decompose Transform” node in Unreal Engine 5’s Material Editor.

First, create a “World Position” node to get the position of the current pixel in world space.

Next, connect the “World Position” node to the “Decompose Transform” node. In the “Decompose Transform” node, set the input to “World Transform” and the output to “Translation and Scale”.

Finally, connect the output of the “Decompose Transform” node to a “Transform Position” node. This will convert the translated and scaled world position back to local space.

By doing this, you will effectively remove the rotation component of the world matrix and assume a non-rotatable object for your special material effect."

  • ChatGPT

Sorry but this decompose node not existed .

I apologize for the confusion. You are correct that the “Decompose Transform” node does not exist in Unreal Engine 5’s Material Editor. Instead, you can use the “Transform (Vector)” node to remove the rotation component of the world matrix.

Here’s how you can achieve this:

  1. Create a “World Position” node to get the position of the current pixel in world space.
  2. Create a “World Normal” node to get the normal of the surface at the current pixel in world space.
  3. Create a “World Tangent” node to get the tangent of the surface at the current pixel in world space.
  4. Create a “Cross Product” node and connect the “World Normal” and “World Tangent” nodes to its inputs. This will give you the surface binormal in world space.
  5. Create a “Transform (Vector)” node and connect the “World Position” and “Cross Product” nodes to its inputs. Set the “Transform” input to be the “WorldToLocal” matrix of the object you want to assume is non-rotatable. You can get this matrix using the “Object Position” and “Object Rotation” nodes, and connecting them to a “Compose Transform” node with the output set to “Local to World”. Then, connect the output of the “Compose Transform” node to a “Transform (Matrix)” node, and set its “Transform” input to “Inverse Transform”. Finally, connect the output of the “Transform (Matrix)” node to the “Transform” input of the “Transform (Vector)” node.

This will transform the world position and surface binormal into the local space of the non-rotatable object, effectively removing the rotation component of the world matrix.