Macros with Custom Controls in DaVinci Resolve

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today we're going to make a macro that will draw a frame of a specific color and what we want to do is with this macro give you all the controls necessary to customize this so the things you might want to change with this is you would want to customize the width the height the thickness the position and the color so you have five things you'd like to control so let me first walk you through this so you can see what's going on dual display the first node is a rectangle that is a mask white is opaque black is transparent the second rectangle is also a mask which I've inverted so here white is opaque black is transparent and if you click on one node you can see its outline in both viewers so if we select rectangle 2 which is on the right you can see the size of the rectangle in viewer 1. conversely if you click on rectangle one and look at viewer 2 you can see the size of that rectangle as an outline what we want to do is to find where these two overlap and that will give us just this hollow frame and the way you can do that is you can chain these masks together come over here to the paint mode and select multiply because opaque or white is one and transparent or black is zero so if you multiply pixel by pixel the values the only time you're going to get a value of one is when it's 1 on both rectangles and that is a nice little hack to create the intersection I would have liked there to be a paint mode or combined mode says intersection but I think you'd have to go and work with booleans to make that happen lastly we have our background node and if we take this and use this as a mask for the background and display it we get this nicely colored frame now before we turn this into a macro and customize the interface let's rename these nodes so rectangle one is the outer rectangle rectangle two is the inner rectangle because if you use the default names for these nodes it can be a little bit confusing when you start to do the customization process and background let's just call that frame color I'm renaming them by the way just by pressing F2 so here we have the building blocks it's not perfect by the way notice how the vertical sides of the frame are thicker than the horizontal slides and we'll fix that as well the five controls we'd like to have well actually first let me show you what you would do if you did not customize it and then we'll start over and just customize it then so let's go through and click the three nodes right click come up to macro and say create macro when you do this you get a pop-up and it asks which of the controls from all these different nodes would you like to include in the output so if we click outer rectangle we'd like to include the width and the height and the center so you can come to Outer rectangle and say we would like the width and Heights let's check width and height and then position or the center next we'd like to do something similar for the inner rectangle we'd like to control the center width and height and then lastly for the frame color notice there's three tabs color image and settings over here there's like subfolders for the tabs we want to adjust the parameters in the color tab but we'd like color green blue and Alpha notice by the way color is top left red whereas the other parameters actually include the color random so this will give us the ability to control the color and then also notice that output is clicked because on the frame color node we want the output to be there one other thing I'd like to point out is if you look at the text or like the parameter or the option folders if you will if you look at outer rectangle notice that it's red if you uncheck everything it turns to Gray This is a little color indicator to let you know which nodes you've selected controls to to include in your macro so let's go back to our outer rectangle which is gray and we want Center width and height and close it do you want to save it yes when you save a collection of nodes or a macro it's all saved in a DOT setting file we're going to call this a colored frame next I'm going to come up to a text editor in my case I'm using visual studio code and we're just going to look at the file that this created it creates a macro operator and it lists which inputs you can access so for the outer rectangle we can access the center width and height next is for the inner rectangle there's the center width and height and then lastly for the frame color node there's the top left red green blue and Alpha then there's a single output remember the output was for the entire macro was on the frame color node and then this lists just the specifications for the nodes that are in our macro now let's delete that or close that I should say come back to a resolve and let's just delete this what we're going to do now is take and drag and drop this setting file in and this is our macro which we can look in the upper left and there are the controls there's one thing I'd like to draw your attention to it's a bit of a problem we have center with high type center with height the names aren't great because which Center is for the outer and which Center is for the inner and actually you don't want to have the inner and outer rectangles to have different centers so that's a bit of a problem but if you want to you can control the width of the outer rectangle the height of the outer rectangle you can click and change the color of the frame as well and there's no way to control the width necessarily I mean you can kind of by coming over here and adjusting the width of the inner but it would be nicer if there was a single number called width and that would control the width of the entire frame so what we're going to now do is go back to the initial macro delete this I'm just going to do undo until there we go we're back to where we started so how do we do this one really neat way is with adding custom controls so on frame color we know we want to include the ability to change the color but if on any node by the way what I'm about to do works on any node if you right click you can go to edit controls here is a way for you to create your own sliders and dials and other things like that to include over here and it's going to be included in a tab called user so the first one is let's call it frame width and a good idea might be to spell it correctly so the ID or that would appear on the Node panel here is frame width without spaces it's a number the default is let's say zero point one and the range can be from zero to one and what's allowed is from zero to one and for the input let's use a slider control that's like for the four colors here if you look at the red green blue and Alpha those are slider controls hit okay now you will see there's a new tab called user and there's a frame width defaults to 0.1 which you can now adjust and it's even keyframeable so let's come back to frame color right click go up to edit controls and we're going to add another one let's do frame height it's also going to be a number on the user page default is how also 0.1 range 0 to 1 and allow zero to one remember these are fractions of the width and height it's going to also be a slider control okay now we have frame width frame height next we want to add the thickness so we're going to come back to edit controls and let's call this thickness it's going to be a number and let's say the default is 0.01 range is 0 to 1 and allowed to zero to one by the way we could have the thickness be an integer like a number of pixels that would require a little bit more calculation in the expressions or you could do a percent here and it's really up to you whichever you're most comfortable with so I'm going to use a slider control for the thickness appear on the user page and when I click OK you'll see it appear over there there we go we have width height and thickness now if you come over to color we have the background color oh also Center I almost forgot that we need the ability to adjust the center of this so we're going to right click edit controls we're going to select point and we're going to call this Center and we want it to have an offset control and let's default to 0.5 0.5 so it will by default appear in the middle of the screen so there you go now what we would like to do is use these numbers to create the rectangles for us so rather than coming to Outer rectangle and dialing in the numbers in a rectangle and dialing in the numbers it would be great if all we did was specify the width height and thickness and these just automatically updated so how can we do that so click on frame color and let's pin this there that way it will always appear in the inspector let's go to the outer rectangle we'd like the center of the outer rectangle here to be the same as the center down there here's how you do that right click on this and go to expression and what this does is rather than you type in the numbers that you want you can now calculate the numbers you want you can calculate it by typing in a little a line of code here or there's this little plus if you grab the plus and come down to Center and hover over it and let up what this will now do is say whatever is the center for the frame color node use that value this in After Effects I think they call that a pick whip but it's a nice way to be able to not have to memorize the names for all these numbers just say add that value let's do that on inner rectangle two we'd like to Center the center of the inner rectangle to be the same as the center of the outer rectangle and we'd like that to be the center control that we added here so let's right click expression grab the plus and mouse over the value you want it to be let's go back to Outer rectangle width and height we would like that to be the frame width and frame height so we're going to go to width use expression and height use expression so for the width grab the plus come down to frame width for height grab the plus come down to frame height there we go now the frame height and width right now are quite small so I can just increase the size of those and you can see it's changing the let me display the outer rectangle to the left here so as you adjust the frame width The Mask or the outer rectangle mask also changes so that's great now let's come to the inner rectangle and for the width and height what we're going to do is use the same frame and width but we're going to make it a little bit smaller by the thickness amount so width let's take that so that is the same width as the outer rectangle but we want it to be a little bit smaller so we're going to do minus and then we'd like to subtract the thickness so we're going to take the Plus put it over thickness and now we have the expression you could type this in by hand if if you're really good at remembering names and things like this the little drag and drop plus sign a little drag and hover thing like that is a really convenient tool so it took the frame width and it subtracted the thickness we're going to now do the same thing for the height take the frame height and we're going to subtract the thickness there we go let's increase the size of the thickness and does the position work it does now we come to the one last little adjustment we need to make because these are all percent based and the width is 19 by 20 and the height is 1080. one percent of the width is different than one percent of the height so if we say the thickness we'd like it to be 0.1 it's gonna it's gonna have a different number of pixels horizontally than vertically so the way to fix that is let's come to the height and when you're working with HD or 4K footage the aspect ratio is 16 by nine so if we took the height and just took the thickness actually and scaled it by the aspect ratio we'll get the same number of pixels here and there I'll let you riddle this out but if you multiply it by 16 by 9 you now get the same number of pixels vertically as horizontally so now if you adjust the thickness it's a nice looking uniform thickness throughout the entire frame now that we've done this let's go through and save it we're going to select the three nodes right click and come to macro and create macro now let's call this macro colored frame and what we're going to do is come down to the frame color remember each one of these subfolders if you will is corresponds to a tab on the frame color node so if you select frame color you can see there's four tabs color image user settings here they call them color image user common I don't know why they don't match settings with settings but what can you do so we're going to come to user controls and we would like to export all of these but underneath the color tab we'd also like to include the color and so for the color we'd like to include the top left color is what you use when you're working with a solid color so we'd like to include the top left red green blue and Alpha so we have all those and you want your output and then close do you want to save it I really do so we're going to come back to our folder and we're going to overwrite the color frame.setting file with this one save and overwrite now if you open this file you will see that a lot of these things have been updated like here for example the frame height which defaults to 0.74 comes from the frame color node because remember we added these custom controls to the frame color node it defaults to 0.74 you can change the default if you'd like so here let's see if there's anything we'd want to change for now let's not change anything we've seen the file and if you ever want to do some more customizations you might need to go in and dig into the file a little bit and after you do it a few times it becomes second nature we're going to delete all this to demonstrate it we're going to take the colored frame.citing file and drag it in here we have colored frame and look at the controls we have over here we display it on the left we have the Color Picker so we can pick whatever color we'd like and it updates the frame you can change the width of the frame the height and the thickness and even the position right now the default position is not 0.5.5 so that's something we might want to fix so here what would be a good thing to do is let's have a default width of 0.5 and for a thickness how about 0.03 that looks like a nice good frame so for the color we could default to White why don't we let's select white and save that let's say these are the default values that we would like to use the only thing you'll really need to memorize is the thickness to be .03 come back to our file and look at the inputs the frame color the red is 0.05 by default the green is 0.36 and the blue is 0.52 we can update the defaults right here say we'd like the default red green and blue to be one and save now if we come down for Alpha we'd like it to to have a default of one we want it to be opaque the frame width let's default that to be 0.5 and the frame height also to be 0.5 and the frame thickness let's do .03 and the center to be 0.5.5 now let's save that come back to fusion and drag and drop the file in and there you go you now have oh my goodness what happened okay I'm now going through and double clicking each parameter and it then resets it to the default but this is interesting if you drag the file in while we know what the default values are that's not the initial values the initial values are different than the default values to get the default you always just double click on any parameter name and it will reset it to a default so we need to correct the initial values back to the file here we go and we set the default inputs for the controls and if we come down here and look at the tools we see for example this has different values and so this is an interesting thing actually that I I didn't expect that you would be able to have different initial ones than default ones so for the center let's have a default of 0.5.5 for the width and height let's have a default of 0.5 0.5 actually the we don't need to type in the numbers to the outer rectangle in a rectangle and everything that all comes down to the values of the color because if you look at the outer rectangle there's this thing called expression so the value is ignored if there's an expression so it uses the expression and it gets the frame height with the center from the frame color node so let's scroll down to the frame color here we look at the width and height the width and height of the overall background image is 1920x1080 which we'd like to have look at the color the top left red green and blue is not initially set to White so we're going to set that to White and then there is under user controls we have a width which we'd like to set a default value of the width to 0.03 there's a frame height which we'd like to set the default value to be 0.5 the I'm sorry I confused with with thickness so the default for the width should be 0.5 the height should be 0.5 the thickness should be have a default value 0.03 and the center is 0.5.5 let's save that come back to Fusion drag and drop this in and display it and it's almost correct the width and height are still not default and neither is a thickness so I must be missing something let's go back to the file one more time and and fix this once and for all so if we come up to the top we see are input controls the default values that we've typed in here are correct which we confirmed by double clicking on the parameter names and it did fix itself now we're coming to the tools the outer rectangle 0.5.5 but there's also the expression the center for the inner rectangle mask is has a value here but it's using the expression like here 0.483.628 drag and drop this in 0.483 yeah so it must be there must be some numbers that I missed come back here we have the expression so the key thing is the background node here we have the height the top left red green blue frame width frame height we like the frame width to be 0.5 frame High to be 0.5 the thickness to be 0.03 and the center to be 0.5.5 so this is a little bit interesting to me so the inputs here has these are the default inputs or the initial inputs but not the defaults and down here there are some initial controls as well here the initial control for the width is a half height is a half thickness is 0.03 and the center is a half and a half so we changed it twice I'm not sure if one is more important than the others but we'll see drag and drop this in display it and now it's doing exactly what we want it's and has the initial values that we'd like and you can now go through and change them to your liking so you can change red green and blue you can change even the alpha if you'd like but the default is one adjust the width and the height and even the thickness of this and notice how the thickness is going in towards the center of the frame and you can re-center it and with all these just double click on the label to see to reset it to the default value to the default initial value now if you want to install this so that it's always available when you start resolve you're going to come up to help documentation and developer go to Fusion templates and open the readme if you scroll down there is a section here called template paths this is telling you where to install that setting file so this is always available in my case I'm on windows so I'm going to copy this path and let me paste it in and my username isocratica and this is we could call this a title or a generator really whichever you'd like oh this must have been when I was playing around the other day so we can take the file that we made copy it and paste it in here and then if we come back to resolve and close let me delete this and then restart we can now see that this tool is available if you go to the edit page let's create a timeline are we in a timeline no let's we have a default timeline kind of line one let's just delete this and if you come up to the toolbox and go into titles and scroll down you will see there should be a custom frame where would that go there's a lot so let's just go ahead and search for it I think we call it a colored frame there it is a colored frame you can see it when you Mouse and hover scrub over it it will display what it currently is drag and drop it in and there we go one thing by the way that you'll notice is that it's a whiteboard or in a black background so we would probably want to fix this so that the default Alpha is actually zero because huh a little concerning there I thought let's see if there's anything behind this let's take a generator bring a solid color underneath this take this solid coloring let's just pick a blue there we go so initially when I brought this in I noticed the alpha was okay I confuse myself and I hope I didn't confuse you initially the alpha was one and I thought oh my goodness I needed to adjust the alpha but the alpha it was the alpha of the frame not the background this is I always get a little bit confused because the default color is always black I almost wish it would be a slightly different random color each time but what can you do so if we get rid of this solid color and we bring in just our colored frame it's black because it's transparent and there's nothing behind it so now if we created a generator that was just called a solid color and bring that in and give it a color that's not black like let's do a pale red there you go and if you want you can always change the color of this Frame like you could always say let's start off with the same background color I click in this selecting that that and then maybe making it a little bit of a different shade to make it just blend in a little bit more so there you go this is how you make a macro and by using custom controls you can build the interface that you want and here notice how we were even able to rename it here it's still called color you might want to change that to say frame color that's entirely up to you to do that you're just going to come back to the setting file and look for the tool and rename it so the tools that we have the outer rectangle the inner rectangle and the frame color the frame color is where is the name name where is the name let's see well I don't want to get too sidetracked I think the main takeaway here is that this is how you can create your own custom macros customize the interface to your locking set the presets set the default values and set the initial values which can be different package it up and go to help documentation developer to find where you want to put that setting file so that it's always available and resolve whenever you start this that's all for now and I will see you in the future
Info
Channel: Socratica FX
Views: 2,931
Rating: undefined out of 5
Keywords:
Id: 7_CyC4TjDv8
Channel Id: undefined
Length: 26min 5sec (1565 seconds)
Published: Wed Aug 02 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.