#RiggingInMaya | Part 18 | Squash & Stretch

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we are slowly getting closer to a complete rig and in its current state we could pass this onto an animator and they can begin to bring life to this creature however before we do there are a few more steps we need to take the first is optional what we're going to do is add in some extra functionality by making the character's limbs and torso more flexible with some squash and stretch the next step which is covered in the next video is to make sure everything is locked down and secure and this step is very important we will cover this later though really quick question for you now how would you like to help support the future of this channel and keep these videos free well there are a few options one would be to simply treat me to a coffee at my coffee page as a quick and easy thank you you could also grab something from the ant cgi store or one of my other online stores like cubebrush and gumroad this is where you will also find the course files that go with this course so you can download them and follow along however for as little as 99p a month you could join the ant cgi club there are a few ways you can join you could head over to my patreon or coffee pages or or alternatively simply hit that join button below this video in short the more support i get the more time i can dedicate to creating more high quality content just for you to get more information on how you can help follow the link on the screen or in the description below now that's out of the way let's get on with the video okay so first let's look at the torso if we pull the shoulder control which is the ik spine control you see that the torso stays in place which looks odd so ideally we want the spine to stretch so it moves with the control okay let's show the rig systems and we need to find the curve we used when setting up the ik spine now open the node editor and bring the curve in usually we hide the shape nodes but this time we need them this is the one we need so let's remove these instead and open this and now we need a new node so press tab and create a curve info node call it spine curve info next connect the curve's world space zero attribute to the curve info node's input curve attribute so what this node does is tell us a lot of information about the curve which you can see in the attribute editor the one we are interested in is the arc length which tells us the length of the curve we can use this to check when the spine is stretching and then use that information to also stretch the joints so they follow so first we need a new multiply divide node let's open this and rename it to spine scale factor connect arc length to input 1x so here we have the curve length we're going to use this node to compare its stretched length against its base length to do this copy the value down to input 2x okay let's look at it in the attribute editor change the operation to divide this will divide the first value by the second and give us a result the result will be 1 when the values are equal and then this will adjust as the curve stretches so what we can do then is use that value to then adjust the scale of the joints because the joint's default value is one okay let's make some room now create a blend colors node this node is traditionally used with shaders meaning you can blend between the colour one values and the colour two values here we can use it to blend between two values which will give the animator the ability to turn the stretchiness on and off call it spine stretch blend and copy it so this one is going to work in a similar way but we will use this to automatically turn off the stretchiness when using the fk controls or alternatively enable it when switching to ik if the stretchiness remains on when using fk it will still be referencing the ik spine so we need to disable it let's add ik to the name here so we can differentiate between them okay now set all the attributes on each to one because when the stretchiness is disabled we need the scale values to be set to 1 again which is the default value on the scale attributes so we have those set up next let's connect these to some of the key attributes we added we added these attributes earlier so we could change the spine so it only stretches only squashes or does both the stretchiness attribute here will be what we use to control the blend colours node here so bring in the cog control and simply connect stretchiness to the spine stretch blend node's blender attribute we now need a condition node so let's open that and rename this to spine stretch condition let's move some of these now connect the scale factor's output x attribute to the condition node's first term attribute this is so we can use a condition node to check when the curve is stretching so as we have before in this series we can compare the first and second terms here and determine what needs doing now connect output r from the stretch blend node to the color if true r attribute so when the condition is true it will output the stretch value we can use the operation attribute to adjust how the torso scales but what we need are the not equal greater or equal and less or equal options which are equivalent to numbers 1 3 and 5 in the menu we need these attributes on the cog control to adjust the condition node's operation attributes the problem is if we connect them directly the stretch type attributes options will output 0 1 and 2 not 1 3 and 5. so these won't tie up to the correct operations so what we need to do is insert some kind of offset which will change those values and push them onto the correct ones create a plus minus average node and open it rename it to spine stretch control pma connect stretch type to input 1d0 and input 1d1 and also input 1d2 so what this will do is add up all these values so it will give us an offset if we change stretch type to stretch you see these values have now changed to one so the output would be three we need the first option to be just one though not zero so let's break the connection on input 1d0 which means this will always be set to 1. so when the attribute is set to both this will output 1 now not 0. okay let's connect this to the condition node so we can check it and you can see it in action now connect output 1d to the condition node's operation attribute so you see the operation is now set to greater or equal meaning the spine will only stretch when the curve is longer than it should be if we set stretch type to both the output is now 1 from the plus minus average node so the operation is set to not equal meaning the spine will stretch and squash finally let's swap this to squash and the operation is now less or equal meaning the spine will only squash when the curve is shorter than it should be okay now let's connect the condition node to our other blend colours node so we can check if we are working in ik or fk so take out colour r and connect it to colour 2r and we also need to control this with the ik fk switch attribute 2. so connect that from the coke control to the blender attribute ok anything else ah is we need the scale factor value to also be connected to the stretch blend node otherwise we won't know what values we are using connect it to colour1r so this will blend between the amount the joints need to scale here or a static value of 1 if the stretchiness is disabled ok let's move the control up a little so we can see the spine update now we need to connect this network to the joints bring the main ik joints into the node editor so these are spine one two and three we don't connect the pelvis or the neck because this will then affect the pelvis and head whereas we want this restricted to just the spine now simply connect output r to each joint scale y attribute we use scale y because that is the axis which is pointing down each joint okay that's done let's check the attributes so we need stretchiness to be enabled and stretch type to be both okay there the spine snapped into position i can move the shoulder control now and the torso stretches to move with it we can also adjust the stretchiness to turn it off if needed let's check the attributes okay they aren't working yet maybe we missed something oh yes on the condition node we need the second term to be set to one if the first term is above one the spine is stretching if it's below one then it's squashing so with it being set to zero it wasn't triggering correctly okay that's only squashing now now it's working both ways so both squashing and stretching okay good now even though this is affecting the ik joints we also want the main bind joints to scale too this is so the geometry is distributed more evenly so bring in the main spine joints so just one two and three let's move this so you can see it as it updates and again connect output r to each joint scale y attribute so you see the geometry is much smoother here now there we go much better a stretching spine and we can blend to fk and the spine moves back and disables the stretchiness too what we have now is a torso which stretches which is good but it doesn't maintain its volume what i mean by this is it doesn't get thinner the more it stretches or thicker when it squashes let's add that functionality in next and it's pretty straightforward now we have the main stretching network set up all we need is another multiply divide node call this spine volume multi this time we need the operation to be set to power what this will do is take the input 1x value and then multiply it by itself the number of times in input 2x so if input 1x was 2 and input 2x was 2 it would be 2 times two set input two x to minus one because we want the scale value to get smaller the more the torso stretches now connect out color r from the condition node to input 1x remember this is the main scale value being output plus it's being controlled by the condition node let's reuse the ik blend colors node now so we can again control the influence depending on whether the animator is using the ik or fk spine connect output x from the volume multiply divide node to color 2g and now we connect this to the other scale attributes on the joints actually let's use the connection editor so load the blend colours node into the left side and the bind joints into the right we only need these because they influence the model so we need output g and this time connect to scale x and scale y on each joint you can see they are now connected up here now as we pull the shoulder control the torso changes shape as it stretches and when it squashes it's also ignored when switching to fk so the spine is done let's move on and set up the arm and this is very similar to the spine we just have to take a slightly different approach with the spine we were able to check when it was stretching by using the curve but obviously we can't do that with the arm so we need to find a different way of getting its length and then finding out when it should be stretching let's build some of the basic nodes first so jump back into the node editor first we need a new multiply divide node and this will act as a scale factor node so rename it to arm left scale factor and open it let's have a quick look back at the spines network we used the curve info node to give us the length of the curve but we could also use this to check when it was stretching and convert that into a usable value 2 with the scale factor node here let's go back and change the operation to divide so we need to find the arm's current length but we already have everything we need to find this let's find the arm joints if i select the lower arm joint here we see the distance this is from the upper arm joint over here in the attribute editor this is because we corrected the orientations so the y axis is pointing down to the lower arm so make a note of this value now select the hand joint and again we can see the distance this is from the lower arm joint here so remember this value too all we need to do is add those together like this and we get the arm length let's bring back the node editor and add that into the scale factor node in both input 1x and input 2x so that's stage 1. now we need to check for when the arm is stretching so when the control here is moving away from the arm what we can do is get the distance from the arm ik control to the root control and when that goes above the arm's length we know it should be stretching let's bring the root control into the node editor now we can't use the ik control directly because it will cause some evaluation issues but we can use a dummy node instead let's just use a locator we can duplicate this one the arm left ik swap position 1 we created earlier in the workshop and simply match it to the hand joint's position and orientation let's rename this to endpos because it will indicate the arm's end position so we have our two nodes now that will mark the start and the end of the arm create a new node now this time a distance between node this will do exactly as the name suggests and tell us the distance between two points call this arm left stretch distance connect world matrix 0 from the root control to in matrix 1 and world matrix 0 from the end position locator to in matrix 2. the distance attribute here will output the distance between these two and keep it updated so we will see when the arm should be stretching connect that to input 1x on the scale factor multiply divide node so here we have the distance value now if i move the arm control away you see it's increased okay undo that so this is set up and will output a value of 1 when both values are equal now we need the two blend color nodes let's just duplicate the ones we created for the spine and rename them to arm left instead so the rest of the setup is exactly the same as the spine let's connect the main attributes to the blender attributes next bring the arm ik control in and connect stretchiness to the stretch blend node's blender attribute now connect ik fk switch to the stretch ik blend node's blender attribute so there we have our two main controls let's make this a bit bigger we now need the main scale amount so connect output x from the scale factor node to color 1 r on the stretch blend node so that will blend between the scale value here and one let's work on those extra stretch type attributes now so we can control whether we want the arm to stretch squash or do both again let's just copy the nodes we created for the spine to speed things up we need the plus minus average node and the condition node here we go and rename them just as before connect stretch type to input 1d1 and input 1d2 remember to leave input 1d0 set to 1. let's move this over here now connect output 1d to the condition node's operation attribute this will control the operation changing it for us okay now we need the scale adding to the condition node so the scale factor's output x value goes into first term and then we want the stretch blends output r attribute to go into color if true r so the joints will stretch when the condition node tells them to now we feed the results of this through the stretch ik blend node to again check if we are working in ik or fk before it passes this to the joints so connect out color r to color 2r now we connect this to the joints so let's find the arm ik joints we just need the upper and lower arm joints and now connect output r to each joint scale y attribute let's test that the arm stretches if we set stretch type to both it squashes and stretches and if we set it to squash it doesn't stretch but it does squash stretchiness works and so does the ik fk blending okay good so now we need to include the bind joints too so the scale affects the geometry so let's find those and bring them in and again connect output r to each joint scale y attribute we could use the connection editor for a change okay there we go the arm can now move and stretch okay so just like with the torso let's also add in some volume preservation and this is exactly the same as we did with the spine bring back the node editor if we look at the spine we have the volume multiply divide node here so let's just copy that and open it and move all these over and rename it because we copied it this node is already set up for us so all we need to do is add the connections connect out color r from the stretch condition node to the volume nodes input 1x attribute here we go and output x goes to color 2g let's open the connection editor so we can connect this to the joins so output g here and load the buying joints into the right side and connect output g to scale x and z on each now the arm gets thinner the longer it is again we have some weights we need to adjust here but we can come back to those later that's the torso and arm done with the leg you can take the same approach as you did with the arm just use the value in each joints translate y attribute to get the initial leg length but make sure you add in that extra joint now i'm not going to go through the process of building that all again because like i said it's very similar to the arm so what i'm going to do now is i will update that and i will be back in a second okay all the limbs are now set up with full squash and stretch abilities the spine is working too there are a few things i need to point out before we move on if you open the node editor on this file you will see that i've added these extra tabs so you can see each section's network and are able to pick through it let's look at the arm so with this make sure you also connect the twist joints too so they scale as the arm stretches with the upper arm joints don't add volume preservation into these or it will look too thin you can however add it into the twist joints with the legs also include the twist joints and also remember to connect the driver joints to all the legs won't stretch correctly again feel free to look at this file and these tabs if you are at all unsure okay so that's squash and stretch covered we have one more video to go now before this rig can be passed to an animator so in the next section we will look at making the whole rig scalable and also locking it down so it can't be broken okay that's another video over thanks for watching right to the end and make sure you also check out some of the other free videos and courses that i have available you can find links to all these on the screen now and in the description below remember to help support future content and keep these videos free visit the ant cgi store or join the ant cgi club alternatively if you would just like to show your appreciation for these videos why not treat me to a coffee at my coffee page again the link is on the screen now and in the description below thanks again for watching this is ant cgi signing off and i will see you on the next one you
Info
Channel: antCGi
Views: 507
Rating: undefined out of 5
Keywords: rigging, maya, autodesk, maya3d, rigging in maya, utility nodes, rig, node editor, nodes, Build Controls, Spine, Head, Pelvis, Waist, Abdomen, Sternum, Shoulders, gamedev, game art, game development, game rig, 2022, maya 2022, squash, stretch, volume, preservation, volume preservations, spine, arm, leg, multiply divide, condition, plus minus average
Id: dXJzgrIKs2Q
Channel Id: undefined
Length: 29min 27sec (1767 seconds)
Published: Thu Dec 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.