# How to correctly compare a color with a list of colors in a material.

**URL:** <https://forums.unrealengine.com/t/how-to-correctly-compare-a-color-with-a-list-of-colors-in-a-material/2724522>\
**Category:** Blueprint\
**Tags:** unreal-engine, question\
**Created:** [May 26, 2026, 2:33pm UTC](https://forums.unrealengine.com/t/how-to-correctly-compare-a-color-with-a-list-of-colors-in-a-material/2724522 "2026-05-26T14:33:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mamingalaxi\_yt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mamingalaxi\_yt](https://forums.unrealengine.com/u/mamingalaxi_yt)\
**Post date:** [May 26, 2026, 2:33pm UTC](https://forums.unrealengine.com/t/how-to-correctly-compare-a-color-with-a-list-of-colors-in-a-material/2724522/1 "2026-05-26T14:33:51Z")

</div>

In an optimized way (without going through a dozen if), I would like to compare a given color in a material with a list of colors. If the color is not part of the list of colors, it should display another one; otherwise, it should display the color.

---

<div class="post-metadata">

**Author:** ![Gecko.GD](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gecko.gd/32/1177553_2.png) [@Gecko.GD](https://forums.unrealengine.com/u/Gecko.GD)\
**Post date:** [May 26, 2026, 5:04pm UTC](https://forums.unrealengine.com/t/how-to-correctly-compare-a-color-with-a-list-of-colors-in-a-material/2724522/2 "2026-05-26T17:04:04Z")

</div>

For comparing a value to a list of values, you want to make sure the list is inside an array, and then use a for each loop (possibly for each with break node) to compare your color to each one

---

<div class="post-metadata">

**Author:** ![mamingalaxi\_yt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mamingalaxi\_yt](https://forums.unrealengine.com/u/mamingalaxi_yt)\
**Post date:** [May 27, 2026, 12:08pm UTC](https://forums.unrealengine.com/t/how-to-correctly-compare-a-color-with-a-list-of-colors-in-a-material/2724522/3 "2026-05-27T12:08:05Z")

</div>

I don’t want a bleuprint method, this method is CPU side, but I want a comparaison method in a material, so GPU side. I know that I can chain a lot of if, but I’m wondering if there is a more optimized method.
