UE4 - Multiple UVs one object question

I have one object with two UV_sets. On one of the UV’s I want to assign a texture on the other I just want to assign a constant 3 vector color.

What does this setup look like in the Material Editor?

I’m not sure I understand your question. Are some UV shells not assigned on one UV set or the other?

Under the assumption that you have an object with some shells in UVset_1 and some other shells in UVset_2 then you could simply do:

This works by assuming that any faces you don’t want to be the solid color have both their U and V component as being <= 0.0 in UVSet_2. If this isn’t the case, it won’t work. I’m using an [If] node here because it is built in, but the hlsl step() would be preferable.

Keeping this in mind, I don’t think this is the best way to do that type of separation. There are a lot of ways you can use UVs or textures to isolate certain faces, and this one is messy and hard to follow. But it should work.

1 Like

I don’t have Unreal in front of me, but the “Texture Coordinate” node has a UV Set dropdown list that should allow you to select which UV set you’re reading from. I assume there’s probably some options on import that need to be set to use them as well.

I do want to ask though: [quote=“jettam, post:1, topic:840”]
the other I just want to assign a constant 3 vector color
[/quote]
Can’t you just use your vertex colors for that instead? That doesn’t need a UV set.

@Keith, is correct. This sounds like a better case for vertex colors.

I found the answer to be a lot simpler than I thought. It seems I just have to assign two shaders to my object in Maya. For example I select the faces and assign shader, select that other faces and assign shader. Import into UE and it has two materials assigned to it. This method will work.

But I was thinking I could use one material and assign to one UVset a texture and to the other a vector color. @ryan.dowlingsoka just showed me a pretty good method for doing this by using a Lerp. The If node I dont quite understand yet, all in good time. :slight_smile:

Thanks guys.

The only reason to do it as one material would be to reduce draw calls. Each material counts as another draw call. It is always a balance between the too many draw calls, versus too expensive materials.

The [IF] is worth knowing, just so you know how to read it.

Pretty much it reads like this:
(I’ve denoted the inputs of the node with [brackets])

if( [A] > [B] )
{
    return [A >= B];
}
else if( [A] == [B] )
{
    return [A >= B] or [A == B]; //If it is connected.
}
else
{
    return [A < B];
}

The confusing parts are:

  • If you don’t put anything into [B] it assumes [B] is 0.
  • If you don’t put anything into [A == B] when [A] and [B] are the same it will return [A >= B]
  • Technically it uses a value that is visible in the node’s details to determine when two very similar numbers are equal, it is actually saying if abs([A] - [B]) < [Threshold] then the two values are equals.

Also something to realize is that it is not like a CPU If statement. All of the inputs are processed regardless of which ones get used, so you aren’t saving anytime (despite what the tooltip says) by using ifs.

3 Likes