I need to check if 2 different conditions are true in my material. Right now I am using a Custom node with custom HLSL code, but I was wondering if there is a better way to do the same thing without using a Custom node?
Three IF statements
First check if A==B. Make it only return 1 if so. Same for C==B.
Then you take the output of those two IFs and see if they both equal 1, return 1, otherwise 0.
You can also simply multiply the first two IFs together and it should be either 1 or 0. Technically you can get rid of the IFs altogether and use subtraction and ceil/clamp etc but it will work fine with IFs.
You will chain together a three if nodes
You have A, B, C
A and B compared in if node 1
B and C compared in if node 2
Both if nodes feed into a third if node and get compared.
So you are comparing a to b and b to c and then comparing the results.
I’m having a hard time figuring out how to use a switch node with that, since the ‘value’ input needs a boolean.
Basically, I am using the HeightLerp node and feeding it the result of blending 2 different HeightMaps together. I then use 2 StaticBoolParameter nodes to enable/disable each Heightmap. If at least 1 Heightmap is enabled, I go on using the HeightLerp, but if both HeightMaps are disable, I want to skip the HeightLerp altogether using a Switch. The problem is I don’t know how to get the result of the “if and”, which will be either 0 or 1, and use that result to feed the “value” input of the switch.
Static switches are not meant to interact with the realtime parts of materials. You will need to make another manual switch for that, you can’t decide a switch based on combo’s of other switches currently.
You could use the switches to return either 0 or 1 and then do the IF based on that, but you can’t read the value of the switch overwise.
IFs are meant for dynamic branching and switches are meant for static time permutation changing, there is really no interface for them to go together.
Makes sense, thx Ryan!