Jump to: Board index » General » Fusion

Merge Tool - operator Xor and faint lines "issue"

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

Okke Verbart

  • Posts: 290
  • Joined: Tue Jan 17, 2017 8:40 pm

Merge Tool - operator Xor and faint lines "issue"

PostTue Mar 14, 2017 8:17 pm

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 } },
      }
   }
}
www.ablackbirdcalledsue.com
Offline

Okke Verbart

  • Posts: 290
  • Joined: Tue Jan 17, 2017 8:40 pm

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

PostTue Mar 14, 2017 8:27 pm

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 } },
      }
   }
}
www.ablackbirdcalledsue.com
Offline

Okke Verbart

  • Posts: 290
  • Joined: Tue Jan 17, 2017 8:40 pm

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

PostTue Mar 14, 2017 9:22 pm

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.
www.ablackbirdcalledsue.com
Offline

JP Docherty

  • Posts: 188
  • Joined: Wed Dec 31, 2014 2:37 pm

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

PostWed Mar 15, 2017 10:12 am

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
Offline
User avatar

Bryan Ray

  • Posts: 2485
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

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

PostWed Mar 15, 2017 3:49 pm

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
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

Okke Verbart

  • Posts: 290
  • Joined: Tue Jan 17, 2017 8:40 pm

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

PostWed Mar 15, 2017 7:07 pm

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.
www.ablackbirdcalledsue.com
Offline
User avatar

Bryan Ray

  • Posts: 2485
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

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

PostWed Mar 15, 2017 8:04 pm

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.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

Okke Verbart

  • Posts: 290
  • Joined: Tue Jan 17, 2017 8:40 pm

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

PostThu Mar 16, 2017 6:45 pm

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....
www.ablackbirdcalledsue.com

Return to Fusion

Who is online

Users browsing this forum: No registered users and 24 guests