Rotate Material UVs by static mesh instance rotation

I have wall static mesh instances and want their UVs always to look down no matter the rotation of the instance, my best bet was ObjectAlignedTexture but it creates some artifacts that hard to deal with is there, maybe a different way to deal with this?
Thanks in advance for any help.

1 Like

Why not use world aligned?

( otherwise I think you might have to put a different instance on each actor )

Few of my instance have faces with angles with creates unseamless textures and sadly I can’t get the rotation of instances or some other kind of information to fix the problem.

1 Like

You certainly can cycle through them and get that info, I have seen it, can’t seem to find it at the mo…

Yeah, just had another look, can’t find the ■■■■ thing. Is this any use?

I looked everywhere online and didn’t really found something in the material that can help, Orientation supposed to do the job but for some reason it gives the orientation of the whole object and not per instance. There are VertixNormalsWS that come the closest but I am using it in ObjectAlignedTexture and with it I have not enough information to find the correct faces that I need to change.

Are they placed manually in the level, or are you placing them procedurally?

Procedurally…

Ok, so if you’re placing them procedurally, you can set the rotation, which means you have the rotation to use as input to the material instance.

Am I missing something here? ( probably ).

Static mesh instance material works on all instances of the same material if I change its UVs rotation every other instance in it changes UVs rotation as well, so I need a way to get info per instance of rotation or some other way because for some reason only that info is not present even tough location and everything else is.

Yes, I realized shortly after putting that comment up, I was being a moron…

You could start with the “Transform Vector” node with local to world. So if you would input the vector (1, 0, 0), so local x direction of the currently rendered instance you would get the world vector out. So if the currently rendered instance would be rotated 90 degrees in z axis, then if you would input (1, 0, 0) you would get (0, 1, 0) out (unless I just swapped the rotation direction in ue4).

And also there is a “vector to radial value” node that might be helpful.

But this process would result in a somewhat crazy workaround.

2 Likes

For those who looking for Instance rotation or orientation for Static Mesh Instances here is the answer you looking for. As @chrudimer said Transform Vector for a vector is the thing that I needed for but it’s not that simple. Two things first, alone the transform doesn’t work so you need to put the output into VertexInterpolator with gives the correct color information for rotation but, I needed the vector in local and not in world but to for some reason I couldn’t just make it into local so first I had to make a Transform into world and then another Transform into local.

To my surprise it actually worked and I got lots of rotation data in colors, the problem is that you get different data per color you input as a vector. So I tested and learned all the colors and found out that each color that you give return another set of colors, so by setting the vector green(0,1,0) and Masking Blue out of it you get the Yaw but if you want to get Pitch you need to Mask Blue out of Blue(0,0,1) and Red(1,0,0) and add them together with gives you the Pitch of the face, of course you need to use few ifs and check the results for negative values and add angles to the ifs for later to use the result in Custom Rotator.

Anyway, it’s quite complex but fun to learn about, I pretty much explained the material so I won’t be posting it here because it’s better to learn how to make it yourself especially here that you need to debug your material as you do so. But be warned I used this material for rotation of 90 degrees only if you intend to use for more complex rotations I suggest trying to use something as World Align or Object Align first because it can be really complicated. Good luck.

There is also a shorter version doing exactly this in the engine functions called “FoliageZRotation” which I’ve just found by accident.