Page 1 of 1

Merge Tool - operator Xor and faint lines "issue"

PostPosted: Tue Mar 14, 2017 8:17 pm
by Okke Verbart
Hey guys - I'm wrecking my brain over something that should be relatively simple. I'm essentially using the merge node with a Xor operator combined with an effect mask input. Objective essentially being to cut out some holes.

Consider the example below where I basically have text+ going into a merge tool background input, with a rectangle as the foreground input. When I put the merge operator mode in Xor mode, this works as I expect: only showing pixels where there's no overlap.

When I then use the text+ input also as a mask effect input, I would expect to only see text where there's no rectangle: i.e. the rectangle has cut through the text. This works ok, UNTIL I enable HQ preview and then I get faint lines around the parts of the text that I had expected to be fully "cut out".

Question: is this an "operator" issue (me!), a system/graphics card/other issue (i.e. is it just me seeing this??) or a bug?

Code: Select all
{
   Tools = ordered() {
      Rectangle1 = RectangleMask {
         Inputs = {
            MaskWidth = Input { Value = 1920, },
            MaskHeight = Input { Value = 1080, },
            PixelAspect = Input { Value = { 1, 1 }, },
            ClippingMode = Input { Value = FuID { "None" }, },
            Center = Input { Value = { 0.502683692417641, 0.507509016142555 }, },
            Height = Input { Value = 0.239359790172248, },
            Angle = Input { Value = -42.9331383703963, },
         },
         ViewInfo = OperatorInfo { Pos = { 1824, 105 } },
      },
      Background1 = Background {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            TopLeftRed = Input { Value = 1, },
            TopLeftGreen = Input { Value = 1, },
            TopLeftBlue = Input { Value = 1, },
            Gradient = Input {
               Value = Gradient {
                  Colors = {
                     [0] = { 0, 0, 0, 1 },
                     [1] = { 1, 1, 1, 1 }
                  }
               },
            },
            EffectMask = Input {
               SourceOp = "Rectangle1",
               Source = "Mask",
            }
         },
         ViewInfo = OperatorInfo { Pos = { 1821, 156 } },
      },
      Merge2 = Merge {
         CtrlWZoom = false,
         Inputs = {
            Background = Input {
               SourceOp = "Text1",
               Source = "Output",
            },
            Foreground = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
            Operator = Input { Value = FuID { "XOr" }, },
            PerformDepthMerge = Input { Value = 0, },
            EffectMask = Input {
               SourceOp = "Text1",
               Source = "Output",
            }
         },
         ViewInfo = OperatorInfo { Pos = { 1815, 229 } },
      },
      Text1 = TextPlus {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Size = Input { Value = 0.227659574468085, },
            Font = Input { Value = "Open Sans", },
            StyledText = Input { Value = "TEST", },
            Style = Input { Value = "Bold", },
            ManualFontKerningPlacement = Input {
               Value = StyledText {
                  Array = {
                  },
                  Value = ""
               },
            },
            ShadingGradient1 = Input {
               Value = Gradient {
                  Colors = {
                     [0] = { 0, 0, 0, 1 },
                     [1] = { 1, 1, 1, 1 }
                  }
               },
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1516, 229 } },
      }
   }
}

Re: Merge Tool - operator Xor and faint lines "issue"

PostPosted: Tue Mar 14, 2017 8:27 pm
by Okke Verbart
BTW, I do realise I can swap foreground & background and then do a "held-out".... However, I'd just like to know why I get the faint lines when using the other approach.

i.e., the below does work (and of course is more elegant):

Code: Select all
{
   Tools = ordered() {
      Text1 = TextPlus {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Size = Input { Value = 0.227659574468085, },
            Font = Input { Value = "Open Sans", },
            StyledText = Input { Value = "TEST", },
            Style = Input { Value = "Bold", },
            ManualFontKerningPlacement = Input {
               Value = StyledText {
                  Array = {
                  },
                  Value = ""
               },
            },
            ShadingGradient1 = Input {
               Value = Gradient {
                  Colors = {
                     [0] = { 0, 0, 0, 1 },
                     [1] = { 1, 1, 1, 1 }
                  }
               },
            },
         },
         ViewInfo = OperatorInfo { Pos = { 108, 212 } },
      },
      Merge2 = Merge {
         CtrlWZoom = false,
         Inputs = {
            Background = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
            Foreground = Input {
               SourceOp = "Text1",
               Source = "Output",
            },
            Operator = Input { Value = FuID { "Held Out" }, },
            PerformDepthMerge = Input { Value = 0, },
         },
         ViewInfo = OperatorInfo { Pos = { 429, 215 } },
      },
      Background1 = Background {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            TopLeftRed = Input { Value = 1, },
            TopLeftGreen = Input { Value = 1, },
            TopLeftBlue = Input { Value = 1, },
            Gradient = Input {
               Value = Gradient {
                  Colors = {
                     [0] = { 0, 0, 0, 1 },
                     [1] = { 1, 1, 1, 1 }
                  }
               },
            },
            EffectMask = Input {
               SourceOp = "Rectangle1",
               Source = "Mask",
            }
         },
         ViewInfo = OperatorInfo { Pos = { 431, 137 } },
      },
      Rectangle1 = RectangleMask {
         Inputs = {
            MaskWidth = Input { Value = 1920, },
            MaskHeight = Input { Value = 1080, },
            PixelAspect = Input { Value = { 1, 1 }, },
            ClippingMode = Input { Value = FuID { "None" }, },
            Center = Input { Value = { 0.502683692417641, 0.507509016142555 }, },
            Height = Input { Value = 0.239359790172248, },
            Angle = Input { Value = -42.9331383703963, },
         },
         ViewInfo = OperatorInfo { Pos = { 429, 80 } },
      }
   }
}

Re: Merge Tool - operator Xor and faint lines "issue"

PostPosted: Tue Mar 14, 2017 9:22 pm
by Okke Verbart
OK - so, I sort of resolved it.... it seems that the anti-aliasing in the text+ tool was causing the issue: when dialing this back to 1, the faint lines disappear. I'm still not sure if this is meant to be like this though as I would have expected the anti-aliasing the affect the text+ the same way: whether it serves as an image input or as a mask input.

Re: Merge Tool - operator Xor and faint lines "issue"

PostPosted: Wed Mar 15, 2017 10:12 am
by JP Docherty
Sounds like a premultiplication issue. This is a basic concept in digital compositing with any software -
have a look at

https://compositing.wordpress.com/2010/ ... emultiply/

and then search "premultiplication digital compositing". This will lead to "linear workflow" which helps with these issues.

http://www.workshop.mintviz.com/tutoria ... explained/

http://www.comp-fu.com/2012/02/linear-g ... in-fusion/

etc

Re: Merge Tool - operator Xor and faint lines "issue"

PostPosted: Wed Mar 15, 2017 3:49 pm
by Bryan Ray
A true Boolean mode isn't actually meant to work with non-binary images. That is, if you have any value that is not exactly 0 or 1, it might have unexpected results.

My testing estimates that Fusion's formula for XOR is this:
(1-2*FG) * BG + FG = Output

Identical non-binary values returns a non-zero Output, which doesn't accord with the logical concept of XOR. The FG acts as a range from its own value to 1-FG, and the other selects the percentage of that range on which the Output falls. For instance, if FG is 0.25 (0+0.25) and Source is 0, the Output is 0.25 (0 percent of the range from 0.25 to 0.75). As BG rises to 1, Output approaches 0.75 (100% of the range). It doesn't actually matter which input is which. The formula works exactly the same if you swap FG and BG.

edit: Added some details

Re: Merge Tool - operator Xor and faint lines "issue"

PostPosted: Wed Mar 15, 2017 7:07 pm
by Okke Verbart
Ah, that's interesting Bryan.... I had actually consulted the reference manual which states the below:

XOr
XOr combines the FG with the BG wherever either the FG or the BG have a matte, but never where
both have a matte.
x = 1-[background alpha], y = 1-[foreground alpha]



I'll need to do some further testing.

Also, thx JP - I was familiar with pre-multiply etc, but your links provided some additional data I was not aware of.

Re: Merge Tool - operator Xor and faint lines "issue"

PostPosted: Wed Mar 15, 2017 8:04 pm
by Bryan Ray
Yeah, I'm not sure if the formulae in the manuals are what is actually going on, or if they've just been simplified a lot, or if my testing methods are flawed (quite likely). I have been attempting to document the behavior of each blend and arithmetic mode, but some of them are quite wonky in comparison to what the "official" math tells me they should do. I got stuck on Overlay and haven't revisited the matter in several weeks.

Re: Merge Tool - operator Xor and faint lines "issue"

PostPosted: Thu Mar 16, 2017 6:45 pm
by Okke Verbart
I now realise what the flaw is in the example...semi-transparent pixels "due to" the anti-aliasing, cause the effect mask to leave some of the background pixels "intact" to be affected by the Xor operation....