I have this issue that whenever I add a decal as a component to an actor, it is rotated by 90° around the y axis for some reason and so all you see is a small line.
The top image displays the decal with a relative transform of 0,0,0 for everything. The bottom on is rotated by 90° around the y-axis.
This wouldn’t be too much of an issue if I didn’t want to do some math with this decal. But since I do, it starts to become a major annoyance that shifting the decal along the x-axis actually shifts it along what I would have expected to be the y-axis.
Why is it like that? Did I mess up the setup of the decal material?
Yes, the Unreal decal object treats “X” as “surface normal,” which means you frequently need to re-orient it compared to other geometry with another orientation.
The choice is a little weird to me, because in shaders, Z is the surface normal, but it is what it is. Someone thought “X should be forward” (fair enough) and “forward is the surface normal direction” (which also kinda makes sense, because that’s the only well-defined direction.)
And that’s how the code was written, and now it can’t ever change, because that would break everything.
So this means that even if it is unintuitive to me, it is still consistent in it’s unintuitiveness and all I need to remember is to add a rotation of 90° around y each and every time?
I’m using the same parent material for all my decals and just derive material instances for them. Is it possible to add an intrinsic rotation to the parent material’s texture sample parameter using a texture coordinate or something similar?
There is a UV input pin on the Param2D node. Maybe that can be used to rectify this?
The rotation is on the geometry, not the material – you cannot rotate “into the plane” in a material shader.
So, yes, you need to remember to add this rotation yourself for each decal object, if you use a different convention for which way is “forward.”