NOT logic gate using nodes

NOT Gate

I am trying to make logic gates in blender using nodes. The AND and OR gates were easy, simple math multiplication and addition nodes but I can’t figure out how to make the NOT gate. This is a simple workaround but it doesn’t hold up while making NAND and NOR gates.
Would love to know how to approach this.
Thanks.

I’d would suggest trying to build the NAND gate first and then use it as your NOT gate…
//Here it’s the set-up of the node group.

Thank you very much. This works great. Would love to know the logic behind this.

The logic is rather simple…If you’ve familiarized yourself with building “AND” and “OR” gates, “NAND” is just an inverse version of AND as you can see below:
Screen Shot 2020-10-12 at 4.49.18 PM
And since our intention in the first place, it’s just to get the “NOT” gates (input:1 → output 0 and input:0 → output 1), we can just re-use the “NAND” gate and have both of the output of one node plug into both of the input of “NAND” gate. The “NAND” gate will receive the same input and just spit out either 0 (if the input is 1) or 1 (if the input is 0). Basically, it just neglects/skip this part of the operation:
Screen Shot 2020-10-12 at 4.55.59 PM
And just use only this part, which is what we want in the first place:
Screen Shot 2020-10-12 at 4.48.21 PM
// If you’re planning to do more logic gates/operation, I’d highly recommend giving this post from Blender StackExchange a look since it’ll most definitely help you along the way.

1 Like

Your “less than” isn’t a workaround, not any more than anything else, and it works fine with NAND and NOR. The main thing I’d say is, sanitize your input. I’d do that with math/round with clamp enabled. Then, keep it sanitized, by using “clamp” on logic operations.

If you really don’t want to use “less than”, though, there are plenty of options: math/subtract to 1-n with clamp, invert->clamp, etc.

1 Like