Distance blending textures of different sizes?

Hey, I’m trying to make a terrain texture from two satellite images, one detailed, the other one no as much but way wider, showing a larger area of the map.

Thing is, the two of them don’t really blend together due to the resolution and color differences, and I want to use the detailed texture when I’m close to the ground, (blended with the low res wider texture with a smooth transition between the two), and completely fade out the high res texture I zoom out or fly away, showing only the wide texture.

So I started trying to Lerp the two textures together using a distance blend as alpha, but I don’t even know how to position the smaller, detailed texture in the middle of the terrain without tiling, so it shows the other texture underneath.

Doing this only gradually replaces one texture for the other as I zoom out.

How can I position the smaller texture in the middle, without tiling, blended with the bigger texture around it, and then make it fade away as I zoom out?

You need to use a different UV for the smaller image.

Thing is, the 2 images don’t seem to be even remotely related, so guessing the UV for the smaller image would be pretty hard if not impossible.

Let’s say you want it smack in the middle of an object. Any object properly unwrapped. Like a square plane.
You would use a use UV of .5,.5
from which you would have to subtract width/2 and height/2 uv equivalent value to align the image in the center.

To prevent tiling you can just change the setting on the texture sampler to clip rather than wrap.

Doubt that’ll just work for what you need, but hopefully it can give you an idea on how to make it work for your use case.

Let me try to make myself a bit more clear

I can make a different UV no problem, mapping only the polygon where I want to place the high res texture, but that doesn’t help, as you can’t really leave the other polygons out of the UV map, they’ll still be mapped randomly. (like shown on image 01)

Similar to what happens when I set the texture to “clamp” instead of “wrap”, it won’t prevent tiling, it will simply make the other tiles look all distorted (image 02).

I’ve exaggerated textures a bit for clarity, but here’s what I want to do: I have a square terrain with a low res texture applied to it (image 03), which should be fine from a distance, but as I get closer to the center, which is my point of interest, I want the higher res image to fade in (like image 04), keeping the low res texture around the edges.

This should be so simple, it’s not a big deal in any other software, just a matter of applying a texture on top of another, making it non-tiling, and offsetting its position, (like image 05), pretty much what you do in other software for applying a decal on top of a texture.

I mean, the distance fade part works fine, but I’m simply not able to offset a texture on UE4 nor stop it from tiling.

Ok at least I managed to offset my texture, but is there a way to make the outer tiles (or texture distortion when using clamp) transparent automatically, without creating a custom mask? so that the texture actually doesn’t tile, shows only once?

You’d have to mask it, and provide the different texture to use inside the mask.
lerp one to the other based on that math’s alpha.

The UV code you are using to place the image is probably the same you need to isolate a back/white area.
try plugging it I to the base color and see what you get.

hmmm nope, this is my material, and this is what I get when I plug the UV coords into base color

It’s almost there.
As you can see the X and Y start at the correct corner and stretch out.
clamp the UV and you’ll only see the 0 to 1 values.
Invert that (-1).
Keep trying different math until you have the area you need either black or colored.

You can then run a desaturate node, an IF or whatever else to mask out the area in a black/white fashion.

Should note that you could also just make a mask that’s landscape wide as an image and use that. But the cost of UV math is usually way cheaper.

Right. The thing is I’m not too familiar with how math nodes work in materials, and I can’t manage to turn this UV into a proper black/white mask matching the texture area. I’m surely doing something wrong. Could you elaborate a little?

and I do realize I could make a custom bitmap mask, but as you mentioned, there must be a way using only nodes that would be more precise on the edges and cheaper

You just need to learn. There’s no substitute.

Just so you know what you are doing, you are shrinking the UV to be 1/4 of the object, then moving it to the center of the object.

This has no rational to actual image size, so it will only work as long as you don’t change the landscape size.

Let’s say that we want to isolate value ranges at the edge.
so subtract 1 from the UV.
lets ceil this value so that the we only get X/Y values of 1. Everything else is 0.
let’s cheat and multiply the float 2 by itself, creating a 0-1 loop or edge. (anything * 0 is 0, so the center will stay black. The outer edge will be 1).

With that, you just have to convert it from a float 2 to a float value to use in a lerp.
it’s literally as simple as breaking the float 2 and adding the 2 floats together.

Should you now the the opposite you can always -1

Didn’t check this logic in editor, but I don’t think I fumbled for once.

Yeah, I’ve actually watched a lot of UE4 tutorials since I started with it a few years ago, but material creation is one of the things I never really practiced so that’s what I’m trying to do now.

I think I’m almost there with this map but I still can’t get rid of the colors. If I desaturate it, the colors become shades of grey and I’m not sure how to isolate those into black and white

Ok, this finally worked! Thanks so much. I just have one more question. if my map preview appears as black/red, why does it show as black/white when I set it as base color?

The preview there is just rendering the Red channel, that’s why it looks red.
When you plug the red channel only into the base color, the engine treats it as a float and automatically transforms it into a vector3 with same value for all channels.