Download

Changing Absolute World Material Instance projection?

Hi all, A while back I posted a similar question about material projection with WorldAlignedMaterials, and while this initially worked, it didn’t solve all my issues. I’ve only just come to understand that when talking about materials like this, ‘RGB’ also refers to the axial planes that the material is projected onto. Before when I wanted to change the vertical projection of my mesh I had to use a ‘Mask ‘B’’ node as the variant in the material.

Learning that WorldAligned materials are computationally expensive I wanted to try a slightly different method. The one I found here works really well, but I can’t figure out how to create nodes that will allow me to have a parameter in the material instance that will allow me to change the projection on ‘R’ and ‘G’ separately, so I can move the R projection and get it where I want it, and then alter the G projection if I need to. I’m not even sure if this is any better than WorldAligned materials, but so far it’s given me a better result.

I’ll post a shots in order of; the current material I’m working with, with the AbsoluteWorldPosition, a shot of the material in-game and a shot of the old WorldAlignedTexture function that enabled me to change the vertical projection of another material. I don’t know if there’s a way the two can be combined, but when I tried changing either the ‘R’ or ‘G’ projection in the other material it didn’t work. Only changing ‘B’ worked.

Hoping someone can help!

Thanks

How about placing the R & G, and B, masks (so 2 different masks) between the final texture samples and the main node? Then a scalar parameter for each projection axis (R=X, G=Y, B=Z) added from Absolute World Position for a whole XYZ mask, and appended for a whole XYZ projection. It could utilize the WorldAlignedTexture node, and the normals could be plugged into the World Space Normal pin on it. I have to say, for the material in question, roughness most likely doesn’t need to be plugged into that whole workup. A simple scalar parameter plugged directly into the Roughness pin on the main node would work well, I think.

In the new material grid, why is Absolute World Position divided by 650?

Thanks for the reply! I shall give it a go and see what happens. I’ll get rid of the roughness too. As for the ‘650’, that number controls the scale of the material and 650 seems to give me the scale I need. :slight_smile:

I’ll see what I can do and get back.

Thanks!

So I probably didn’t end up exactly in the direction you were trying to point me to, but along the way while trying I did come across what’s starting to look like a solution.
I’ve tried mixing in the absolute world position with the world aligned texture using the masking of the RGB values. That part worked fine. You can see this in the first image. In the second you can see the instance created from this, and a horizontal position parameter does appear which is what I’m looking for, but when I alter the value, nothing really changes. I see something moving around but it isn’t the material. It’s the lighter looking shaded area that moves which you can see in the third image. I’m really not sure what I’ve done here but I think it’s getting closer to a result that I want. I just need the texture to actually move. Any ideas?

Thanks

I see. I notice the G and B inputs are now in one mask, and the R input (X axis) is in a mask by itself. And in the preview, the light-shaded area got pushed to the negative Y / positive Z area of the sphere (so -G, +B). The graph needs to get the axes in 3 separate masks, I think, which would be appended together (append node for two, and append node for those plus the last mask). It might prove functional to use a multiply node for the Position parameters and masks, so multiply each mask by its position parameter (Mask R x Position X param, Mask G, x Pos Y param, Mask B x Pos Z param). Do it prior to appending them all, so the wires are going to flow from each multiply output to 2 append nodes. Then connect those to the respective WorldAligned pins. However, I also notice the WorldPosition(V3) pin is empty on the two WorldAligned nodes. Connect from the append nodes to those also, so it’s not misconstruing the moving of position to be biased in terms of normals. That’s my hypothesis of how to set it, at least. It’ll probably need reworking somehow. It’s not easy to do, as I’ve tried several other methods for simply moving a texture / material on objects so it’s not stretched, skewed, or differently mapped on different sides of the same mesh. There’s a video on Youtube about tri-planar mapping, yet it’s only the 2nd of two videos, and I can’t find the first video. It’s about an hour long, and delves into the projection of textures / materials onto 3D meshes in world space, and I think local space too. I thought this aspect of design would’ve become more accessible by now in a game engine, but it’s extremely technical and laborious so far.

World aligned texture in unreal is probably one of the most over complexified methods of triplanar mapping that I have messed around with, if you need simple planar/triplanar mapping, you can copy one of the incredibly simple material function in the image attachments, it will cost way less, and doesnt include a lot of stuff that really isnt useful. My solution wont work extremely well on smooth, round objects but on a path, a block, rugged, uneven terrain, etc, it will work perfectly. For the path in the image you gave, simple planar mapping will work perfectly fine. If you need high quality smooth transitions between sides, try stripping down World Aligned Texture node already put into ue4.

Wow that’s quite a work through. I’ll look into that when I have a little more time. I actually watched the tutorials you talked about. The second part was actually how I put together the second version with the absolute world position. It was a lot of information to take in, especially for someone who has a limited understanding of math. When I need to make materials with tri-planar options I will have to go back and watch again.

I quickly put together the first function you first listed. I’m relatively new to understanding all these ins and outs of making materials etc. I can’t seem to work out how to get this function to work in conjuction with a base colour material. For instance I appended the function (attached to a scalar parameter) into a texture sampler of the base colour and plugged it in and the material remains a black sphere. When I make an instance of this I only have a parameter option for scalar aspect. I wish I had a better understanding of all of this.

I know. The video is a ton of information. I need to watch it again, a few more perhaps. If the simple method you tried didn’t work, it’s probably because it was plugged into the texture sampler’s UV pin, which is essentially for UV coordinates, not for a function and scalar appended. That’s one of the issues with simple methods in the Material Editor. There’s probably something missing, or it doesn’t work because a node is connected to another node incorrectly. Yet there’s no doc and little help on how it all works, what is connectable to what, and so forth. It’s one of the most versatile tools in UE, yet it is bogged down by those aspects and more. Coders need to remember not everyone learning the engine is going to have an extensive background in texture UV space, programmatic math, and how engines map 2d to 3d / vice versa. Not to sound redundant, but it’s really sloppy work and inconsiderate of the user in numerous ways.

All you do is put the scale (in UU) that you want the texture to be, and you stick it into a normal texture sampler’s uv.

Wow that was a simply solution to get rid of errors. Couple of questions following; there are no parameter options in the instance made from this that allow me to move the projection. Should there be? Also the scale of the material is tiny, and even when bumping the scalar parameter up quite high it doesn’t alter the material size. I’m feeling rather hopeless at all of this. Everything I try either half works how I intend or doesn’t.

Attached images in order; 1) material function. Should it be glowing? :’) 2) material editor. Is this hooked up right now? The material sampler at the bottom is what it’s actually supposed to look like, not a solid colour (just a really small scale) as seen at the top. 3) material instance. Only a scalar parameter and that doesn’t work.

Hate to be a bother. Hope you don’t mind answering questions.

Thanks

Only scaling the texture is not going to allow it be moved along the 3 axes in world or local space. It could work for getting the right scale, but positioning the material in-editor (not the material editor) is the objective. One of the main problems is getting the masks to be properly connected to the UVs in the material graph. It was almost solved by the 2nd and 3rd workups @ashbriers did with the horizontal position parameter. But it’s not moving the position exactly how it needs to along the 3 axes (XYZ). And I think it has to do with the mismatch from UVs of the textures (base color, and normal) to world aligned projection in XYZ. If the textures aren’t somehow connected to the World Space pin of the WorldAligned nodes, then it’s going to not work, in how I’m thinking of it. There’s another node that converts world space to local space, so that the reference planes are according to the object the material applies to, and not the game world’s reference planes. This is obvious in a video on Youtube that is on how to project textures (materials) in world space so they’re scalable. When it’s in world space, moving or resizing the object in-editor results in the material staying where it is while that object moves or is resized. It’s usable for changing what part of the material is visible on the object, but it’s severely limited since it requires moving the object. Moving the material is far more practical because it allows for keeping the object where it is, or moving it wherever and scaling it, and then moving the material along object (local) space to position it exactly.

I followed that tutorial as much as I could originally and even when playing around with the material set-up after, still didn’t work. I’m really at a loss. I’m not very good with this side of UE4. Literally every time I try a blueprint whether it be material or other function it will either half work or not at all and it gets frustrating. You’d think something as simple in theory as moving a texture’s projection should be relatively easy, but not at all apparently. I’m taking a break from trying and will come back to it later on.

1: Totally.
2: Yes. it is, but you got the masks mixed up, its supposed to be in rb then gb then rg in that specific order top to bottom or else it well, does that.
3: Scalars work, but see #2.
Edit: Also, Make transformposition Absolute world postion, not world position.

You need to multiply a texcoord node by the scalar parameter (photo #2) to change it in a material instance for it. Effectively, increasing / decreasing the scalar parameter in the instance changes the scale of the UVs.

In photo #1, it seems like the Mask(R) needs to be plugged into the alpha of the second Lerp node (which contains RG and RB), and switch the Mask(B) to the alpha of the first Lerp node (because it lerps RB and GB, both having B…or Z axis…in the Lerp).