Material Function - World Aligned Texture/Normal With offset & Rotation

Should work right out of the box, are there any issues with it?
​​​​​​​

Hi Luos Would it be possible to control the texture rotation by the object Orientation?
This is so if you have a brick texture and you rotated the model to a slope the bricks would not stay and 90deg and stay with the models Orientation.

You’d need to alter (or butcher) the material function for that, and get the object rotation to influence the texture rotation.
Never tried that, it should be possible but currently I do not have the time to figure it out :confused:

How do I use this to enter the ‘physical’ dimensions of a bitmap I am using? For instance, if I add a bitmap of a concrete tile that is 30cm x 18cm in the real world, what do I do? I assumed I would just add a constant for Texture Size Front of 30 and a constant for Texture Size Side of 18.
However, this doesn’t seem to work. Am I missing something?

since your bitmap should be powers of two (and tiling), find a resolution that works for you.
Just a rando 30x18cm texture is not enough information. what is the pixel resolution? is it power of two? (if its not power of two, i cannot help you)

The texure side front has nothing to do with side, as its different sizes for X axis aligned and Y axis-aligned textures. not separate LxB of the texture.
a vector2 for texture scale could be used, but with the lack of information I cannot give more information than this.

So must all bitmaps be square in UE4?

In 3dsmax (software package I am coming from) you can input the actual dimensions of none square textures so they are scaled correctly when rendered. For instance, if I have a single brick (which obviously isn’t square) I input the dimensions of that texture. The following screen grab illustrates this:

On my mesh, I can then simply select ‘use real world mapping coordinates’. It means that the mapping is stored in the material itself so you don’t need to add different UV mapping to meshes all the time.

Is there any workflow that would allow this in UE4?

All bitmaps need to be power of two in ue4, for mipmapping and other optimization reasons. (with some exceptions like UI)
Generally, we have this dev-rule to have an 1024/1024 texture mapped on a 1meter/1meter square. (though nowadays you see more 2k/2k mapped on 1meter/1meter)

There is no real world mapping coordinates in ue4, or at least I have yet to find it.

I would actually suggest to just properly unwrap the mesh, and learn the regular ue4 texture/material workflows, else you’ll be having a hard time.
Regardless, besides trying to use a texture size of 1024 and do some math to scale the x/y I dont see any point in adjusting (or trying to find a solution) for something that’s not really done (in my experience) in ue4. And since I have limited time its also something I dont see happening anytime soon.
My apologies.

Oh man, how come? That is exactly what I am looking for, but when I do those textures become uneven, that is where the surface is narrower they become shrunken, where the surface is wider they become stretched…could you show us how exactly did you do that, please?

This is how it should be (as seen with AbsoluteWorldPosition) with evenly stretched textures across all surface nevermind their size.

…and this is how it looks when I change AbsoluteWorldPosition for LocalPosition - texture on narrow surface got shrunken yet it should be proportionally right as with AbsoluteWorldPosition (that is not shrunken)

EDIT:
So I kind-of achieve - partially - what I want by modifying the function’s SIZE section, but it still looks not quite even tho much better than the original approach I made at first, see this:

This is my MOD to original function (besides changing AbsoluteWorldPosition for LocalPosition)

Now the question is how to fine tuning it even more, so that those textures would really be even in size across all the surfaces as seen in the original authors function?

What I think about is - maybe - some sort of formula that would get the largest surface from the object and make the ratio by comparing the other ones’ sizes and change their respective texture size accordingly…but I do not know how to to that, I just have this idea (maybe wrong, I do not know) - what do you think, guys?

DONE:
Ah, forget my “ratio” idea: I actually got it right, I just forget to change MASK values for the other two masks leaving the same parameters for all of them - once changed all works as a charm now! :p;)

Final LocalPosition version with even textures stretched proportionally right (more-or-less, ehm):

1 Like

Hi @Luos !

First of all, thank you very much for these super useful functions!

Secondly, I came here to ask you if you are still supporting it; I have noticed that, when a mesh is partially rotated, the normals will break (for example, applying a triplanar normal to a cube, and rotating the cube 45º on Z. Side faces will be like ‘half illumited and half dark’).

Thank you very much and best regards!

This is normal (pun intendeD) because they are world-aligned.
Local aligned might be what you need.

I should take another look at the functions in 5.x someday, but I cant promise when due to starting a new endeavor later this month.

1 Like

Thank you Luos! I will investigate that way.

Thanks!

this is amazing, but how can i add roughness and metalic maps? There is only slots for normal and texture … could you please add functions for roughness and metalic ?

hey Tom, apologies for not seeing this message sooner.
Just use the regular (non-normal map) one, that one works fine.

If you channel packed the roughness/normal/AO/etc you can always put a component mask node afterwards to split it.

Hello!

Thanks so much these, they are super useful.

One limitation I came across is the lack of a “Projection Transition Contrast” compared to the default WorldAlignedTexture, which would be super useful in my current setup.

I tried adding an input in the World location checker, but increasing that contrast value outputs weird results:

luos_contrasttransition2

Any clue on how that could be handled?

Thanks again! :smiling_face_with_three_hearts:

Thanks for this !