Blender 2.8 - Applying Physics Simulations Baking & Animations for glTF exports

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi so i'm gonna show you a quick tutorial hopefully um that shows you the basics of a applying a cloth physics um procedural animation to an object and then exporting that animation baking it essentially so using an exporting process that bakes the cache and then you can export as a gltf ready for all sorts of fun applications so um this is your just kind of your generic blender at startup i'm going to hit g and then z to keep uh constraint on the z-axis and so this is the cube that i want to apply the cloth physics to it's going to kind of fall and hit the ground and then crumple um but i need a ground so i'm going to hit shift d and then return and then g z again and then i'm going to hit s for scale and constrain the x and the y oops sorry scale and then we'll do y now sorry um still kind of learning my renegotiating blender after teaching on with my first one all right so uh now what i need to do is apply the uh physics to my cube but maybe maybe first i actually want to give it um an interesting texture so that we can kind of see what's going on so i'm going to go into my materials tab and i'm going to say new texture and i'm going to name it cloth and i'm going to delete the this this default material from the cube and then i'm going to give it a node for the base color with an image texture and i can go into my shading tab and get my my um graph editor i can select this and hit x i can also uh do a shift a for add and then search for image texture here and then add the image texture node i want to collect connect the color out and to the base color and i'm going to open a file um what do i want oh how about this cadre 1984 poster open image and i can see it's kind of um wrapped around the cube but if i wanted uh to map that a little bit more closely i could go into my uv editing and i'm going to box select and figure out where i am i'm upside down here i think this is what i'm looking at so i'm going to hit r for rotate and then s for scale and then g actually different r again there we go so you need to grab it other way there we go there we go that looks pretty good um and then i can tab hit tab back into my object mode or i could go toggle between my edit and my object mode from this drop down menu all right i'm gonna i'm happy with that um i'm gonna go back into my layout view and i'll grab this window uh see my time slider grab it just give me a little bit more real estate down here um we're gonna be playing playing through the time slider and then i'm going to apply the physics so i'll need to do two things first i'm going to apply the cloth physics to my my cube and i can do that in a couple different places i can go into my modifiers and add a cloth uh physics here but this isn't where i get most of my options most of my options are going to be in my physics tab so go down into my physics tab here and i can see that i have my cloth turned on i can turn it on and off with that little x button or add the cloth physics here um i'm going to turn the quality up a little bit and then i'm also going to turn the mass up a little bit like three kilograms um you can play around with these like tension compressions here and bending we'll they'll all kind of make modifications to the way like cloth interacts so when i press play i see it just drops right down through the floor that's because i need to add a collider physics property to my floor so i'm going to select my floor click on collision i'm just gonna use defaults for now and now when i press play the box just sits there like a big done box and that is because i don't have any joints in my box uh so if you'll remember from my uv editing all of these spaces have no vertices so i'm going to go in and add some vertices i'm going to select my object press tab to go into edit mode i can also do that over here go to edit mode and then right click and subdivide i'm going to do that a couple times so that i have enough bendy vertices and not no no too many what let's be realistic rhonda i'm going to hit tab again go back to object mode and now i've got some crumpled behavior that's actually pretty crumply so i might go in and it looks more like water than cloth so what i'm going to do is go back into my my physics um tab here and make some adjustments so let's see here we'll say tension [Music] five compression five and bending point one and i'll drag back and reset yeah it's maybe worse i know there's some a little bit more going on there let's see if i increase the tension again and what happens i like don't know my physics properties so like i just guessed a lot of stuff probably like most of us see what else stiffness there we go compression shear bending oh you know why i need to turn on self collision so it's allowing itself to oh no it's got out here self collision so i want um it to i want the object to not be able to pass through itself so with that turned on we should be getting a little less of like a flat paper puddle um action happening here it starts uh calculating slower too because not only is it calculating the collisions with the the plane but it's now uh calculating its kind of like internal uh collisions vertices to vertices so that looks a little bit better um so now what i'm going to do is i press stop and let's see 250 frames that's fine if i wanted to do this really fast maybe i do one two three four five maybe i'll just calculate it out to 150 frames so i'm going to say end at 150 frames and go into my cache settings so this is like saving um all of the the frames down here we see where it's blue that's me that means it's been calculated it's going to save temporarily to a cache um and i'll bring it back anytime you make edits like it'll it'll like rewrite the cache if it loops so you have to start on the very first frame and then loop through to the very end um and that'll give you a full cache and after it does that loop through once it's it's kind of temporarily saved until you make another adjustment so let's go ahead and pause this and we're going to play we're going to save our file so save as i'm going to call this um where are my downloads that's great um rh fi cloth test one all right there we go so it's going to be using it's this kind of local path and in the library where it's saving all of our temporary files like all of our autosaves and all of the the kind of temporary files associated when you're editing in blender um you can tell it to save to the disk um that is you can get into trouble there because it will save it out every time you make an adjustment so you can end up with eight ton of cache files that are saved to you locally to your hard drive um i don't recommend doing that um unless you have an infinitely large computer and you're really worried about you know the cache like if you have like a big complicated animation and you really only want to do it once like the cache calculation once maybe that makes sense but for most of the time when you're like still editing all your preferences you you don't want to you want it to be temporary and you want to be able to write right over it okay so there we go so now you can see once these um once this kind of little purple line is down here those are frames that have been cached so it's now playing back much much more quickly uh okay so i've kind of uh started a part two and i forgot to do something that's really um important it's a feature of uh the export process in blender into new art city um and that is you might have noticed when you import things into new york city like the handles might be a little bit off so uh it becomes really tricky to like move things around let's see if i can yeah so like these cubes here let me move back a little bit here our x were exported together um or even here so when i roll over the center of this 3d scan you'll i see that the handles are kind of like off-center right and that is because the newer city the way that it activates an object is like by moving like when your cursor is over the center of an object but though the the way that the handles work is that they kind of roll off pretty quickly right so you're kind of constantly trying to chase like the handles to like like grab it and you have to like move your your kind of point of view so that the center of your screen is on top of the handles and it can be like a real pain um and the best way to to manage that is to have an origin that is like the center of the object so that's what i've done here with this this cube i've exported it's the origin of my object is the center in the center and then that way when i roll over it i don't have to worry about it i think that kind of happens by default in maya but in blender the world origin or like zero zero um where the the grid matches up is where the kind of like sender uh lies with the exporting gltl so i'm going to show you how to hopefully fix that so um back in blender this little orange dot represents the the origin for each object right so if i select my floor and that has a little orange dot and the gimbal handles for like all the transform tools are focused on the object's origin but we also have a world origin so like a global origin and the global origin is what these numbers are in relationship to right so the local origin if i switch from global to local um well it actually isn't because i haven't applied any transformation but blender allows you to do something like applying transformation so that i can actually change this origin to zero zero so that shows up zero zero zero locally but is uh still at the same position globally which is a little bit funny um it has to do with why we have this cursor um the workflow in blender is kind of changing a little bit so i don't think most people like end up doing those kind of like applied transformations anyway um i digress uh but what that translates to is that funny cursor asymmetry in um in new york city when we do our export so what we're going to do is like in my if you watch my path constraints tutorial in order to before we apply the constraints we set the object to zero zero zero so i'm gonna do the same thing here so zero zero and zero and then i'm gonna go into my side view here and i'm going to press n to get rid of my my um transform window and for tools or transform window and then i'm going to go into my side view so it's going to my viewport and right side and yeah that looks good like i'm happy with that position of the floor in relationship to my cube um so it will will fall and hit that floor and then i'm gonna um calculate out the cache again for the physics simulation so i'm going to do that and i'll probably yeah it's not too bad i might need to wait it out so um what we're doing again is calculating that temporary cache and then what i'm going to do is use that third party plugin to go ahead and bake that cache into keyframes so in in new york city that animation because like the cube moves the origin is going to stay in the same place but it will help us in that kind of like animation loop to like roll over the center viewport so that the center of the cursor is aligned with the center of the gimbal um which is just i know it can be tricky in new york city all right so i can see uh down here in my viewport window that i've got my little purple bar yay and sometimes it needs to go through twice before it kind of saves out the cache wonderful all right so now i've got the cache shaped out i can tell because the frames per second are kind of you know more or less real-time i'm going to pause this and then pull that back and we're going to um we're going to export that back we're going to export this now for that keyframed um cache but before i do that i'm going to say file save and then i'm going to file file save as and every time i do this i want to make sure every time i bake i want to make sure i'm saving to a new file so i call this test three bait that way i've just saved you know my my fit file with all the physics and the constraints settings and now i can do whatever i want and kind of overwrite those with keyframes and i i have something to refer back to so the first thing i want to do is make sure that my plugin is turned on so under edit and preferences add-ons go into new and make sure the import export new tech mvd format is checked then i'm going to go down my hamburger and say save preferences and now i can export this file export mdd and that's fine that looks good where's that downloads and now i'm going to import that file so that this is my keyframed cache file so it's basically like a keyframe version of this little blue line so say file import lightweight point cache mbd and there it is and there's all my keyframes so if i press play i see the same thing which is good and now it's still kind of you know calculating out the the physics is still calculating out so but i should be able to now that i have these keep this keyframe data imported just delete the cost simulation which is why you want to make sure that you've got your your data um why we do this kind of like uh baked version of the save right because now i if i'm not happy with it that that's that's all like i'd have to redo the simulation go back to my bake file but it's good that i have that okay so now i've got the the object with keyframes and now i can export it as a gltf so i'm gonna say export gltf and the uh i'm going to use the gltf embedded and i want to include my selected objects i'm going to make sure my y up is turned on geometry um modifiers at apply modifiers uvs normals vertex colors materials check check and then animation i want to include animation and i want to make sure i include my shape keys the shape keys are the those keys that came in as that dot mdd file and then i'm going to say that looks good export gltf it'll probably take a little bit of time it's a lot of data it's going to be a big file but once we've exported the shapes and import it as a gltf um we can kind of play around with some like face reduction so i'm gonna let that run and i'll be right back okay so my gltf uh just finished uh exporting so i'm gonna say file save go to file new this is in a new general and here's where i'm gonna um just test my gltf file so file import gltf and where was that downloads there we go you can see it's 60 megabytes right and so if you're trying to optimize i mean these have this cube had a ton of faces but like depending on um your application this is not you know a small file awesome all right so we've got our collapsed little um little qb friend it's at zero zero zero now let's see what it looks like when we import oh i messed up yeah that's all right um or maybe that's just this file so the minute general yeah so the the keyframes and it won't end at 150. uh i opened a new file and i forgot anyway long day so let's go back into new york city and let's see uh i'm gonna have a version of it's that had the asymmetrical handles that i didn't like um and then let's say upload okay so it's finished uploading i have a beautiful little preview of it i'm gonna say rh by cube and let's say preview it's a big file so it definitely needs some optimization all right so i've got my little crumple here beautiful and the handles are still a little funky so let's see there we go so it's fine when it's like you've got to catch it you've got to catch what is like raised so this is like just something to consider right like when you've got your animations the origins aren't moving with your with your animations so it's because it's dependent on the nash which might be something to consider for newark city so um 178 crew let's figure out how to use it so that it's not like viewport dependent and how like how do we like if something's animating like you've got to like go back and like chase chase it like that's i don't know anyway you can always like change the location of things like hand coding with the xyz but all right so that is the basics and um yeah um but for today i think that's that's probably good all right take care thanks
Info
Channel: R Holb
Views: 599
Rating: undefined out of 5
Keywords:
Id: DZKi8GecYpw
Channel Id: undefined
Length: 23min 8sec (1388 seconds)
Published: Mon Jul 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.