# Triplanar texture - projected from Local Space?

The unwanted results of using World aligned texture + rotation. (the textures on the sides also gets artifacts due to the triplanar blending)

Is there a way to keep the features of World aligned texture; like - the texture remains independent from the scaling of the object, but fix the limitations - such as when the object is rotated - the triplanar projection is not oriented with the original object and thus creates artifacts and the alignment with the object is broken?

Such texture could be VERY useful with cubic geometry - for creating all sorts of buildings and architecture.

I donâ€™t know how to do thisâ€¦ but I am thinking - a triplanar texture that is projected in the local space of the object? thus making transformation like rotation of the object in the world - to have no effect on the positions of which the triplanar projection is made, or simply - triplanar projection fixed to the object itself and to its own local orientation.

I imagine something like this:
Subtract the origin world position from the vertex position.
Then, use TransformVector(WorldToLocal) on the VertexPosition and Normal.

I canâ€™t follow really the Substract idea because I am missing too much info and I am bad at this.
But you give me an idea - because I didnâ€™t know that TransformVector node canâ€¦ transform from one space to another.
So I open up the Unrealâ€™s World aligned texture function and modify the two transform nodes there like this:

Now I indeed have a local triplanar projection, and rotation now worksâ€¦ the problem now is that if I stretch the mesh - the texture stretches tooâ€¦ So this just replace the feature I wanted - for another that I wanted, but didnâ€™t combine themâ€¦

Currently youâ€™re executing TransformPosition on AbsoluteWorldPosition.

If you instead subtract the position of the object from AbsoluteWorldPosition first, then use TransformVector on the result it should ignore the local scale.

You can get the object position by transforming (0,0,0) from local to world.

Well, this is wrong, but I am posting itâ€¦ Now the texture indeed seems to trying to scale independently when I scale the object, but it still continues to stretch with the object.

I am sorry, but all I can really do is to try to brute force the problem, and I doubt I can solve it like that. Could you post a solution if that doesnâ€™t bother you?

Youâ€™re close, thereâ€™s two options.

If you use this exclusively with meshes, you can just connect object position straight into the subtract here.

Or if you want it to be slightly more flexible, you can connect 0,0,0 into the transform, then connect that into the subtract.

Problem is, I already try those and they didnâ€™t workâ€¦ Here is the result:

The previous post gives no better results, but the scaling of the texture seems to at least trying to be independent from the objectâ€¦ although as well - fail.

1 Like

Hereâ€™s a working Object Aligned Triplanar Material Function

The texture UVs scale with the objectâ€™s world dimensions, but stay aligned with the objectâ€™s local orientation. It also handles normal maps properly and mirrors the â€śbackâ€ť axis projections.

5 Likes

Standing on the shoulders of giants applies full power here. I am speechless. This is some fine fine work. Thank you sir, this is game changing function, extremely useful.
Ok, again because that thing is incredible - thank you, respect!