Page 1 of 1

Magic Mask looses mask if I adjust a different node

PostPosted: Thu Sep 15, 2022 5:03 pm
by JossSang
I have only just upgraded to Studio, so I am still swimming through Magic Mask.

If I create and track a mask on one node, it is all fine. If I then go to a different node on the same clip and change something (nudge the gamma, perhaps), my mask vanishes, and I need to track it again.

I don't have the most powerful system out, as a note.

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Fri Sep 16, 2022 8:03 am
by michael_72
I was just about to post an identical post as this... I have a pretty decent rig with up to date drivers so I don't think it is a horsepower issue... I have an AMD system, could that be a problem...?

Magic mask is truly magic, I am blown away by it... Fast, accurate and a time saver if only this glitch was ironed out... The mask data seems to be lost very arbitrarily, sometimes even without me changing parameters in other nodes...

Should the effect be applied only in parallel nodes or in the beginning or the end of a node tree, is there some workflow logic that I am missing...?

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Fri Sep 16, 2022 12:20 pm
by Steve Alexander
Think of it this way, if the video fed into the node with the magic mask changes in any way (by either a previous node or some other change on the edit page), the mask will be deleted under the hood.

With this in mind, you can imagine how you might have a separate path to a magic mask node and then borrow the alpha channel from that node to use in a downstream node, etc.

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Fri Sep 16, 2022 2:53 pm
by GalinMcMahon
There is a ton of discussion on this. Instructions at the bottom of: viewtopic.php?f=21&t=165381

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Fri Sep 16, 2022 3:28 pm
by Steve Alexander
GalinMcMahon wrote:There is a ton of discussion on this. Instructions at the bottom of: viewtopic.php?f=21&t=165381


Yes, I've seen your solution proposed by others as well. I think there are some cases where the magic mask tracking is lost unnecessarily and hence embedding it within a compound clip as you describe can offer an additional level of protection. I think BMD still has some work to do to make the magic mask more robust when it comes to upstream changes that would not necessarily invalidate the previous mask/tracking.

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Fri Sep 16, 2022 3:44 pm
by Andy Mees
To summarise, as it currently stands, Magic / Object Masks are inherently fragile... they are mostly static mask files generated by an algorithm, one for each frame. The algorithm looks at all the input pixels of a given reference frame in a clip instance, and, guided by a user defined stroke (or strokes), dynamically generates a mask for the arbitrary pixel area that it believes the user is most likely targeting on that reference frame. Tracking that chosen area generates a static cached mask file for each tracked non reference frame of the clip instance.

So far, so good. In practice, you jump into the Color Page, add a corrector node, define your object with a simple Magic Mask stroke and 'Viola!' ... you marvel at the result, track it and move on. Hurrah!

But then you adjust something... uh oh... maybe it was in the same node, maybe in another node or maybe you just made a tiny adjustment on another page... whatever you did, the (static) mask track is now gone and only the occasional (dynamic) reference frame lives to tell the tale.

As Steve says, it's because (regardless of your best intentions) your adjustment has caused a change to the input pixels of the Magic Mask, and, as far as the software is concerned, if the input data has changed then any previously cached data based on that input must be discarded / regenerated.

As suggested, you can certainly protect yourself against unexpected loss of cached masks by careful separation and management of your Color Page node operations ... there are some examples of that in this thread... but once in a while you might still lose them, it shouldn't happen often, but all cache files are somewhat temporary by nature.

And as Galin posted, another way some folks have developed to protect themselves, against casual magic mask cache loss, is to nest any magic mask generation operations inside a Compound Clip ie create a compound clip from the source clip instance, open the compound clip in its own timeline, add the magic mask to the source image as needed, generate the mask cache, and then finally step back out to the parent timeline... thereafter, when you manipulate the pixels of the compound clip, you are manipulating a separate pre-masked object rather than manipulating the pixels of the source clip itself (ie the mask input), thus the mask is preserved. Do be aware though that nesting magic masks inside compound clips comes with the current drawback that such contained masks can be 'hidden' from other standard software operations. Eg Using the Magic Mask >> Regenerate Object Mask > All Clips function at the main timeline level will not regenerate masks for any such nested clips; similarly, the automatic mask regeneration that's triggered via the Delivery Page 'Render' command will skip any nested masks.

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Fri Sep 16, 2022 4:19 pm
by Steve Alexander
Brilliant summary and words of wisdom, Andy! Thanks for posting this (should be pinned, lol).

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Sat Sep 17, 2022 9:19 am
by Sam Steti
Steve Alexander wrote:Brilliant summary and words of wisdom, Andy! Thanks for posting this (should be pinned, lol).

Yes indeed, except on line 7-8 : I can assert that the correct expression is "Et voilĂ " :lol: :lol: :lol:

(just kidding, I know it's a typo)

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Sat Sep 17, 2022 10:31 am
by Andy Mees
Doh! Sam, by way of an apology, please accept the below entirely intentional violas... :)
Image Image

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Sat Sep 17, 2022 10:38 am
by Sam Steti
Fully accepted 8-) :mrgreen:

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Mon Sep 26, 2022 12:55 pm
by JossSang
Thanks for all the info, everyone!

I went a little cross-eyed, but only a little.

I would have jumped in earlier, but I forgot to have notifications on. Oops!

I can see why it happens now from the above explanations, but perhaps, therefore, it needs a little more intelligence built in, or perhaps a simple command that effectively locks the mask cache or whatever until unlocked.

Or perhaps a warning:

"Hi, this is Magic Mast from clip number ###. My input pixels have changed, do you want me to ignore them?"

I look forward to further developments. But this is all fun.

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Thu Sep 07, 2023 6:45 am
by FlyingZayin
Andy Mees wrote:another way some folks have developed to protect themselves, against casual magic mask cache loss, is to nest any magic mask generation operations inside a Compound Clip ie create a compound clip from the source clip instance, open the compound clip in its own timeline, add the magic mask to the source image as needed, generate the mask cache, and then finally step back out to the parent timeline... thereafter, when you manipulate the pixels of the compound clip, you are manipulating a separate pre-masked object rather than manipulating the pixels of the source clip itself (ie the mask input), thus the mask is preserved. Do be aware though that nesting magic masks inside compound clips comes with the current drawback that such contained masks can be 'hidden' from other standard software operations. Eg Using the Magic Mask >> Regenerate Object Mask > All Clips function at the main timeline level will not regenerate masks for any such nested clips; similarly, the automatic mask regeneration that's triggered via the Delivery Page 'Render' command will skip any nested masks.


>>FF>> Fast Forward to September, 2023. Davinci Studio 18.5.

I'm having a longish (about 30 seconds) clip that I have to use MM twice on.
First, I need to color correct the object in the foreground, separating it from the rest of the picture.
Second, I need to split the clip into three parts of about 10 secs each.
Third, I need to take one of these parts to Fusion, once again MM-out the same object, and make a 3d text orbiting around it.

My actions:
For the First, I do as advised: compound the whole clip, open in timeline, MM the object, colorize it to my liking, all good, back to main timeline.
For the Second, I split the compound clip - so nice, nothing is lost, everything stays in place. But I'm rejoicing a bit too early, because...
When I proceed to the Third, and open the needed fragment in Fusion, create MM node, draw the mask, and click "track" - nothing happens. The node doesn't blink green, no tracking occurs, no matter what I do (restart DVR, reboot the computer, toggle between Better and Faster MM modes, etc., I literally tried every option available).

Looks like Fusion doesn't like applying MM to compound clips to which MM had already been applied somewhere upstream.
Now what, BlackMagicDesign? How many more surprises with Magic Mask are you hiding up your sleeve?

Re: Magic Mask looses mask if I adjust a different node

PostPosted: Tue Sep 10, 2024 6:05 pm
by DefinitelyMatt
Magic Mask has been the best and most infuriating tool to use! I cannot imagine anyone who would want their mask to disappear because they made a small change to any part of their grade... At the very least there should be an option to bake in the mask.

However in the meantime, this is the best solution I've found.

Instead of using magic mask in line with your other nodes, create a new node and link it to the source point, then slap on a lut or something to give it some contrast, add a node to that for your magic mask, then link it back to a node where the rest of your grade is with a mask link.

Here's a basic example:

O-->(02) LUT-->(04) Magic Mask-->(05) MM SAT

O-->(01) LUT-->(03) Contrast-->(05) MM SAT-->O

This way any changes you make to Node 01, 03 or any additional nodes you add after will not mess up your magic mask.

It's not perfect though... If you make any changes in your edit tab like extending the clip, reframing or stabilisation that will still undo your magic mask.

I really hope this makes sense and helps someone save a few hours of banging their head against their desk.