Object aligned textures how?

I need object (NOT world) aligned texture mapping. It should take the size from object coordinates (LIKE world aligned from world), ignoring UVs and should live in local object space so it sticks on the objects (NOT LIKE world aligned where you move and rotate objects through the mapping). Pinning the position of the mapping onto the objects is easy: simply subtract ObjectPivotPoint from AbsoluteWorldPosition and you get object space, BUT rotation is very tricky. How to do it and get kind of 3samax “realworld” type mapping, sticking to the objects but scaled by object space?

Before you ask I’m getting a lot of runtime imported objects into the engine and need to assign aligned and real size scaled textures to them.

3 Likes

There’s a material function called “local aligned texture”.

Which sadly uses the objects own UVs to triplanar blend the textures into another. The blending-masks are based on local vertex normals. The mapping is not generated from scene units (absolutensize) like I need them to do.

I think you can use Absolute World Position + Object Position, use a component mask to get just the R & G channels, then divide that number by a Scalar parameter to get the size you want, then plug that into your Texture UV input. Note that this will map the texture along the Global X & Y coordinates (like a flat plane) and then move the position to the Object position, keeping the mapping consistent with the object.

If you want the texture to be mapped along multiple axes, like a triplanar mapping would do, you could plug in the result of Absolute World Position + Object position to the World Position input on the World Aligned Texture material function.

Best of luck, let me know if you have any questions or have a visual example of what you’re trying to achieve!

1 Like

Edit: Just re-read your description, you should be able to use Absolute World Position + Object Position, and then take the output and run it through a Transform node, transforming from World Space to Object Space or Local Space (sorry I’m away from my dev PC so I’m paraphrasing.)

Best of luck!

Any chance of a graphical description of this hippowombat?!

Thanks in advance.

1 Like

Hello there. I found this thread looking for something similar.

This is what I worked out so far - I hope it’s helpful:

1 Like

Does masking the X and Z in CheapContrast provide enough for the mapping of Y too? Asking because I don’t know. What is the function or purpose of multiplying object scale by 100?

For whatever it’s worth, I made a version of this a while ago: How to tile textures WITHOUT Absolute World Position and TextureCoordinate ? - #19 by Arkiras

Mine doesn’t require an object scale input

Originally I was transforming the positions/normals like you were, but another user pointed out that you can use pre-skinned local nodes and that turned out to be cheaper.

Is there any way to do multi object aligned textures? So it tiles seamlessly between objects (like the World Aligned Texture), but doesn’t slide when the objects move?

You can subtract object position from world position, and this solves the problem with texture moving around on your object when your object moves, but when your object rotates, it will still have a problem. Unfortunately there’s no object rotation information (that I know of). The closest thing is object orientation, which is only the objects up vector (but you don’t know how the object has spun around its up vector axis), so you can’t reverse the rotation… if you could, you could probably get back to the original object orientation, but then I think there could be problem with normals and lighting (maybe not). I suppose the only solution is to try to pass in the object rotation to your shader. I’m not sure if that creates a lot of overhead. Seems like a lot of calculation. I think in regular shaders, you always have the translation/rotation info, there’s the model/view/projection matrixes. I don’t know why this standard info is not available in material blueprints.

Ok, I finally got it…

Use WorldAlignedTexture; multiply Local Position by Object Scale and feed that to World Position, then convert VertexNormalWS with TransformVector node from world space to local space and feed that to World Space Normal. Now you can move and rotate your object but the texture will not move.

4 Likes

This is working really fine but there is a way to make it works inside Niagara because right now my problem is when I put it inside Niagara everything is like in world space again. Thanks in advanced!

did you figure this out?

I’ve tried, but without any luck, unfortunately.

thanks man, this is exactly what I needed, dont know how Ive never found this solution before. I was even able to add the offset parameters into worldposition like I needed