# Subtaction issue with Comp node - Has it always been this way?

**URL:** <https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408>\
**Category:** Flame Questions\
**Created:** [July 9, 2021, 6:14pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408 "2021-07-09T18:14:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ytf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/ytf/32/109_2.png) [@ytf](https://forum.logik.tv/u/ytf)\
**Post date:** [July 9, 2021, 6:14pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/1 "2021-07-09T18:14:12Z")

</div>

If I create 2 gmasks, both 100% white over 0 black as described by the desktop dropper (working in Rec. 709) and subtract one from the other, the resultant black in the subtracted area is -1. If I invert one mask and multiply, the black is 0, as one would expect. Perhaps it has always been that way and I never noticed because I never did anything with the -1 black in which it made a difference until yesterday. Clamp, of course, fixes the issue, but why would I need to clamp it? 1-1 = 0.

---

<div class="post-metadata">

**Author:** ![mattriley](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/mattriley/32/516_2.png) [@mattriley](https://forum.logik.tv/u/mattriley)\
**Post date:** [July 9, 2021, 7:44pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/2 "2021-07-09T19:44:30Z")

</div>

I’m not seeing that here (2022.1) unless I misinterpreted what you wrote.

-Matt

 ![snap-15](https://us1.discourse-cdn.com/flex020/uploads/thedepartmentofexternalservices/original/2X/6/69d77131cded7782b4ac63e0fca150871539916b.jpeg)

---

<div class="post-metadata">

**Author:** ![ytf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/ytf/32/109_2.png) [@ytf](https://forum.logik.tv/u/ytf)\
**Post date:** [July 9, 2021, 7:49pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/3 "2021-07-09T19:49:16Z")

</div>

No, you did it exactly as described. The only difference is that I started with a piece of footage (from the job that I encountered the issue on) and you started with a colour node. And I used gmask tracer. As soon as I have a moment I will look farther.

---

<div class="post-metadata">

**Author:** ![andy\_dill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/andy_dill/32/15475_2.png) [@andy\_dill](https://forum.logik.tv/u/andy_dill)\
**Post date:** [July 9, 2021, 7:49pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/4 "2021-07-09T19:49:22Z")

</div>

It’s always been that way. Use the blue inputs to combine two mattes—it’s got all the options you want and won’t create negative values.

---

<div class="post-metadata">

**Author:** ![mattriley](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/mattriley/32/516_2.png) [@mattriley](https://forum.logik.tv/u/mattriley)\
**Post date:** [July 9, 2021, 7:53pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/5 "2021-07-09T19:53:18Z")

</div>

Gmask tracer doesn’t seem to change anything in my little setup. So the negative values must be coming from your footage is my guess.

---

<div class="post-metadata">

**Author:** ![ytf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/ytf/32/109_2.png) [@ytf](https://forum.logik.tv/u/ytf)\
**Post date:** [July 9, 2021, 7:54pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/6 "2021-07-09T19:54:18Z")

</div>

Actually, I think if you move the dropper around a bit you may find sporadic instances of -1

---

<div class="post-metadata">

**Author:** ![mattriley](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/mattriley/32/516_2.png) [@mattriley](https://forum.logik.tv/u/mattriley)\
**Post date:** [July 9, 2021, 7:56pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/7 "2021-07-09T19:56:48Z")

</div>

Ah… You are correct. I was sampling the intersection of the masks. The -1.0 shows up when sampling the area outside of the intersection where the shape that is being subtracted would be.

---

<div class="post-metadata">

**Author:** ![ytf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/ytf/32/109_2.png) [@ytf](https://forum.logik.tv/u/ytf)\
**Post date:** [July 9, 2021, 7:57pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/8 "2021-07-09T19:57:53Z")

</div>

Yes, and setting it to 2 Minus 1 (outside) as well does the trick. I guess I never had to use such a matte in a way where it made a difference until yesterday. (as a holdback matte for a colour node.)

---

<div class="post-metadata">

**Author:** ![mattriley](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/mattriley/32/516_2.png) [@mattriley](https://forum.logik.tv/u/mattriley)\
**Post date:** [July 9, 2021, 8:00pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/9 "2021-07-09T20:00:42Z")

</div>

Yeah… I know we are _supposed_ to use the matte inputs of the comp node to combine mattes because the math is geared for it but it’s kind of a PITA and disruptive to the flow when you have to view the matte out of the node vs. just the result like normal. Thankfully, there are methods for supporting my bad habits and doing it the right way. 😉

---

<div class="post-metadata">

**Author:** ![mattriley](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/mattriley/32/516_2.png) [@mattriley](https://forum.logik.tv/u/mattriley)\
**Post date:** [July 9, 2021, 8:04pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/10 "2021-07-09T20:04:13Z")

</div>

I guess now that I think about it, it would be nice if the comp node could correctly interpret our intentions based on the input. If it sees matte sources being piped into only the front and back inputs, assume we are being lazy about combining mattes and do the right thing (don’t generate negative values).

---

<div class="post-metadata">

**Author:** ![ytf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/ytf/32/109_2.png) [@ytf](https://forum.logik.tv/u/ytf)\
**Post date:** [July 9, 2021, 8:12pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/11 "2021-07-09T20:12:30Z")

</div>

I get it now. It is subtracting 1 (from the white of one matte) from 0 (where the other matte was black) but 1 from 1 where there was white on white. Interestingly enough, it doesn’t do that in 8 bit.

---

<div class="post-metadata">

**Author:** ![andy\_dill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/andy_dill/32/15475_2.png) [@andy\_dill](https://forum.logik.tv/u/andy_dill)\
**Post date:** [July 9, 2021, 10:45pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/12 "2021-07-09T22:45:13Z")

</div>

Yeah, it won’t do it in 8 bit cos 8-bit is an integer color space. The only possible values are 0-255.

Theoretically this would apply to 10 and 12 bit color as well, but (at least in batch) flame promotes all non-8-bit color to 16-bit float, which has a value range of -65,636 to +65,536.

So when you subtract in 8 bit flame gives up at zero, but in floating point it can do the math correctly and give you negative results.

I agree it’s all a bit confusing.

I love those blue comp inputs though. So useful!

---

<div class="post-metadata">

**Author:** ![andy\_dill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.logik.tv/andy_dill/32/15475_2.png) [@andy\_dill](https://forum.logik.tv/u/andy_dill)\
**Post date:** [July 9, 2021, 10:52pm UTC](https://forum.logik.tv/t/subtaction-issue-with-comp-node-has-it-always-been-this-way/3408/13 "2021-07-09T22:52:57Z")

</div>

> [@mattriley](#):
>
> If it sees matte sources being piped into only the front and back inputs, assume we are being lazy about combining mattes and do the right thing (don’t generate negative values).

A couple of nerdy points:

1. The comp node’s matte inputs have blend modes not available to the front inputs, and they are all super useful. Zero chaff. One inverts and multiplies one matte over the other, one does the opposite of that. It’s great, and you should use it because:

2. “Subtract” was never a good way to combine mattes. Like “Add” it’s raw-math-ness make it too agressive in the semi-transparent areas. The nicer way is to invert and multiply the matte over. See point 1 for a method of doing that in a single node.
