Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Is it possible to "lock" a worldaligned texture?

I somewhat recently discovered the worldalignedtexture node, and it has revolutionized how I design environments. However, I am wondering if I can use it with animated objects without the texture changing.

So more specifically, I am wondering if it is even possible to "lock" or "bake" a world aligned texture when an actor is spawned, so that it can be moved, rotated, or animated without the texture changing. For example, say I wanted to model a boulder with a world aligned rock texture for variation, with moss on the top side, and be able to roll the boulder, and for the texture to perfectly roll with it, as if worldalignedtexture wasn't used at all.

Product Version: UE 4.14
more ▼

asked May 03 '17 at 12:09 AM in Rendering

avatar image

1 1 2 4

avatar image Imagine-Games Jun 01 '18 at 05:25 PM

im wondering if you ever got a solution to this.. im using world aligned because it fixed so many of my UV problems directly in unreal editor, but if i have something like a moving iceberg using world aligned texture it looks ultra silly...

avatar image rattmeeves Jun 04 '18 at 05:44 PM

I found something close to what I wanted, but not exactly. I had to do some 'under-the-hood' experimentation to get it to work properly.

Basically, I looked through the engine content folders and found a material function called "LocalAlignedTexture", or something like that. I don't believe it was a finished function, as it didn't seem to work properly by itself. So I messed around with it until I got it to accomplish what I wanted.

When applied to an actor, it would seamlessly wrap the texture around the whole object, and when rotated, the texture stayed fixed. This is really nice for doors that swing on a hinge, and don't need an intentionally mapped out texture (I used it for a basic white door with a couple different wood grain textures). It's especially nice, because you don't have to manually map out the UVs for the mesh--although you will need to give your mesh an 'automatic UV' layout to avoid texture stretching.

Will this work for your project? It sounds like it. But my original intention was to be able to do this with a texture 'start position', which would be linked to the actors starting point, and then be locked. The local aligned function I used locks the texture, but I believe it will map out the same exact way on a duplicate actor at a different world location.

To summarize, I had two intentions: 1) Texture automatically wraps around actor seamlessly so I don't have to go through the hassle of manually UV mapping every mesh. 2) Give texture a 'start position' that is offset by world location, and remains locked when moved or rotated.

I found a way to accomplish the first intention, so my problem is half solved. If you or anyone else have an idea that might work for the second part, let me know!

Imagine-Games, if this looks like any kind of solution to you, let me know, and I can post a screenshot of the function I modified.

avatar image Imagine-Games Jun 04 '18 at 05:51 PM

thanks for your detailed explanation. I found out a solution on my own as well here is a screenshot alt text

by using world aligned function with a world position using a local position function it locked into place (so the icebergs material are locked onto it even if it is moving)

I did it for the same reason as you, as the icebergs used where originally very low poly and then i subdivided them and I don't have much time to setup uv maps for each and everything in the game so world aligned seems like a quick fix for almost everything that has an issue with the uv map

avatar image script526 Jun 09 '18 at 08:47 PM

Buddy could you please show us how you created a UseLocalPosition node?

avatar image script526 Jun 09 '18 at 09:23 PM

Oh sorry, it's a simple switch statement. Anyway, your method doesn't solve the problem at least in my case. World Position node doesn't affect (texture still swimming while the object is moving). The Local Position node works fine but the texture is stretching.

avatar image Imagine-Games Jun 10 '18 at 12:57 AM

https://youtu.be/F4n5KxZS38E i made a quick video showing how it worked for me... so the object is now moving but the materials are locked onto it.... and there is a scale setting so you can fine tune the texture stretching depending the static mesh you use and how you scale it...

avatar image script526 Jun 10 '18 at 01:05 AM

Wow thank you for the video! I'll try out scaling feature tomorrow and give you a feedback!

Don't remove the video please.

avatar image script526 Jun 10 '18 at 12:39 PM

So I've played around your material and found out what the issue is. Texture projects fine while the mesh is facing X or –X direction. When I rotate the mesh — texture gets distorted. Texture stretches if rotating the object after simulation is being started as well. Moreover, I've tested this material with the starter content simple objects and I ended up with the same issue so there's nothing wrong with my mesh I believe. Scale parameter doesn't help unfortunately.

I believe you will get the same stretching if you try rotating your object.

Facing X alt text Rotated by 30 alt text Rotated by 60 alt text Rotated by 90 alt text alt text

As you can see while rotating the object texture starts fading out and instead of perfectly applied image I start getting the stretched one. That's weird.

facingx.jpg (399.3 kB)
rotated-by-90.jpg (385.5 kB)
rotated-by30.jpg (400.0 kB)
rotated-by60.jpg (382.2 kB)
material.jpg (94.0 kB)
avatar image rattmeeves Jun 14 '18 at 04:01 AM

I'll have to post the function graph that I edited, because I initially ran into the same problem. I was able to get rid of it. Not in the way that I wanted, necessarily, but it worked. I'll try and post that soon.

avatar image script526 Jun 14 '18 at 12:22 PM

Nice. Would be interesting.

avatar image rattmeeves Jun 19 '18 at 01:15 AM

The first image is the 'LocalAlignedTexture' material function, located in the Engine Content folder (just search "local" and it will pop up). If you look closely, you'll notice there's a section of the material that apparently never got finished. And the part that is causing the weird texture tearing, is the XY Output. If you look at it, you'll see that the texture is one flat color. alt text

The second image is my modified version, which includes the ability to rotate the texture (useful for using material instances for wood grain textures on doors). If you look at the graph, you should be able to figure out what I did differently, although please notice that the 'texcoord' nodes are [0], [0], and [2]. This is because using [1] results in the flat color, which in turn causes tearing. I don't fully understand how all of this works, and I'm sure there's a more efficient way to do it, but obviously the UE4 team didn't even take the time to finish it, so I at least took it a step further. alt text

Let me know if any part of this is confusing, and I'll do my best to explain. Please also let me know if it works for you!

mat1.png (186.3 kB)
mat2.png (255.5 kB)
avatar image script526 Jun 21 '18 at 11:20 PM

And what is your actual material looks like?

avatar image rattmeeves Jun 29 '18 at 01:44 AM

So I went back and put my material on a different mesh, and discovered that it wasn't actually working the way I though it was. Coincidentally, the meshes I had used all worked well with it, and right after I posted the graph above, I tried it on a new mesh, and it didn't work right. SO, I'm checking out a tutorial today for something completely unrelated, and stumble across this:


From the gifs, it seems to do EXACTLY what I wanted, and was available the whole time, and I just never found it :S At any rate, I'm testing it out right now, though not entirely successfully, but I think I'm finally on the right track!

avatar image Imagine-Games Jul 01 '18 at 02:45 AM

edit* i see what you mean now... i guess it worked for me since my icebergs are in the water i never noticed that stretching

avatar image script526 Jul 01 '18 at 08:21 AM

Yep)) I can see it even in your video)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

5 answers: sort voted first

a world aligned texture is locked by definition. what you want is to shift it's coordinates based off the object it's on yes? if so then this should solve your issue. also if you are using world aligned texture i believe you plug in the 1-x into the WorldPosition input. if that doesn't work remove the 1-x and try again. alt text

untitled.png (63.6 kB)
more ▼

answered May 03 '17 at 02:28 AM

avatar image

23 1 7

avatar image rattmeeves May 03 '17 at 04:35 AM

Thanks for the reply! However, I suppose I could have been a little more specific.

The main thing I'm trying to accomplish, is to get an animated actor to initially have its texture world aligned, and then somehow locked, so that the texture appears to be baked onto the mesh. A much better example would be applying a world aligned texture to a few tree actors, mainly for some texture variation, but have them animated to move with the wind, and not look like the texture is morphing because certain vertices are changing their world space location. Does that make sense?

To some, this may seem like an unnecessary thing to accomplish, but if I can get it to work, it can produce some truly powerful results. What I like so much about world aligned textures, is the fact that they appear seamless, and I would like to be able to use them for detail texturing on actors like characters, because it can cover up seams very nicely. Is what I'm trying to do even possible? I tried your method, dillzilla, and it didn't do what I wanted.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Yeah it is possible. You need to project textures in mesh local space rather than world space. You would need to modify WorldAlignedTexture material function for this yourself though.

more ▼

answered May 11 '17 at 12:43 PM

avatar image

7.9k 130 31 293

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

If I recall correctly, there's a local counterpart to this node: ObjectAlignedTexture. If there isn't, go inside this node (it's a function) and Transform world position into local space. But that only works for object position/rotation anim. Moving vertices are why standard UVs were invented. For baking, you can recreate the setup in Substance Painter (using Fill type of layers with Triplanar option).

more ▼

answered May 14 '17 at 07:41 AM

avatar image

Oskar Świerad
403 13 31 29

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

This can't be the correct method, but I would think there would be a way to subtract the objects movement from texture coords using panning. I suppose this could be useful if you wanted to interpolate between world aligned and object aligned at run time. I'm sure there is some psychedelic effect that could make use of this but likely nothing useful.

Anyway that's my 2 cents. XD

more ▼

answered Jun 19 '18 at 05:54 AM

avatar image

215 4 4 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

hey im sorry ive been away from my main work computer as im moving and so havent been able to update, but this weekend i move in and ill see if i can offer any additional help

more ▼

answered Jun 29 '18 at 03:48 AM

avatar image

224 5 11 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question