# Material color mask based on UV coordinates?

**URL:** <https://forums.unrealengine.com/t/material-color-mask-based-on-uv-coordinates/322371>\
**Category:** Rendering\
**Tags:** uv, unreal-engine, question\
**Created:** [June 19, 2015, 12:49pm UTC](https://forums.unrealengine.com/t/material-color-mask-based-on-uv-coordinates/322371 "2015-06-19T12:49:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Efrye](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/efrye/32/1194658_2.png) [@Efrye](https://forums.unrealengine.com/u/Efrye)\
**Post date:** [June 19, 2015, 12:49pm UTC](https://forums.unrealengine.com/t/material-color-mask-based-on-uv-coordinates/322371/1 "2015-06-19T12:49:51Z")

</div>

Hey,

I’m using flat colors for most of my meshes, but I need multiple colors per mesh. To achieve that, I separated the UVs of my meshes based on their color and arranged them accordingly in a 0 to 1 UV space (see image).

![47018-checkeruvs.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/0/3301fe74880475a6417b3b38abcb0cd03ad65a3d.png)

However, I can’t use a texture since I need to be able to set the colors via parameters in the material. So I have to somehow mask/lerp the colors based on UV coordinates or a control texture of some kind.

Some of the starter content materials, like the chair or lamp, use the R/G/B/A channels of a texture to separate colors. But I need much more than only 4 colors, so this isn’t an option for me.

Does anyone know a good way to set this up? Any ideas would be appreciated!

---

<div class="post-metadata">

**Author:** ![Efrye](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/efrye/32/1194658_2.png) [@Efrye](https://forums.unrealengine.com/u/Efrye)\
**Post date:** [June 23, 2015, 8:42am UTC](https://forums.unrealengine.com/t/material-color-mask-based-on-uv-coordinates/322371/2 "2015-06-23T08:42:14Z")

</div>

It appears there is no elegant way to do this, so I ended up using the RGBA channels of a control texture (see below) and isolated the individual squares by adding and subtracting the channels. It looks messy, but performance-wise it doesn’t seem to be an issue and definitely beats having 20+ material slots per character.

![47474-controltexture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/e/dee1aa72b8da4cf1e33a7bee4ddd42ef124e6ed7.png)

 ![47475-controlmaterial.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/a/c2a976e1c5b1c1ea9d02cb53c875a8834084528e.png)

---

<div class="post-metadata">

**Author:** ![KACPEROGO](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KACPEROGO](https://forums.unrealengine.com/u/KACPEROGO)\
**Post date:** [May 7, 2021, 9:52pm UTC](https://forums.unrealengine.com/t/material-color-mask-based-on-uv-coordinates/322371/3 "2021-05-07T21:52:22Z")

</div>

Hello, this looks exactly like what I’m looking for:) However, I cannot see the nodes in the picture. I know it has been a couple of years, but maybe you could share this solution once more?  
Anyway thanks for the tip!

---

<div class="post-metadata">

**Author:** ![Pendali](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pendali/32/765848_2.png) [@Pendali](https://forums.unrealengine.com/u/Pendali)\
**Post date:** [February 17, 2025, 11:00am UTC](https://forums.unrealengine.com/t/material-color-mask-based-on-uv-coordinates/322371/4 "2025-02-17T11:00:24Z")

</div>

You can mask in or out a UV region by doing something like this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/1/a11905bfeac0fa9d85b5e6b24e8531b731660236.png)
