# Switch on int for materials (scalars/grayscale textures)

**URL:** <https://forums.unrealengine.com/t/switch-on-int-for-materials-scalars-grayscale-textures/440934>\
**Category:** Asset Creation\
**Tags:** Switch, integer, unreal-engine, question\
**Created:** [January 9, 2019, 10:35am UTC](https://forums.unrealengine.com/t/switch-on-int-for-materials-scalars-grayscale-textures/440934 "2019-01-09T10:35:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4230003f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4230003f](https://forums.unrealengine.com/u/anonymous_user_4230003f)\
**Post date:** [January 9, 2019, 10:35am UTC](https://forums.unrealengine.com/t/switch-on-int-for-materials-scalars-grayscale-textures/440934/1 "2019-01-09T10:35:50Z")

</div>

Hi,  
I’d like to help anyone who needs a switch on int node but for materials.  
The scenario is this - you have 1 or more textures that each channel is separate grayscale texture (for example you use the RGBA channels to store variations of a mask).

 ![264696-result.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/8/a/18a1553cb6c83014e4d9a7fa7f1bf960151b7517.jpeg)

Here’s how to use it:

You need to create two material functions

- MF\_MultiSwitch: This is the function that should be called in the material.

 ![264697-mf-multiswitch.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/a/2/2a25389a4e7d26a956dfbc7657d25af5a037c7ee.jpeg)

- MF\_alphaBlend: This material function will be used in in the MF\_multiSwitch to filter whether to allow the current scalar texture to pass through or not.

![264698-mf-alphablend.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/e/7/0e7e5e9d80cdc7dbf9eb85ad9b2591a8f42c7cfd.jpeg)

Note: this can also be used with whole textures (RGBA), you just need to change the inputs for the material function to be vector3 or vector4 depending whether you like to use the alpha channel or not.

You can find the project zipped here

---

<div class="post-metadata">

**Author:** ![GodzillaFiresox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GodzillaFiresox](https://forums.unrealengine.com/u/GodzillaFiresox)\
**Post date:** [June 28, 2019, 6:23pm UTC](https://forums.unrealengine.com/t/switch-on-int-for-materials-scalars-grayscale-textures/440934/2 "2019-06-28T18:23:00Z")

</div>

Thanks a lot for this! Dunno why there isn’t a switch node already, this is very useful. Is there any reason MF\_MultiSwitch has the input nodes all out of order like that? Shouldn’t it be in increasing order to match the scalar hardCoded params?

---

<div class="post-metadata">

**Author:** ![LyubomirIko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LyubomirIko](https://forums.unrealengine.com/u/LyubomirIko)\
**Post date:** [November 9, 2019, 8:49pm UTC](https://forums.unrealengine.com/t/switch-on-int-for-materials-scalars-grayscale-textures/440934/3 "2019-11-09T20:49:22Z")

</div>

This is exactly what I need!!! THANK YOU SO SO MUCH!  
At first I got it wrong because I didn’t change the inputs to be vector3…  
I am very grateful you are golden!!!

---

<div class="post-metadata">

**Author:** ![Tbjbu1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tbjbu1](https://forums.unrealengine.com/u/Tbjbu1)\
**Post date:** [October 18, 2021, 5:43pm UTC](https://forums.unrealengine.com/t/switch-on-int-for-materials-scalars-grayscale-textures/440934/4 "2021-10-18T17:43:07Z")

</div>

Thank you!!!

---

<div class="post-metadata">

**Author:** ![Tbjbu1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tbjbu1](https://forums.unrealengine.com/u/Tbjbu1)\
**Post date:** [October 18, 2021, 5:44pm UTC](https://forums.unrealengine.com/t/switch-on-int-for-materials-scalars-grayscale-textures/440934/5 "2021-10-18T17:44:51Z")

</div>

Thanks!  
Just a note, this is not the most performent way to do it from my knowledge, you use LERP, but optimally IF would be used.

---

<div class="post-metadata">

**Author:** ![TRI-EyeLight](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TRI-EyeLight](https://forums.unrealengine.com/u/TRI-EyeLight)\
**Post date:** [May 8, 2023, 3:22pm UTC](https://forums.unrealengine.com/t/switch-on-int-for-materials-scalars-grayscale-textures/440934/6 "2023-05-08T15:22:49Z")

</div>

Hello, I can’t find the attached project zipped file?
