Can you get a world texture to align perfectly without manual work?

Lets say You have a simple plane with a checkered texture regular UV.
I have a duplicate version of the same plane, I want to apply the same texture but in a world position mode but have it align perfectly to be identical to the original version.

Is there a way I can do this without resorting to manually eyeballing it by panning and scaling the world texture in place?

Instead of using world position, use local position in the material

thanks, I suppose I made a mistake in explaining one thing.

Instead of a duplicated plane with a world position, say I have a sphere and I have this sphere placed onto this plane, I would like the sphere to catch the underlying planes exact texture during movement only projected onto it. I suppose local position in the material wont work here becuase they are two different UVd objects.

The way I’m doing this at the moment is that I have my plane which is the floor and I have a checkered texture on this as a normal UV, I import the plane into the scene and place it someplace in the scene randomly. when I put the sphere on it and I assign a world position checkered texture projected, it doesn’t sit right on the sphere because its a world position texture, it comes all skewed and tiled the wrong way. So i am manually panning and eyeballing it on the sphere to match between it and the plane.

I was wondering if there is an automatic way to tell the material that take X location of the plane and start projecting from there?

I am guessing there is no magic way around this…

It’s a bit hard to understand without images but if you want both the plane and the sphere to align their textures together then both textures need to use world aligned.

World alignment is great and under the hood, the textures uvs are driven by their 0 to 1 values. So if the X location of your mesh is say 1500cm from the center of the world (ie X=0, Y=0) and you divide that 1500 by the texture size you want (say 100cm) then you end up inputting a UV coordinate with a value of 15 for the U. This means that what you see on your mesh is the 15th repetition of that texture.

Also remember that your material is using the World Position per pixel so it is the pixels world position. This is why the textures UVs read across the texture based on the meshes/pixel location.

Using vector maths you can relocate the center of your UVs. I don’t know the specifics of the maths of hand but it will be something like taking the world location of the pixel (masking it for the projection/axis’ you are aligning with) and making that value relative to another 3 value location. If that new location was [400, 1000] (for 2D) and your pixel location was [1500, 500] and you subtract them then the relative location of that specific pixel would be [1100, -500]. Then dividing that value by your texture size of 100 would result in the UVs of [11, -5]. So it would use the 11th repetition along the U and the negative 5th repetition along the V.

Maybe that helps a bit :sunglasses:

You could use the same world position UV on both materials so they would be identical and you wouldn’t need to move anything.
However you didn’t really explain much of anything - particularly the end goal. So…

Thank you both guys!

@MostHost: The idea is to have one world position UV because all others have normal uvs and materials applied.

The idea was to fake a few things in FX, I want the character object to inherit the color of the sectionof the ground it is moving on. The best way I came up with was to use the color as uv world projection on the moving object’s material as a guide to be triggered. Matching the UVs one to one with the base ground object was the manual alignment work.

In any case I suppose the way to go is somewhat more math and experimentation for now.

If you want to have the object share the terrain texture there’s always rendertargets for this too.

Why? Because it’s an effect that isn’t always active.

And because I’d you use a RT you can either capture the finished landscape from above in ortho - Or use the RTV system to generate your texture.

The cost of the render is something like .2 ms possibly less. Depends on size, and other actors captured. If you limit to just the landscape with no special effects of any kind and Unlit its super cheap.

One option to get the color of the ground material would be to use a Scene Capture Component 2D that specifically filters the scene for your ground mesh. This would then render to a render target which could then be used inside any material.

@MostHost_LA We answered at the same time. lol.

Thank you again both,

@MostHost_LA
Is world position UV assigned in the material of a moving object an effect always active or costly? My understanding is that it is a simple UV instead of being in texture local coordinates its in world space. Unless I missing a point. Being mindful that i’m not using the default node whiich comes with UE I eblieve its called “world aligned texture” or somthing I heard that could be a bit more expensive since it has additional features on it for normals and such.

in addition to simply projecting with world position UV I may be able to use other channels I have in my texture to mask out or do other effects with them vs having a render target capturing things as they are in the scene.

Ex. if i need to use only red channel with ground to change X color on moving object but i’ll use green and blue for other effects.

The UV is literally just a coordinate.
However that is put into the material the cost is minimal.
When you start to make math on top of it, the cost can increase.

To align a texture with world, just place a world position node, drag and type mask to get a Component Mask. In it’s setting enable both R and B.
That’s your UV coordinates (x / y).

Then you need some base math on top.
Like divide by the texture size (in meters), subtract 1/2 the texture (to center it). Etc.
Keep the operations to a minimum to preserve performance.

Most importantly. If you start doing a ton of calcs, put the result into a custom Uv node, and connect the custom uv to the texture(s) instead.

yes agreed on that, the cost is how much more math you put on top of it.