How I Made The Best 2d Facial Rig [Blender 3.4 & +4.0]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey you want to see what I consider blender magic check this out I got this Dynamic 2D facial system that I made that's really easy to use and has a lot of cool features like animated textures and dynamic eye movement and all these expressions are stored and accessible through the asset Library you want to see something that's even more cool well this system I made you can also add it to just about any character that you went with just a few steps first I'm going to go into the Shader editor and add the Shader node that contains the whole eye control system then I'm going to go into the asset browser and add the control rig which drives the system and join it to my character's rig then I'm going to go into the system node itself load my character's eye textures into the texture nodes and refactor the drivers to fit the new rig and the new scene then finally I'm going to add two UV warp modifiers targeting the appropriate UV maps and Bones of my character and Bam I got a newly working 2D facial rig now this may seem a bit complicated at first but after this tutorial video you're going to know how to make your own version of this robust 2D control system and even maybe iterate on top of it so this tutorial was inspired about a week ago when I saw this video on Twitter showing off this eye control system it was made by Brawler's World which is a fellow 3D animator and it went a bit like this so brawler has these eyes here in blender and they are controlling them through an amateur they can be of the pupils independently inside the bounds of the eye and with these switches on the side they can alter the shape of the eyes to whatever expression that they want as you can see though this system is rather janky and they admit to this in the Tweet below it that it isn't as efficient as they would want it to be and this video got me thinking how would I improve on this system work better yet what would be the best 2D facial rig that I could make there's a lot of tutorials out there that show off how to make a 2d facial system and I have at one point or another in the past probably utilized every technique from all of them for my own purposes and for basically all the ones that I have used looking back I have some contentions on their usability or their implementation or construction some of them used image textures Daisy chained together in one long string some of them stored their facial textures inside these image atlases and moved the UV maps about to select a specific face some of them even use geometry country nodes drivers or incredibly complex mathematical equations to make their systems work each system that I analyze had certain drawbacks that I felt made them unintuitive or even painful for me to use the way that I see it I just don't find any of these to be an acceptable system as they are they definitely work and they definitely have value because each one gave me insight into some important techniques but for me as an animator they do not provide the freedom that I'm looking for these systems are just too difficult to manage and they only become more problematic the more that you add to them for the purpose of this video and for myself I wanted to make something that was generally my ideal 2D facial system when that was far more robust eloquent and easy to use I wanted to build a system that was reusable easy to implement into other characters and that is easy to create texture faces for without the fear of bloating with no need of pointless math which requires minimal planning or organizing and doesn't require any bone sliders or Geo nodes or overtly complex mechanics um so I did I did do that so here's the final eye control setup that I should in the beginning and I'm going to now start to break down exactly how my ideal control system works the center bone right here controls the direction that the eyes look as well as the spacing between them and their rotation additionally we have this bone here that can scale and rotate the pupils on their own axis as well as take independent control of the pupils scale and rotation these are just the basic controls and the benefit of this is that it basically gives me Dynamic control over where the eyes look at all time removing the need to store eye Direction in as its own texture now we're going to talk about the good stuff I'm going to go up here to these bones right here labeled eye States these buns right here are special because they control um well they control a lot of things actually the simple explanation is that these bones control the shape of the eyes as well as the shape of the pupils if we go into the expression demo action and we select these bones we can see that they are keyframed for every instance of change in the eyes of this character here's where the magic comes in these bones are locked in all transforms you can't move them or scale them or do anything with them so to use these bones um you you don't even need to select them at all actually just unselect everything and what I have done is I've made a bunch of post Assets in the blender asset Library they have their own thumbnails tags and descriptions some of them change only the pupils some of them change the eye shapes some can do both some of them are even animated and the best part about it is all you have to do to use them is just go into the keyframe that you want and just click on the expression you want you can see that the keyframes were added into the bones themselves and they can even be flipped if it's enabled just like any other pose asset it's really just that easy and that was the simplified answer of what these bones do the more complicated answer of what these bones do will become apparent when we go over here and actually look inside the bones custom properties these bones store the value of every driver that controls the eye shapes and the peoples for their respective side driving what specifically you may ask well if we open up the Shader editor and we take a look at our material for a character the four bones are driving these four nodes here these are image sequence nodes they are like a special image textured node that can store more than one image at a time effectively what I'm doing with them is I'm using them as a container to cycle through my character's textures based on a certain property within the eye State bones and as a dumb little bonus for this bone right here which controls the scale and rotation of the eyes I also have a driver that enables it to procedurally give a spinning animation not as many use cases but I can at least do this for a dazed expression now I could go on and fully explain every single node connection currently on screen down to the very intricate workings of how every driver interacts inside the image sequence nodes and that would be a very shitty tutorial because that would be a lecture so what I'm going to do instead is I'm going to take everything my several days of tinkering workshopping programming and just Chuck it straight in the bin and start from scratch working through the entire process from beginning to end so just give me a few seconds while I do that okay here we are we have our blank clean slate to work with uh I'm going to continue using this character brush that I made since this approach should work for any character model as long as it is not using a mirror modifier a quick disclaimer before I start I'm using a different control setup than the ones that come with blender by default I'm still using blender 2.7x controls with some of my own hotkeys as well as some add-ons I'll talk about as they become necessary additionally I need to express this tutorial is not for game development I don't think you can export this system and its animations uh I it's strictly for animating a character's face within blender itself I have talked to some people about this and they seem pretty sure that you can make a similar system in like Unity or unreal or whatever but I'm strictly an animator and not a programmer so the first thing that we need to do before we even start texture painting is we are going to need to set up the region for this character's eye textures to even sit we are first going to be creating UV Maps now don't panic I know UV mapping is the bane of most people when it comes to 3D modeling this is going to be really simple so what we're going to do is we're going to go into our object data properties here for our model and we're going to go into the UV Maps menu where we can find our current map and here we're going to click on this plus button and what that's going to do is it's going to create a duplicate of our currently selected UV map there's only one anyway but it's important to remember now we're going to select our newly made UV map and rename it to Iota L and we're going to go up here to the UV editor tab what we're going to do here is basically just select all of our UV Islands by hitting a and then we're going to just hit s and scale them down to zero to shrink them down to a singular point and then hit G to just move them off somewhere way out of bounds what we're going to do now is go back to our model and then edit mode we're going to select the region of the face where our left eye is going to be sitting and once we have that area selected I'm going to hit unwrap and this should create a new UV Island you should be able to see it over here in the UV space this island will probably need to be readjusted so that way it's upright in the UV space so I'm just going to rotate it a little bit and then I'm going to do a UV pack on the island so that way it fills the bounds of the space turn off rotation so that way it actually keeps my adjustment then I'll try to Center the island in the space as best as I can with our UV Island now in plates we can begin to figure out what the resolution of our architecture should be so that way it can be as close to seamless as possible with the base texture to figure that out it's time to go into the Shader editor we're going to be making something called a Texel density Checker which is basically going to let us measure the resolution of our base texture so that way we know what the resolution of our eye texture should be it's super simple I'm going to add a UV map node set it to i.l then I'm going to add a checkerboard texture and feed the vector of the UV map node into the checkerboard then finally what I'm going to do is I'm going to add a mixed color node then plug the base texture in slot a and our text Will Checker into slot B and with everything plugged in I can make some minor adjustments aligning the UV map to be more aligned with the base texture and setting the scale to be approximately close to the resolution as we need it to be it doesn't need to be perfect but it just has to be decently close once you got your Texel Checker as close as you'd like it to be all you have to do is round the scale to the closest integer and use that as your resolution for your texture and with that we can just replace the checkered texture entirely for New Image texture we're going to hit New Image set the name to Ida L and plug in our measured resolution and then what we're going to do is we're going to set the base color of our texture from black to full transparency and hit OK with a newly made texture we're going to also need to plug in the alpha channel into the mix Factor so we're actually layering our eye on top of it and not just blending between them and then we're also going to have to change this setting here that says repeat having this texture on repeat is a problem because that means that it tiles along the UV space which can cause problems if the UV islands that we scaled to a point just so happen to sit on one of those tilings so for our sake we're going to set this to clip which will prevent that from happening now with our image texture properly set up we should be able to just paint our eyes directly on our character though we have to make sure that we have the Ida L UV map selected as well as the Ida L texture selected otherwise we may end up painting on the base layer instead we're going to be starting with a neutral expression since that's going to be the basis from which we build all of our expressions and for the purpose of this I suggest that you use grayscale I'll be using black for the outlines and we're not going to be using any color colors are going to be important when it comes to masking and I'll be using a masking system that draws from the value and saturation of this eye texture which if that doesn't make any sense it will when we actually start talking about how we layer the people in all right I got my eye texture here made now and what I'm going to do next is actually very important I'm going to go up here to the image editor I'm going to save my texture yeah big funny I know it's important to save your textures I know I've lost many image textures because blender crashed and wiped all my work before but that's not the point pay attention to this I'm going to go into my textures folder here and I'm going to make a new folder called istates as well as people States I might as well since I'm here and I'm going to open up the Ice dates folder and this is the really important part I'm going to save this texture as 0 0 0 1 for every single I stay or pupil State texture that we are going to be saving from this point forward they must be saved as a four digit sequence it is essential for this system to work it doesn't matter if the number sequences are at our order like zero 420 or 69.69 it just has to contain a four digit sequence and give them a name if you want it as well like say cobbled i001 or characterize001 but if you do that they must stay the same throughout the entire folder you can't mix names like sati005 or angry006 or it'll again break the system organization isn't my strongest suit so I can't tell you the best way of how to name or organize image textures by numbers with that being said though I typically keep them all together sequentially starting from one and counting up unless there's a special case which I'll clear up when we start to talk about animated sequences now that we have our image texture saved as character eyes one which is how I'm going to be reading these sequences from now on I'm also going to be saving this texture as characterize zero it gives us a backup and it also has a minorly important role to the system but I'll get to that in a second from here on we can begin to expand on our character by adding different eye expressions and variation as many as you feel appropriate the benefit of this system is that it can support at least in our case up to 10 000 different textures and because of this you don't have to worry about the scalability or the system growing rigid as you add to it like any other system and at some point down the line if you want to add more Expressions you can very easily do so and you can even have textures that use completely different sizes and aspect ratios if you felt so inclined so once you have as many different Expressions as you feel is appropriate we're now going to take our image texture i.l and we're going to convert it into an image sequence by clicking on this drop down here and selecting image sequence okay the image sequence node the image sequence node is basically a giant image array and what it's doing right now is it is loading the very first image of our istate folder which is characterized one and it loads this image on the very first frame of our timeline and stops at frame one the image array wants to load more images if we increase the amount of frames of the node and toggle Auto refresh we can see this cycling take place in the animation if we can change when this animation starts by adjusting the start frames value to be more precise the image sequence node is an animator and these values set the bounds of that playback this is one of the reasons why I have an image 0 aside from having a backup it also prevents having a missing texture additionally if we toggle cyclical we can watch it play back on screen based on the bounce that we set looping between these values obviously none of this is actually helpful to me I don't want it to animate because that's my job to set this node up to work properly for our purposes we're going to make sure a few things are in place first off frames and start frames need to be set to one second Auto refresh needs to be enabled and cyclical is literally worthless we're going to be programming our own system that does the exact same job but better around the time we start to talk about drivers now the way we're going to use the image sequence node and tell it what image we want to pull from the folder is by adjusting the offset slider the offset slider is really the only thing that we care about and just about every custom property that you saw was targeting the offset of an image sequence node the offset value acts as an index of an array and of course zero is the starting point so whatever the offset value is we'll return the image of the given sequence address so in a sense four digit nomenclature that we used in our texturing was basically us declaring how large of an array we intended to use I'm pretty sure 10 000 slots for texturing is more than enough for our purposes I'd rather Overkill it than have to refactor a lot of images don't you think all right we got our eye textures done for now so we can now begin to work on the pupils we need to repeat the same process as you did to make the left eye sequence starting with making another UV map that's easier this time around since you just have to select the Ida l u v and hit plus and that'll create a complete duplicate of it now for the pupil textured themselves the way that I do them is I normally start with a color background typically white and then I make the actual eye part in the center of the image I put my pupils in the center of the image so that way it gives me the most room to work within because it's in the at all you also probably have to move your UV maps to fit them accordingly just a heads up also the reason why I'm using white and not Alpha is because I like to mix my pupils over my eye textures with multiply so the change in color values on the eyes and shapes kind of acts like a fake shading also it's important for the extrapolation mode of this texture to be set to extend rather than repeat or clip this will prevent having your pupils loop around your eye texture when you scale them up or down as well as preventing the boundaries of your texture from showing up black speaking of layer mixing I'm going to show off how that's done right now so our pupil and I stay image sequence nodes we are going to create a new color mix node with the method set to multiply and then hook them up like this Eyes On Top pupils on the bottom and for the factor we're going to take the color not the alpha of our eye sequence nodes and plug that into our texture mask I'm going to add a separate color node and plug into the color like this then I'm going to set the method from RGB to HSV then I'm going to add a math note set to multiply and join our saturation and brightness values what I'm trying to do here is I'm trying to make a threshold where the pupils are going to be masked out depending on how dark the color of the eye shape is going to be as well as how saturated that color is going to be using this math node to join them together for myself I want to allow the pupil layer to be able to mix with colors above a value of 0.125 as well as colors below a saturation of 0.5 and this can be done with a greater than and less than math node respectively this masking setup allows me to do extra stuff with the eye shapes like tears or weird little cracks and really the thresholds that I provided aren't really that important feel free to expand with them as you feel like it these are just the values that I'm using but I will suggest that once you get these math nodes set up that you group them together so that way you can use them for later in the right eye system doing it this way also means that you can just edit one of them and it changes both of them since they use the same data set and with that we've successfully made the left eye setup now we just have to repeat the process for the right eye unfortunately we can duplicate most of our work to create it we will have to create the right eye and pupil UV Maps but I'm going to show you an easy way how to do that if your characters like mine it should be perfectly symmetrical from left to right so what I'm going to do is I'm going to select the area with the left eye in the area where I want the right eye to be then I'm going to hit Y and what this is going to do is going to break these sections away from the mesh and this is important because what I'm going to do next is I'm going to go up here to mesh and I'm going to hit symmetrize and then set the direction from positive X to Negative X this is going to mirror the left eye over to the right eye and if we did not hit Y to break those areas away from the mesh when we symmetrized it over it would have deleted portion of the character's face and that's obviously not good as we complete the symmetries I'm just going to fully select my character and hit M to bring up the merge menu and then hit merge by distance to rejoin my eye areas that I separated back into the character's mesh now that we've done that what we need to do is we need to make this newly duplicated area into its own eye it is currently sharing the same information as the left eye when which we don't want but we do want to copy the UV data so we can reuse it so back in the object data properties what we're going to do is we're going to select each the left eye and left pupil UVS and then make a duplicate of them by clicking on each of them and hitting the plus sign to make a copy now that we have a duplicate of the left eye and pupil UVS we can go about renaming them and also starting the process of isolating the left side from the right side since they're duplicates they both share the exact same data and that's not good but the right side selected we can go into the left eye and pupil maps and scale our UV Islands down to move them out of the space to clean it then we'll need to repeat this for the left side by selecting the left eye area and doing the same thing for the right eye in pupil UV maps and finally what we will need to do is we need to take the right eye pupil map and flip it horizontally across the center point of the space so that way it'll match the left side so in the UV editor in the view tab we'll need to set the 2D cursor's X location to 0.5 then set our pivot mode to the 2D cursor and then select the right pupil UV Island and scale it by negative one across the x-axis to flip it to the way that we want it this set up the textures for the new eyes we can take our old system for the left eye and duplicate it and move it down what I like to do is I like to take these and frame them within the Shader editor so I can tell which section of the nodes do what I do this with the node Wrangler add-on I just select the nodes I want to frame hit Ctrl J and it will bind them within a box I can set the color and even label these frames so I can both name and color code them so I know which ones do what and when we duplicate our left eye system down we're going to need to do two things one is we need to refactor the UV map node so that they're actually targeting the right side instead and secondly we need to make sure that we click on this little button here on the image sequence nodes with the little two in it what this button indicates is that this node shares the same data from the one that we copied from which means that we can't offset them to create more Dynamic expressions and this is just bad and it'll break things when we get drivers involved so clicking this button makes it its own data set and we can use it as we normally would we can then join the right eye into our system by using a color mix node set to mix and using the alpha of the right eye like so and we should now have both left and right eyes set up properly now all you have to do is the actual hard part of this which is making the controls for the actual face system I already have a rig set up that I have the character weighted to she can look around and move her head and mouth but now I need to add Eye controls that'll allow her to look around and express I'll be adding those controls onto this rig so I'm going to select it and I'll go into edit mode and I'm going to move the 3D cursor to the center of our character's head and hit shift a to add a new bone to this position I'm then going to position this bone in front of her face like this and I'm going to name this bone UV pupil base this bone here is going to be parented to the Head bone so that way when she looks around this bone will also follow where she looks to continue with the full control setup we're going to need four more bones two to represent our respective pupils and two more bones to control all our pupils we can make the pupil bones first by duplicating our base moving it over to the left then we can name it UV pupil.l and then symmetrizing it over to the right I'll duplicate the UV base bone again scale it up and then rename it UV pupil master and then parent both of the pupil bones to this bone I'm also going to go into each pupil bone and turn off inherent scale we don't want the master pupil to control the influence of those values then I'm going to duplicate the master pupil controls and rotate it 90 degrees this way this bone is going to be called UV pupil transform and it's going to be parented to the pupil Master bone just as the pupil bones were now the way that we're going to set up the controls for our character's eye movement is going to be done through a modifier we're going to leave edit mode and select our character mesh and in the modifiers tab we're going to look for the UV warp modifier I'll be starting with the left side first for this modifier we need to feed it which UV maps are going to be manipulated which for us will be the pupils.l layer then we'll need to tell the modifier how we're going to manipulator you v's and for this in the objects from and two fields we will be selecting our Armature this will create two new fields for us to select which Bones we are going to be using for this modifier and we'll be using from UV pupil base to UV pupil.l if we did it correctly the pupil texture should be offset to our characters left somewhere we're gonna have to reel this back into place and the way that I do it is I turn off the modifier for a second place the 3D cursor on a point that I can remember turn the modifier back on then open up the transform menu and adjust the offset of the warp modifier to fit where it used to be the process is the exact same for the right eye just targeting the right side instead here's a quick way to do that we're just going to hover over our UV wart modifier and hit shift d to duplicate it then we're going to scroll down and make some quick changes changing the UV layer to pupil.r changing the bone fill to UV pupil.r and then take the offset value and setting to the negative of the current value when you're done you should be able to control where the character is able to look using the master pupil controls as well as individually offset each eye by moving the pupil bones since we got this working I would also like to take a second to clean up our bones for one when we added them they were set to deform by default and that shouldn't be since they shouldn't be affecting the mesh in any capacity so I'll select all of them and hit alt W and select deforms to turn that off I also want to clean up the transforms to make sure that they don't act weird the first thing I'm going to do is change the rotation mode of all these bones from quaternion to Euler XYZ Euler is simpler than quaternions and they'll just make our lives easier next the UV base bone needs all their transforms locked since there's literally no reason for us to ever need to move it the pupils and master pupil bones I'll lock on the Z locational transform as well as the X and Y rotational axis since I effectively want to lock them into a 2d space in front of my character and for the pupil transform bone I'm going to lock everything except the Y scale and rotational transform channels additionally what I want to do is I want to add a limit distance constraint to the master pupil controls so that way I can't move the eyes off infinitely in some given Direction so what I'm going to do is I'm going to take the master pupil bone and move it off just a little bit to the left until the right eye is barely visible then what I'm going to do is select the UV base bone then the master pupil bone and hit Ctrl shift C to make a targeted constraint which I'm going to select limited distance and this will limit this bone within a radius around the UV base which means it can no longer go off infinitely outside the bounds of the eyes just have to make sure that we change the Target and owner spaces to local so that scaling this character won't cause issues okay next on the list of controls is the pupil transform bone so the way that I want this to work is when I scale this bone on the y-axis I can manipulate the overall scale of both the left and right pupils additionally when I rotate this bone I want to rotate both pupils at the same time on their axis I'm not going to be using a copy rotation or scale constraint because well they simply won't do what I want them to what I'm going to be doing instead is selecting our transform bone and then our left pupil and hit Ctrl shift C to make a targeted constraint I'm going to select the transform constraint for this transform constraint I'm going to want to set the Target and owner to local space and rename the constraint to scale control I'm going to go down here and open up the map from and two drop downs I'm going to take the scale of the y-axis from the transform bone for the minimum I want it to be 0.5 and for the maximum I want it to be 2. for the map 2 Fields I'm also again wanting to Target the scale but here I wanted to Source the transform of the y-axis of our Target so I'm going to change the source for all these to the y-axis and for our ranges I'm going to put in 0.25 as a minimum and 2.5 for a maximum and finally we're going to change the mixing mode from replace to multiply so that way we can still edit the scale of our pupil bones individually this should create a decent range for our scale and Rotator bone to control now all we have to do is do the same for the rotation so we're going to make the exact same transform constraint this time targeting the rotation and for the rotation minimum we want to put negative 180 and 180 for the maximum we're going to map the same values to the Z rotation sourcing the targeting y-axis and the transform bone should now allow us to both rotate and scale the left pupil and for Polish sake I'm going to add a limit scale constraint to our transform bone to clamp it between 0.5 and 2 since we won't need any value outside of this range now that we got both of these transform constraints all we need to do is change them over into the other pupil bone to do that we're going to first enable an add-on in blender called the copy attributes menu go up into the edit menu hit edit preferences go to add-ons search copy attributes and it should pop up you can enable it and save your preferences and now we can easily transfer our constraints over so first we're going to select the bone we want to transfer to which is our right bone then select the bone we want to pull from the left bone hit Ctrl C to bring up the copy attributes menu then go down to copy selected constraints and here we can select our scale and rotation constraints and hit OK and now both eyes should be controlled by this transform bone and we now have full control over the movement of our character's eyes so after all that we got the basic controls for our eyes now we need to make the bones to control our image sequence notes that way we can without touching the Shader editor change our character's expressions from our istate controllers so to start off I'm going to be making a new bone called istate i.l it is very important to include the dot L at the end of our names because it's going to save us a lot of time in the future I'm going to place our istate bone over our character's head and I'm going to set the parent of this bone to the Head bone then I'm going to go into pose mode and just lock all of the transforms for this bone we're not going to be needing these at all now the next thing we're going to do is we're going to be adding properties to this bone we're going to doing this in pose mode by going into the bones data property scroll all the way down to the bottom and I'm going to hit the button to create a new one this will create a new float property called prop also it's important that we're actually in pose mode when we add custom properties here if we're in edit mode we won't actually be able to use these for some reason we right click it we won't be able to copy it or use it and it just disappears whenever we leave edit mode I think it might be a bug but I'm not sure anyway we're going to be editing this property by clicking on this Cog icon here now this property is simply going to be called texture address it's going to control the index of our image sequence node and that lets us cycle through our textures we don't want this property to be a float value so I'm going to change it to an integer I'm going to set the maximum value to 10 000 since that's the largest possible value our system can support and then I'm going to set the minimum value to 1 and hit OK with our property established we now need to take it and make it into a driver so what I'm going to do is I'm going to right click on the value of our property and go down here to copy as new driver I'm going to go into the Shader editor where we have our i.l image sequence and I'm going to right click on the offset and go into paste driver the offset value of our image sequence node should now be purple which means that it is now being controlled by this property and technically if you just wanted a simple system this is all you really need this one driver and nothing else you just move on to making the other three bones with the exact same property and well you gotta copy their drivers into their respective nodes as well but you get the idea it's simple everything else is just sprinkles and eye candy but they're still important to me and you're going to learn about them anyway I'm going to right click on our new offset driver and hit edit driver which will bring up this menu here in the driver editor right now it is currently set to average which just means it will average together any variable that we plug into it and we don't want that so what we're going to do is we're going to set this to a scripted expression instead and this field right here this is where we're going to do all the programming for our drivers to do everything texture index animation controls frame rate controls reverse controls everything and that sounds super complicated but at actually it's surprisingly simple for such a complicated system with all said and done the final equation will look a bit like this and I'll be explaining every variable as they come up while writing it so the first portion of our equation we'll be doing right now this right here texture address is the current name of our variable that represents our texture address I'm going to be shorting it down to text in the script field we're going to have to refactor our valuable so that way we don't have a null variable reference and then I'm going to put text in parentheses our address property isn't the exact index for when we're cycling through our image sequence if you remember how array indexes work with the offset being one we're actually pulling the second texture from the sequence so we're going to have to offset this variable by minus one technically we don't have to do this and we can just edit our property to have a minimum of zero and a maximum of 999 but I don't want to have to do the metal map of subtracting one every time so now that we've got the index set up we can now begin to incorporate the animation portion of our script to make editing our drivers a little easier what I'm going to do is go up here in the Shader editor and I'm going to click on this little thumb Tech icon so now when we select our Armature to go into pose mode to access our control bones our material will stay on screen and we can easily swap back and forth now for our next variable we're going to pull from blender what the current frame of Animation is since we're dealing with animated textures we're going to need a way to measure time so what we're going to do is go into the timeline and right click the value of the current frame to copy it as a new driver and to put it in our equation we're going to go back into the driver editor and click on this button here this will paste the information that we copied from the current frame value as a new variable and from here we can put this into the equation AS Plus current frame however I would like to change the variable from current frame to the Greek symbol Delta because well it represents time it's short I know what it means and it also just really looks nice honestly it's kind of a pain in the ass because you'd have to copy the character from online to paste it in so if you like just use like X or something works all the same so with our time variable in the equation what should happen now is that as the current frame progresses our image index should increase this is because we are now adding the numerical value of the current frame to our index and this will continue 1 until Infinity which we don't want so we need a way to limit the output of Delta to a range and that is where the bounds variable comes in we're going to be creating a new custom property called textured Loop bounds and this property is going to be an integer property the default value of one a minimum value of 1 and a maximum of doesn't really matter the big number now it's very important that this value never equals zero because we're going to be doing some division with this number and if this value ever equals zero the whole driver breaks and that's bad because we have to start all over again so we're going to paste this in as a new variable and we're going to rename it to Bound in the equation and to use it we're going to take Delta and do what's called a modulus so instead of using a divide sign we're going to use a percent sign and what this is going to do is it's basically a fancy division it's going to give us the remainder of whatever we divide by so with the bounds value set to 1 the modulus will always return a value of zero since it always divides by one as we increase this very variable this also increases the range that it can return something that bounds value higher the one basically causes the image sequence to begin cycling through the animation up until that value before starting over again and with this variable we can effectively set up a playback range for animated textures if they in fact exist within our sequence now the problem that I have is that we have no control over the speed at which these animations play back the playback speed is dependent entirely on our blend file which is currently set to 24 frames per second and we have no way to independently set that within the texture animation now we're going to create our playback speed property which we're going to call Delta step or frame step if you don't want to use Delta this property is going to be an integer a minimum of one and a maximum of the again doesn't matter I'm going to paste it in as a new variable and rename it two-step and then what we're going to do is we're going to divide Delta by the step variable and encapsulate this in parentheses and then to ensure that this outputs an integer value we're going to type round next to our now encapsulated expression so now as the animation plays with our texture anime mating if we adjust the step value the playback of our animation will become slower and slower requiring more frames to pass before cycling on to the next frame so the next variable we're going to create is Delta warp frame offset and basically what it'll do is it'll allow us to control the current frame of the animated texture sequence as of right now if we set a texture to animate when the animated sequence is called based on the address and the frame boundaries the Cold Frame of that sequence will start depending on the current frame value which makes much just making my brain melt okay basically if we want to force it to be on a certain frame regardless of the current frame we can adjust the frame offset and then we can do that so in the custom properties tab we're going to make a new property called Delta offset and it's going to have a default value of 0 and a minimum a maximum of uh big numbers I'm going to paste this into the driver editor rename it to offset and we're going to encapsulate again the Delta value within parentheses and in these parentheses we're just going to add the offset variable and this this should allow us to control where the current frame is of our animated sequences based on the offset value and finally if for some reason we wanted to reverse the order of the sequence well we currently don't have a way of doing so in theory we could just allow the speed or step property to go into the negative values but the issue with that is is that would allow us to possibly pass a zero value into the equation if you remember that's bad dividing by zero is bad it'll break everything don't do it so what we need is a new property called Delta reverse it's going to be a simple integer property with a default value of 0 and a minimum and maximum range of zero to one it's basically just a billion I wish blender had Boolean custom properties it looks so cool if it had like a little check mark it'd be nice it'd be great unfortunately we don't have that so we're just going to paste it in as a new variable rename it to reverse and well we are going to have to be careful here for this final addition to the equation we're going to have to need to Target the step value we're going to encapsulate in parentheses and we're going to multiply it by this expression 1 minus two times reverse so what this is going to do is basically our reverse property is at acting as a toggle when it is zero or false it will go through the equation uh two times zero is zero one minus zero is one step times one is Step so there's no change but if the reverse is true if it's one uh then two times one is two one minus two is negative one and step times negative one is negative step which will reverse the order of the animation that it's played back and give us the control to reverse animation and that right there caps off the entire control driver for our image sequence it's honestly incredible how simple it actually is when you sit and look at it it's only a single line of code and it does so much now the issue is is we need to do this for the remaining three image sequence nodes since we have our final driver actually complete here's what we're going to do I'm going to right click on the image sequence driver that we just made and hit copy driver and then what I'm going to do is I'm going to paste it into the offset of every other sequence node so now that we have this driver in place all of our nodes we can control them with this one bones custom properties obviously we don't want this one bone to control all of these so we're going to need new bones with their own custom properties and rewire the drivers to Target them instead unfortunately we do have a way to save time in that regard so what I'm going to do is I'm going to go into edit mode and select our I State bones and I'm going to duplicate it for the time being I'm going to leave the duplicate in the same position as our original and I'm going to rename it to istate pupil.l this duplicate bone has all the original custom properties that we created as you can see but I'm not done what I'm going to do now is I'm going to select both the eye and pupil bones here and I'm going to go up here to amateurs and then go down to here where it says symmetrize and this will create a mirrored duplicate copy of both of these bones each with their own custom properties once you have all four bones we can begin to go through each driver and then refactor our variables to Target the right custom property to do that I'm just going to go into the data path of our variable as you can see right here this contains the address of our properties so all we got to do is go to the correct property that we want to replace it with hover over the value and hit Ctrl shift C to copy the data path and then paste that into the data path field of our variable and that should allow us to easily refresh Factor all of our drivers to this bone and once we refactor all of our variables that's the hardest part of this tutorial over we've completely programmed our animated texture playback system there's just two more controls that I want to set up for my rig you don't have to do them but for me I want to do it so that way I have a procedural way to rotate my character's pupils I have this days people State here which is like the spiral and I want to be able to control it to allow both of the eyes to procedurally spin and be able to control that speed so what I'm going to do is I'm going to make two new custom properties called pupil rotate which will be a Boolean and pupil rotate speed which will be a float value from negative nine I'm going to be putting these custom properties in our transform bone since it's going to be the one using them we're also going to be adding a new limit rotation constraint which we'll use to drive the animation we'll set the owner space to local and for the influence we're going to set our pupil State Property to turn the constraint on and off for this constraint we are also wanting to Target the minimum and maximum numbers of the Y rotation which need to stay the same value to make this easy I'm just going to copy the minimum value as a driver and paste that into to the maximum value that way whatever the minimum value puts out the maximum value will copy it for the minimum value I'm going to copy the current frame again as a driver and paste that in and then we'll set it to be a scripted expression unfortunately we're going to have to do a little bit extra math because for whatever reason whenever you use a driver to control the rotational constraint the values are read as radians and not degrees which is very annoying so of course we're going to have to convert this which isn't hard which is good all we have to do is divide Delta by the conversion equation which is 180 divided by pi and then to bind this expression to stay within the 360 degree range we're going to have to do a modulus and since we're using radians we're going to have to do a modulus using the value 2 times pi we can test real quick to make sure that works and with that we should now have every single control that I can currently think of that we could possibly need with all that said and done I'm going to now take a minute to stylize our rig I'll be making a few custom bone shapes to help them Stand Out make them easier to use and make it look more polished overall you can skip this part if you want it has no bearing over how the rig actually works but if you're unfamiliar with some bone shapes and want to know how they work well here you go so a custom bone shape is basically just a 3D object that we call to represent a bone could be just about anything it could be a curve it can be an empty it can be a mesh typically I like to use meshes because they're simple to manage and make so when you're making a mesh bone shape the workspace for the bone is as such in the mesh's local space the origin point would be the base of the bone and a y value of one would be the very tip of the bone so it's often easier to make bone shapes from a top-down view for myself I made a few simple shapes some of them I added a text object that I converted to mesh and joined it with the object so it had a nice label for the ice State bones what I did was I made two different shapes I made this circle for the pupils and then this outline for the eye shapes so that way when they came together they created this eye shape this also made it much easier to select them so that way they would no longer visually overlapping each other as for the the UV base bone since it only serves as a purpose to store a locational value for the UV map modifiers and I can't transform it in any way what I decided to do was to make it into a label for the i-state drivers I made the custom bone a text mesh and then from here using the transforms of the custom bone values translated it to sit over our eye State bones which made it look a lot nicer okay so now we got the controls finalized they have their polish they work I'm now going to show you how to use the facial rig that we just created so not gonna lie selecting every eye State bone and fiddling with all these custom properties is not an intuitive design we would be stuck having to dive into each bone one at a time to create an expression and then having to keyframe all the variables and that would suck ass if we didn't have a better solution and this is where the pose asset Library comes into play blender comes natively with a built-in system where we can save pose data so that we can repeatedly reuse it in our animation this also includes saving custom properties which we are going to be taking full advantage of first we need to actually enable it believe it's off by default just done because it's super useful so to do that we're gonna go up here to edit and then into our preferences and then to add-ons where we're going to search for post library and then enable it and hit save preferences now we can begin to make pose assets for our first pose asset I'm wanting to make a default value pose so that way whenever we're animating our expression and we want a way to bring our Expressions back to their default values instead of going through all the custom property menus and just matching backspace over all the values we can just apply this one pose and do it that way so to do that we actually do need to go and mash backspace over all our values but that's just to ensure that all of them are actually at their default values and then what we're going to do afterwards is we're going to select all four I State bones as well as the Rotator bone hit I to bring up the keyframe menu and then go down to here where it says location rotation scale and custom properties if we go through our bones we can now see all of our custom properties are yellow which indicate that it's been keyframed and once we have all of our values keyframed to their default values what we're going to do is we're going to go over here into the 3D viewport into this little sidebar here and we're going to go into this tab here that says animation if you don't see this tab that means you don't have the pose Library add-on turned on which you should probably fix that okay what we're going to do now is we're going to click on this button here that says create asset and when we do that a little menu over here is going to pop up that will allow us to name our new asset which I'll be naming 0 underscore istate Dash default I always use zero underscore when I'm designating something as a rest bow so that way it's easier to find whenever I search for it after we click the button we should also now see a new image over here in the sidebar if you have a camera active in your scene it will try to make a studio preview screenshot of your scene and use that as a thumbnail for your new asset the way that I have this material set up the studio preview will never show anything useful so we actually have to make a render to get a good thumbnail I'll set up a camera real quick to take some actual thumbnails and save the render to a new folder called asset preview the thumbnails are going to share the exact same name as their asset so that way it's more cohesive I'll also be setting up a new camera to capture the pupils more closely for their thumbnails and I'll just swap between the cameras whenever I need a new thumbnail so just saving these into our folder doesn't actually change the thumbnail to manually set a thumbnail we actually have to go into the asset browser proper if you have an extra monitor I think it helps to open open up a new blender window and set it up over there on the new window that we created I'm going to hit shift F1 once or twice and that should bring up the asset browser the hotkey for the file browser and the asset browser are both shift F1 no idea how or why that works it's just like a 50 50 shut you get the right one when you hit it I don't know I'm just using hotkeys because it's a faster option than going up here to actually change it straight to the asset browser that way now that we're here in the asset browser I'm going to select our pose asset and I'm going to hit n to open up this right sidebar and from here I'm going to click on this folder button here and search for our custom thumbnail that we made in the asset preview folder now to test if our asset actually works what I'm going to do is move the current frame and then scramble the values of our custom properties randomly I'm going to unselect our bones by double tapping a and then I'm going to double click on our pose asset and it should apply the pose that we created if we had Auto keying enabled it would also automatically key our expressions and we can animate our faces this way it was also important that we didn't have any bones selected there otherwise they would have tried to apply that pose to that selected bone and not the whole expression also any value that we didn't key when we created the asset would not be affected now when we apply it this is good to know since we can use that information to make poses that only affect either the ice shapes or the pupils and then if we only wanted to apply it to one side or the other all we would have to do is Select that portion of the face click on the pose asset and apply it that way knowing how to do things this way we can quickly iterate on our system and dynamically make expressions and save them for later use now there is a problem that we will run into when we actually start to use the asset browser and that is that when it assigns and keys our Expressions into our timeline it won't key them in the correct interpolation it's going to use linear interpolation instead of constant what that means is if I key these two expressions a few keyframes apart blender will actually cycle through every texture until it gets to the final keyframe this is a problem for me because I want her to hold this expression until it hits this keyframe and I don't want to set the interpolation to constant every single time that I make a keyframe for a character's face it's going to get annoying really fast so what I'm going to do is I'm going to go into my preferences go into the animations Tab and set the default interpolation from bezier to constant and what this will do is it will force blender to key our facial expressions in the correct way this will also Force any keyframe that we add to also use constant interpolation this is fine for me because I always had it set to constant it always helps for blocking out animations getting timing of key poses down before smoothing everything out it's just set to bezier by default and you should know that all right let's talk about a few more things you should know about the system to know how to utilize it better so you know you can create Poe's asset you know by now you can click the create asset button here however let's say you made an asset and you realize that you made a mistake it doesn't key the texture correctly or you accidentally keep the wrong phone and now you need to change it well there isn't really an edit asset button it would be nice and intuitive if there was but unfortunately that's not the case so the way that you go about editing your asset pose after you make an oopsy doodle need to go fix it what you need to do is need to change your timeline to the dope sheet you can do that by hovering over it and hitting shift F12 or by doing it the normal way and from here what we're going to do is we're going to change the dope sheet to the action editor using this drop down in the action editor what we can do is we can go over here to this drop down open it up and you can see we have all these different actions here that exist within our blend file all the actions with a little stack of book symbol here next to their name is a pose Library asset so to edit them all we have to do is load them into the action editor and from here we can find our key pose in the timeline and then edit our properties until they have the correct expression and key them in properly so for instance in my days expression I made I forgot to add the procedural rotation animation so to fix that I just gotta go into the asset action find the keyframe where it's stored and I just gotta add the keyframe to the bone that does that so now when I'm working in a different action when I click on the days expression it should now load as it properly should finally let's talk about making animated Expressions I mean I spend all that time to program the system and I'm going to use the whole system here is my Approach for making and using an anime did text your asset I wanted to use this GIF of some pixelated fire that I found for my character's peoples just to show off some anger so to do that what I'm going to do is I'm going to throw this GIF into and I'm going to begin exporting out each frame one at a time since this is an animated sequence I kind of want to give it a special address so that way I can keep it separated from my static textures I don't know what the best way is to organize these so what I'm going to do is I'm going to place them around the 500 range and start to export them there in sequence once I export the sequence out I can go back into blender to set it up whenever you add a new texture to your sequence folders you'll have to refresh your image sequence nodes and to do that you'll need to enable the node Wrangler add-on with it enabled you can select your image sequence and just hit alt R and that will refresh the node then in our pupil bones we can type in the address of the first frame over animated sequence next we need to set the loop bounds for the sequence which is a total of 10 frames and that's basically it we can set the steps keyframe and then save it as an asset and it works the same as any normal asset now with everything said and done this system is finished we can freely add new expressions and use them whenever they come up and it's a system that controls well and the question is now is do we ever want to rebuild this system again and the answer to that at least for me is God no this took me close to an hour or more to make this setup and if you think I want to do that for every single character that I'm ever going to make then you are sorely mistaken I want to convert this eye system into something modular that I can recycle over and over again like excuses for why my next video isn't out so to make this system modular we're effectively going to have to strip it down to its most fundamental components and deleting everything else and then saving our results as its own blend file so we can draw from it later those components being the eye control bones that we made the image sequence nodes the pupil masking system and the UV nodes as well as the color mixing nodes that layer them all together first I'm going to isolate our control bones I'm going to select our Armature go into edit mode make sure all the bones available to this rig are unhidden and visible select hour control bones then hit Ctrl I to invert the selection and just delete everything else then one going to do is I'm going to go back to object mode and rename the rig object as well as the rig name to 2di controls now when I said we're isolating the control bones we also have to isolate them from the scene itself now what exactly does that mean remember this control bone here that controls the scale and rotation of the pupils well it contains a driver that is dependent on this file the current Frame data if we don't remove the reference to this scene what will happen is when we try to add this as an asset it won't work correctly I also don't want to delete the variable entirely so what I'm going to do instead is I'm going to make the variable empty by deleting the data path and thus removing any reference to this scene next I want to isolate our Shader nodes I'm just basically going to select everything that involves the left and right eye system and then I'm just going to hit Ctrl G to group them all together into a Shader node I'm going to rename this node to 2D face system then I'm just going to re-label it to sickly space system I mean I gotta take some credit right I'm going to edit our new 2D face node just like we did with the rig I'm going to go into every image sequence driver and delete the data path to the Delta variable one at a time then when I'm done with that I'm going to go through these image sequence notes and revert them back into an empty image texture by clicking these buttons here you might think this is bad because we can no longer see our drivers and that they're gone well they're actually saved inside the image nodes themselves if I hit new texture and then swap it back to empty image sequence we can see that our drivers are actually still there as for the UV map notes I'm just going to leave them as they are when I add this to a new character I'm going to be using the same nomenclature for their UVS anyway so basically it'll be expecting a specific UV named i.l and etc for them all to work now I've isolated our rig and our Shader setup I'm going to go about pruning everything else out deleting every other object out of my 3D viewport except for my custom bone objects then I'll go into the blender outliner and I'm going to go through the blend file deleting everything that isn't part of our final product to minimize the file size as much as possible in the outliner I'm going to right click on our 2D system and I'm going to click add false user this will basically prevent it from being erased whenever we save this since there's no material in our file that can use it I only got a couple more things that I need to do now I'm going to change the name of the current scene to iRig storage the reason why I'm doing that will become apparent when I show off how to incorporate this into another character and finally what I'm going to do is I'm going to Mark our eye control and our 2D face node as an asset so to incorporate this system into another blend file or character there are a few ways of doing that one way to do that is just append it into your file but the easier way is to actually add it as an asset Library so in a new file what you do is you go up and you edit preferences and then here to where it says file paths we're going to go to this menu here called asset libraries and what we're going to do is we're going to add a new asset Library by hitting the plus sign this will take us to the file browser and we're going to go and look for the location for our 2D file system that we saved when we add this directory and then save it to our preferences what we should be able to do now is open up the asset browser and then set our asset directory to that file directory and we should be able to access our system from any file that we want the way that I add this system to any character I want I first start off by adding the 2D face node to the character's material I'm going to do that by dragging the 2D I system into the material like this then I'm going to drag our 2D face rake into our scene as well now this has inadvertently done something up here in our scene drop down we can open it up and we can see that we have a brand new scene called iRig storage this was generated when we added our rig to the scene and we don't really need it so I'm just going to delete it and move on for the note to work we're going to have to make sure that our character has the appropriate UV Maps which I have made sure ahead of time then we can allocate our image sequences that we want to use all right so we have our 2D node set up as well as our control we can plays what we should now do is go about reconnecting our controls we're going to need to add the UV warp modifier back to our character so that way we have control of the pupils and then we're gonna have to go about re-establishing our drivers right now if we go into our face controller node and check the drivers are actually still referencing the rig from the rig storage scene even though it no longer exists so we're gonna have to redirect the variable's object data path to our character's rig I'm going to do that by clicking on this drop down here and changing the target object from 2D face controller to whatever the name of our current controller rig is which is for me character rig and then I'm going to change the target scene for our time variable to the current one we're gonna have to do this for every variable in all of our drivers but the good news is this process does go by really quickly this approach while not perfect is a hell of a lot better than rebuilding everything from scratch and it is really powerful when it comes down to it and looking back on my system I feel there's maybe even more I could have added like for instance a channel for mouth texture but as it stands right now I think this is a perfectly adequate and also incredibly versatile system that can be used for most any kinds of projects like this and that about does it for all the advice I can give on this system hopefully this video was helpful and taught you a good bit more about blender than you already did for my patreon supporters as of right now you should be able to download this 2D I system that I made in the video as well as play around with the demo scene that I made for a while back as for everyone else I hope that you liked the video and subscribe for more content if you have any questions be sure to leave them in the comments below and I'll try to get to them and respond within a reasonable time frame and with that I think that's all I have to say see ya
Info
Channel: TheSicklyWizard
Views: 34,467
Rating: undefined out of 5
Keywords: Blender 3d, 2d face, texture, animated texture, facial textures, image sequence, tutorial, uv face, face rig, texture rig, rigging, armature, uv editing, animation, facial animation, low poly, 2d, uv, face
Id: VZYm4mg1Eyo
Channel Id: undefined
Length: 54min 30sec (3270 seconds)
Published: Wed Apr 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.