Wednesday 29 November 2017

Everything You NEED to Know About Fluid Simulation! - Blender Tutorial

Everything You NEED to Know About Fluid Simulation! - Blender Tutorial  .today I'  going to be teaching youeverything you need to know about theblender fluid simulation system so openup blender and we' ll open this up slightlyso we can see all the tabs on the topincluding this physics one. Now we' regoing to get rid of this lampwe don' t need it for the time being soright click on it and press X to delete.At any point in the future if you' re notsure what I'  clickingjust look here in the bottom left andthe screen-cast keys will show you whatI'  pressing. Now select this cube presss to scale and then press eight to scaleit up eight times. Now it' s taking up thewhole of this grid which is which is ourfloor plane and a good size. Now press Gand Z to move it up and press eightagain to move it up eight times. Nowthis big cube is sitting on top ofthe ground planethe camera is sort of inside it nowwhich is a bit of a problem so we' re goingto press 0 on the number pad, press shiftF, and now you can move your mouse aroundto move the camera and you can pressWASD to physically move the cameraand now you can see I'  pressing s downto move it back and we' re now outside of thecube and we have a good view of it.Once you' re ready you can left-click andthat finalizes how you moved the camera.So this is going to be the cube thatholds our fluid i'  also going to add anobject that will create fluid and add itinto our scene so press shift-A to add aicosphere and this is going to makewater so let' s scale this up two times bypressing S and 2 and go to your sideview with three on the number pad andmake everything orthographic withfive. basically this makes things flat. Nowpress G to grab and move it up here.We' re going to scale it down a bit -it didn' t need to be two times bigger sothis sort of size is good. I'  going to moveit somewhere over here nowthis is going to make our water but also we' regoing to have a sink that will takewater awaywe' re going to make this by pressingshift-A, adding a cube now press G andZ and 1 to move this cube up oneand now it' s also sitting on top of ourground plane now we' re going to scale itbut only in the x-axis so we do that bypressing s to scale than X for thex-axis and we want to scale it eighttimes so it takes up the whole width ofthe big box. Now that' s ready we' re goingto grab it in the y-axis by pressing G andY and then I'  going to hold control so itsnaps into positionI'  gonna put it right in the corner here of this big box. You could have alsodone that by pressing G Y and- 7 because we' ve moved at seven inthe negative y-direction.

To introduceyou to all aspects of the fluidsimulation i'  also going to add anothercube with shift-A to make a mesh whichis a cube. Scale it twice and this timego to your front view by pressing 1and grab it so that it somewhere up hereand now it isn' t going to be like a tapit' s going to be a cube of water thatfalls into the rest of our scene. We' regoing to add one more object which isanother sphere this time a UV sphere sopress shift-A, mesh, UV sphere. This timescale it up three timesgo to your side view by pressing 3grab it so it sits on the floor, that' stowards the right so this is towards theback of our cube. So we' re going to startoff by selecting this big cube which isgoing to be our domain and what thatmeans is it' s going to contain ourphysics simulation because the wholefluid simulation has to happen withinthis domain so the fluid can' t leave itand everything you want to simulate hasto be within these bounds so make sureit' s selected by right-clicking on thisbig cube go to the physics tab on theright, click fluid and under type selectdomain.The most important setting here is the speed. That just speeds up or slows down yoursimulation. Select the icosphere byright clicking it, select fluid and makeit inflow select this sink that wemade to get rid of fluid, click fluid andoutflow. Select this other cube clickfluid make the type fluid and finallyselect the UV sphere click fluid andmake the type obstacle. Now this isalmost ready to simulate we can presscommand-S or ctrl-S to save ourprogress in case this crashes when wetry to simulate. Now select your bigcube, click bake to see what happens so these orange objects that it' s createdare where the fluid is.Even though this is taking a long time you can left-click on your timeline hereto scrub through and see what happens so you can see that after this point it hasn't simulated yet but before thatyou can get a vague idea of what' s going on so you can see this the ionospheric giving off fluid, it' s creating water,which is just dripping down and you cansee that the cube (so this thing) is water:it' s not making any more but it just dropsdown and splashes and you can see thatit' s bouncing off this UV sphere. You cansee that when it touches the other thisoblong cube you can see that the waterjust disappears and so everything isbehaving like we want. There' s afew things we can tweak to get thislooking a bit better this cube isn' tvery exciting so I'  going to make it a bitbigger to give it more water.

There' s one problem here which is thatwe can' t see where the domain is anymorebecause it' s now become the fluid object sothere' s a way to get around that. We' regoing to exit the simulation and justsave our progressthis is the domain and we' re going tojust change the name, so we don' tlose track of it because once yousimulate (so this used to be the domainbut you can see that once you simulateit becomes the fluid) so that' s why wechanged the name to make it lessconfusing but the problem with this isthat we no longer can see the bounds ofour simulation so if you move thingsaround we' re not sure if they' re stillwithin the bounds or not and we' re goingto get around that with quite simplesolution. Just make sure the domain isselected which is going to be the fluidobject and in this case it' s this. Now press shift-D to duplicate it but goover to the fluid tab and get rid of thefluid setting by clicking on this crossthat you can see. Now we still have the old domain which is called domain and we have this copy of it which isn' stimulating called a domain.001and this will show uswhere the bounds of the domain are nowif we press 1we can see that even even though we made this cube bigger it' s still within the bound so that' s perfect.The other problem was that this sphere was giving off fluid but it wasn' t very exciting it' s just dribbling down and didn' t look very nice so we' re going to give it an initial velocity and the direction wewant it to go in is in this direction because we wanted to hit the big sphere.The way we figure out which axisthat is is this by looking here and youcan see that if we wanted to go in thedirection of the green arrow and downhere this green arrow is the y-axis sowe' re going to give it a positive Yvalue here let' s try two, and we' ll run avery quick simulation to see if two isenough power press command s to savebefore I bake and i'  going to waitbriefly to see if I' ve given it enoughpower.

So you can get a preview of whatthe simulation going to look like byscrubbing down here on the timeline andyou can see that it' s overshot a littlebit so i'  going to press escape tocancel the simulation i' ll select theicosphere again and i' ll reduce thisnumber to about 1.2 so let' s select thedomain again, save our progress, and bake.You can see it' s coming along nicelybehaving like we want it to this ishitting exactly what you want on thesphere.What we' re going to work on now are thematerials so let' s go to cycles renderand we' re going to make sure first ofall that nothing else is shown apartfrom the fluid so select this cubeobject go to the materials tab give it a newmaterial call it transparent and make ittransparent under the surface here tothe surface type and make the color purewhite by dragging this up. You' ll want tomake sure that everything here is onenow we' re going to apply the samematerial to these others select the icospheremake it transparent select thismake it transparent select this and alsomake that transparent. Now there is anadd-on that lets you apply materials in bulkto any number of objects you want, but ittakes a while to set up because we onlyhad a few objects we' re not going to useit today. So now select your first domainand this is the domain with no numbersafterwards. This already has a materialbecause it started off as a default cubeand we' re going to call this fluid it' sgoing to be water basically. Now let' spress shif-Z to see roughly what thislooks like and there' s not enoughlighting in the scene to let us see whatit really looks like we' re going toincrease the level of light by going tothe World tab, press use nodes, make thiscolor pure white and also add a sunlampwith shift-A, lamp, sun, and just go toyour camera view, press R and move yourcursor down and it' ll angle the sun awayfrom the camera. With shift-Z you can seewhat that looks like it' s a bit toobright so I' ll make this the strength ofthe world ambient lighting 0.5 that' s agood basis to start with ourmaterial so we' re going to add a floorby pressing shift-A, mesh, plane, we' re going toscale this up maybe 32 times to make it muchbigger than thefluid so if we press shift-Z torender this it looks quite boringeverything' s just white so I'  going toadd an HDR panorama in the background tomake it look better. Before I do that I' going to head over to the render tab andclick border and this make sure that wedon' t waste the time renderingeverything outside of our camera view. Sogo to the world tab and under colorselect environment texturenow if it' s gone pink that' s perfectlyOK. Click open here and navigate to afolder where you saved some HDR panoramasI' ll link to some free sources downin the description but the one I'  goingto use is called the HDRI Haven Teaserpack and it' s a really great set ofpanoramas and link to that as well.

 I' going to load this one so let' s add afew things now for realism.Firstly there' s a weird square on thefloor hands is where this cube intersectswith the floor so I'  going to grab thisin the Z axis 0.001 and that' ssolved that because they' re just notintersecting now and i'  going to movethis up as well, 0.001 so now there areno weird intersections with the polygons onthe floor i'  also going to add somedepth of field to make this look morelifelike so i'  going to go back tosolid mode and press shift-A to add anempty which is plain axes and we' regonna press g for grab to move this andthis is going to be our focus point forour camera so that' s a good focus pointI think go back to your camera with zeroon the number pad and then select thecamera now go to the camera tab, underdepth of field set the focus to emptyand we can see what this looks like now.Press shif-Z to render. At the momentnothing is happening because we haven' tblurred it at all so if we set this to 0.1you should see it starts to blur. We' regoing to need a bigger blurring settingbecause our scene is so big sorelatively the blur needs to be bigger so let' stry oneyeah that' s giving us really nice reallystrong Depth of Field effect. May be toostrong. So let' s make it 0.4 and that' sthat' s looking decent. I like a reallystrong depth of field effect so we' regoing to save our progress to make surenothing is lost and will finally startplaying with our material for the waterso the basis of this material is goingto be a glass shader with somevolumetric absorption to give it alovely blue look on the inside so selectthe domain and this is the fluidmaterial that we created earlier andclick use nodes on the surface and makethis glass. Now make sure the roughnessis 0 (for me it was like that by default)Now press shift-Z and you can see that thefluid is clearit' s not actually blue, itlooks a bit like it over here but that' sjust a reflection from the HDR. We' regonna add the blue tint to it with avolume and we' re going to do that byclicking here and volume absorption andmaking this a lovely light blue colorlet' s see what that looks like.Yeah it' s giving it a blue tint let' smake this less strong, 0.5, and also let' smake the surface of water smoothyeah so this is going to look verydecent the biggest problem at the momentis that it' s a really low resolution soit looks really clumpy and I'  going tofix that and come back in a few minutesonce it' s simulated a higher resolutionSo I raised the fluid simulationresolution to 80 and another thing I' ll doto help it look better in the viewport ischange this viewport display to final andnow it shows it as a resolution of 80instead of this preview resolution.Again just save and press shift-Z to seewhat it looks like now.Ok the boundaries are looking muchsmaller so it' s not looking as blocky as itwas before. We' re gonna do something to fix these black edges that you mighthave noticed around some of thesesharper corners.

 So with the domainselected go to this data tab and click Auto-smoothand that should help your fluid lookmuch smoother so some of these black boundaries have gone and also the scene isstill quite dark so I'  going to raisethis strength of the HDR panorama. Let' s try 2that' s looking nicer yeah. Let' s givethis ball a more interesting materialso I' ve selected the sphere which is theobstacle that the water is bouncing offand let' s give it a material, call it Sphereand why not make it glow. Let' s see whatthat looks likeso if we give it an emission as the surface.Hmm that looks nice.What about if we increase the strength.No, one is good. Two, a strength of two seems okay.And let' s play around with the color to seeif we can make it look more interesting.Hmm that' s a lovely color. Let' s make it thissort of pinky purple color.Awesome, so this scene is brighter now soi'  gonna change the density of thevolume back to 1, because it' s notgoing to make the fluid lookdark anymore. So increasing this will justmake it look more blue and I think that looks nicer.We' re also going to add some motion blurto the fluid which is a new feature incycles we can do is natively now withouthaving to hack it.So we' re gonna open up a new window bydragging that window down here, clicknode editor, and click on this which isthe sequence editor and click use nodes.Now you can see what this scene looks like and at themoment it' s quite simple it' s rendering andits outputing that so we' re going to adda motion blur between those two steps. Goto the layers tab click passes and tickvector. You' ll see there' s a speed littlenode here that it' s made for us and that' swhat we' re going to use. So press shift-Ato add a filter, this is going to be vector blur you can just slot it inNow, plug Z into the Z, and plugspeed into the speed I should give you areally quick way to add motion blur to yourscene. Because this is a new feature forcycle it' s a bit temperamental andactually it doesn' t work with this autosmooth on so we' re going to have to untickit and now render if we want to see themotion blur effective in our render. Soit' s a bit of a trade-off you have todecide whether you want the motion bluror you want to get rid of the blackedges and depending on what you like one or the other might be worthwhile. SoI' ve set the blur too high we' re gonna changethat back to one.

Now, I' ll make it really low. 0.1, 0.05 and now you have a blur where the fluid is and I think this looks really good soI'  going to keep the motion blur even though i'  going to have to un tick Auto Smooth so i'  going to introduce someof these black edges back but i willhave this motion blur, which i think is more worth while.Now you can see that once it' s been rendering for a while you start getting these little fire flies so even though it has 20 samples which is a reasonable number of samples, it has these fireflies. So I' m going to get rid of that by, under sampling, changing these to two.And this stop very bright portion of light, and it's going to make it much smoother so you can see it' s only got ten samples now but there are no specs.OK so this looks really good if I was gonna render this as a simulation all  I would do now is increase the resolution to something like 200 or 300 that will take maybe overnight to simulate and then i will render that, which will take over night again so i'  going to set that off to do that now i' ll see you in two days. When you do go to render it just set the out putto render wherever you want to. I' ll use a folder called render. I'  going to render as jpeg to save me some space and I'  gonna tick this which really helps reduce the level of noise you have in the final image. Also I'  going to increase this to a hundred percent so it' s full HD. Thanks for watching I really hope you found this useful there' s a new Moby Motion video every Saturday so click here to subscribe ifyou don' t miss those and support me on patreon if you want to help me make morevideos. If you donate before ChristmasI' ve got a special limited-time offer where you' ll get a custom a tutorial on atopic of your choice, you' ll get one-on-one help whenever you' re stuck onyour blender project, you' ll get loads of my blend files to my most popular videos,and you' ll get early access to mytutorials as soon as they' re posted onyoutube so check that out up here andi' ll see you next time

No comments:

Post a Comment