# Shader Node "If Then Else": How does it work?

**URL:** <https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123>\
**Category:** Rendering\
**Tags:** unreal-engine, question\
**Created:** [September 30, 2025, 2:52pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123 "2025-09-30T14:52:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lawrence.vicare](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lawrence.vicare](https://forums.unrealengine.com/u/lawrence.vicare)\
**Post date:** [September 30, 2025, 2:52pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/1 "2025-09-30T14:52:56Z")

</div>

Hi guys!

It’s just a simple question but how the shader node “ifThenElse” does work? 🤔

I don’t have any results with it. So if anybody finds how it works, I’m curious to know 😁

Quick note: It’s not the same node as “If” (which compares two entries)

Thank you guys!

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/b/debdf2112d275fb4d0b2bd9d66b66df46e65b656.jpeg)

---

<div class="post-metadata">

**Author:** ![Arkiras](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkiras/32/1008648_2.png) [@Arkiras](https://forums.unrealengine.com/u/Arkiras)\
**Post date:** [September 30, 2025, 4:08pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/2 "2025-09-30T16:08:50Z")

</div>

Didn’t even know this node existed, it seems like the static switch node makes this redundant, no?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/1/fb1967ac34d4dc9830644d8b85812a2b4bb8eefc.jpeg)

---

<div class="post-metadata">

**Author:** ![lawrence.vicare](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lawrence.vicare](https://forums.unrealengine.com/u/lawrence.vicare)\
**Post date:** [September 30, 2025, 4:19pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/3 "2025-09-30T16:19:26Z")

</div>

I agree with you 😁

Actually, it’s just for curiosity’s sake.

I don’t understand this new node (it doesn’t exist in 5.4) but maybe it be usefull… Or maybe it’s just a forgotten test from dev, I don’t know ^^

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [September 30, 2025, 8:49pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/4 "2025-09-30T20:49:09Z")

</div>

hmmm is the “if” node static though?

my first impression of it made me thought that it wasn’t static.

the static switch generates two permutations, and only executes one branch. but maybe the “if” node executes both and the condition could be a dynamic value. like the other “if” node with the A-B comparison.

---

<div class="post-metadata">

**Author:** ![Arkiras](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkiras/32/1008648_2.png) [@Arkiras](https://forums.unrealengine.com/u/Arkiras)\
**Post date:** [September 30, 2025, 11:22pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/5 "2025-09-30T23:22:56Z")

</div>

> [@nande](#):
>
> my first impression of it made me thought that it wasn’t static.

Can only be static as there’s no way to make a dynamic boolean parameter in UE (to my knowledge at least). If you try to create one you’ll find that it’s just a static boolean exposed to the material instance and can’t be set at runtime.

Now, I thought perhaps you could use a custom node to return a boolean value and use that as the input, but it doesn’t seem to work either. Custom nodes can only return floats and material attributes and just using a 1/0 didn’t work. (plus I guess what good would it be if you had to use a custom node for it? At that point you may as well just stick the if statement in the custom node)… So I took a look at the generated code;

If you try this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/e/e/8eed9f83333588729121fc7547848c5c5931b567.png)

This is the generated HLSL:

```auto
lerp(MaterialFloat3(0.00000000f,0.00000000f,0.00000000f),Material.PreshaderBuffer[0].yzw,Material.PreshaderBuffer[0].x);

```

I’m not sure what the material preshade buffer is, but this definitely isn’t an “if”, and it’s just throwing away the nodes inputs so it doesn’t matter what you plug into it. I can only assume it’s broken, this is the first I’ve seen this node so I don’t even know how long it’s been in the editor, might be some relic from the UE3 days.

The material editor has a bunch of strange nodes that don’t make any real sense, dynamic branch is another one; It’s not a dynamic branch at all, it’s just the regular if node (which is a ternary op) in a trenchcoat.

If you want to read a very long and tedious discussion about that one you can see it here: [Shader Dynamic branch not working?](https://forums.unrealengine.com/t/shader-dynamic-branch-not-working/1909078/)

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [October 1, 2025, 9:13pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/6 "2025-10-01T21:13:08Z")

</div>

yeah that’s pretty much how i expected it to work. that’s why i thought you could use a 0/1 number instead of a static bool. hence not being static.

but you said

> [@Arkiras](#):
>
> aterial attributes and just using a 1/0 didn’t work.

not sure if you were talking about another node. that confused me.

anyways great dissecting work.

---

<div class="post-metadata">

**Author:** ![lawrence.vicare](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lawrence.vicare](https://forums.unrealengine.com/u/lawrence.vicare)\
**Post date:** [October 4, 2025, 3:04pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/7 "2025-10-04T15:04:29Z")

</div>

Hi Guys!

Thank you so much for your investigation!

Ok, so, this node seems broken 😅

There are always new things, and it intrigues me every time ^^

Thanks a lot for your time

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [October 4, 2025, 9:02pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/8 "2025-10-04T21:02:08Z")

</div>

i personally don’t think it’s broken, just used in unexpected cases

---

<div class="post-metadata">

**Author:** ![lawrence.vicare](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lawrence.vicare](https://forums.unrealengine.com/u/lawrence.vicare)\
**Post date:** [November 24, 2025, 10:51am UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/9 "2025-11-24T10:51:35Z")

</div>

Hi guys!  
I may have discovered why the node isn’t working.  
Apparently, it’s a future node development. I imagine it was introduced empty for now, waiting to be implemented for a future version of Unreal:

![](https://d3kjluh73b9h9o.cloudfront.net/optimized/4X/6/f/d/6fdf9e8f6bf74b59b6aca35906963997c79ca730_2_690x388.jpeg)https://www.youtube.com/embed/KYmd_LNlw2c?feature=oembed&wmode=opaque&start=2215

---

<div class="post-metadata">

**Author:** ![BananableOffense](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BananableOffense](https://forums.unrealengine.com/u/BananableOffense)\
**Post date:** [November 24, 2025, 3:56pm UTC](https://forums.unrealengine.com/t/shader-node-if-then-else-how-does-it-work/2661123/10 "2025-11-24T15:56:29Z")

</div>

Notably the new node _will_ feature dynamic branching so it is a big upgrade - but yes, it is a placeholder right now and is non-functional. If you need dynamic branching, you must use the custom node as usual for a little longer.
