Is it possible to make a material with 2 textures in different spots?

I’m going to grossly oversimplify what I’m trying to do, but is it possible to make a material that takes 2 textures and uses 1 texture for one half and the other for the other? For instance, say you have a simple plane. On the top half, it should show a texture of the top half of a car and the bottom half should show the bottom half of a bus. I would also want to be able to blend/transition between the two textures rather than having a hard line between them.

Is this doable?

1 Like

You can use a mask where one channel is used for one texture and another channel is used for another, so an RGBA texture could potentially hold 4 masks. To smoothly transition between the two, the mask would need a gradient where one color fades into the other color. My mask example doesn’t do that but if it did, it would be yellow in the middle.

2 Likes

Thanks for the help. This is almost right. The problem that I’m having now is that since this is an add, the part where it’s blending ends up being brighter than the rest. You can see this most easily by using the same texture for both halves. Is there a way to combine them that will keep the saturation roughly the same?

That’s because the total of the values is greater than 1.0. You’ll need ensure that in the mask, all the channels sum to 1. I was previously incorrect about saying the blend of red and green would be yellow because that is full green and full red. The result is closer to an olive-y green (.5 red, .5 green).

It’s not just an issue of the values being greater than 1. You can get the same result I’m talking about by simply taking the same dark texture and adding it to itself. 0.2 + 0.2 is less than 1 but it will still be brighter than it was before.

Brisket’s solution works correctly but relies on having black and white values with no grays. You could also use a linear interpolate instead of multiplying and adding.

Yeah, what Arkiras said. In my description, all channels need to sum to 1 (or you could pick another value), not just be less than that value. You’re getting the darker/lighter effect because they don’t sum to the same number. If you want to only use 20% a texture, the remaining 80% is blended with black. If you want the middle to also only use 20%, then (assuming only 2 masks are used) the 2 channels are going to have to say use 10% of texture in order to sum to 20%.

If you use Lerp instead of Multiply, then UE will use the second texture for the remaining part instead of black.

You can also look into UE’s Mesh Paint tools. It’s the same idea but instead of providing your own mask, you paint the textures on the actor the way you want and UE will store this “mask” as the vertex color.

Right, I see. Alright, I’ll have to figure out how to calculate a lerp value that will make sense here.

If you’re curious, as mentioned at the top, this is a gross simplification of what I’m trying to do. What I actually have is the following values. These combine to define the opacity and each can be mapped to a different texture.The actual use case is the blending of different tile types in a grid based map. Each direction takes the texture of the tile in that direction and only appears if that tile is a different type.

As I said, I’ll just need to find a way to determine the lerp values. Thanks again for the help.

Frac or round for solid transitions. Clamp before it probably.

Why are you not doing this in the model with the UVs and a single texture?

I’m not sure I follow. The model is just the default plane mesh, but I’m not sure how I would do this with UVs and I’m not sure what you mean by a single texture.

Here’s an image of the current effect. You can see in the corners of the tile that the texture is brighter. It also makes the lines between the tiles harder. Just for clarity, light stone covers dark stone and dirt covers both.

Capture.PNG