Bake PERFECT Displacement Maps (with blender)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and when I say perfect I mean perfect hey guys welcome back to another default cube cg matter tutorial and in this one I'm gonna be showing you how to bake perfect displacement Maps because it seems like nobody knows how to do it correctly they're missing either the openexr thing the orthographic camera basically there's a lot of things to juggle around and that's why nobody can bake displacement maps and blenders very guilty of when you go to cycles and you go to the bay cop shion's which is where you can bake all sorts of different maps you're gonna notice there is no option for bump and there's no option for height or displacement which are all essentially the same thing meaning you're kind of thrown into the wild you need to figure it out yourself so let me show you how to do it so we're gonna just switch back to easy so what is the concept what is it that we're trying to do well imagine if you will imagine you have some geometry in this case I've made this hard surface thing it's some of the 3 ish thousand faces meaning that it's too much geometry for this kind of thing right especially if we want to make 10 duplicates of this then we're getting pretty close to a million faces just for you know some pretty small details that maybe we want to put all over a corridor meaning we want to convert this geometric data into texture data namely a bump map height map or displacement map and again blender has no way for you to do that so let me show you the best the perfect and I'm gonna show you the way to do it that isn't messing missing any of the steps this recording is a disaster so you can see I've already made this example a displacement map this is what we're gonna try to achieve and you can see that I've taken the camera put it above in orthographic mode and then done a bunch of stuff to extract height information so that means the first step is our camera view needs to be bird's eye view needs to be above how do we do that well I'm gonna click n which gives us the location and rotation and scale the camera assuming you have your camera selected we can just zero this out so zero out location and rotation and then bring it up on the z-axis so it's kind of above it and this is what it looks like in 3d it's just facing directly down and make sure right now you're gonna hopefully notice that we're kind of viewing this via a perspective one so there's a bit of distortion in some sense we don't want this we want to look at it kind of like a blueprint where all lines or Thag or orthogonal basically what I'm saying is take your camera set it to orthographic okay and then we can actually zoom in so it's taking up our frame and this is how you set up your camera if you're using perspective you're gonna get the wrong displacement map and when you use it on a different object is gonna be some distortion because of that perspective fine next thing is that we don't necessarily need this like 1920 by 1080 you know frame here right we just want to capture this usually use a square texture for these kinds of things so in the output tab let's set this to again the higher the square resolution the more detail you're gonna have in your map so I recommend at least 2 K so that's 2048 by 2048 and then you might just need a zoom in just a bit maybe zoom out a little okay cool so now we have our set up how do we extract height information cuz again cycles doesn't let us do this so if we go to the render tab right now we're using evie we're just basically seeing some diffuse or maybe principle be SDF stuff right it's reacting to a lighting which is not necessarily what we want so in the shading workspace what you're gonna do select your object create a new material we can call this anything anything under the Sun I'm gonna call it whatever I whatever I want there we go we do not need this principle be SDF let's look at this via rendered mode what we want is to extract height information again we want to know at each point on our surface on our geometry how elevated is it where this is zero and as you go up the elevation goes up right well to do this what we're going to do is we're going to add in a geometry node and look at the position which is a vector quantity meaning it has the position in Xyz three-dimensional but we only want the Z you know how elevated it is vertically and does Z sound so at a separate XYZ we don't care about X we don't care about why we care about Z and by the way you can set same thing up where instead of this facing up and the cameras above that you could do it like this in which case you do x-axis right just depends on your orientation but this is probably the easiest way to do it and you can see that already we have something that makes a lot of sense we have a gradient that as it ascends vertically it becomes wider and wider and brighter and brighter which is saying our elevation is going up and it makes it's more obvious when we look at it via the side the side view however you could pretty much render this out after changing a couple settings however this is not optimal because what we're doing right now is we're starting at zero maybe going up to 0.5 and that's it right we want to make our texture go from 0 to 1 meaning that the highest elevation you can have is the very top of the surface right now it's kind of floating above here so we're kind of losing a bit of detail that we could get back so let's fix that range is the way we'd say that to do that we're going to add in a math node set this to multiply and you can see that right now we're multiplying by 1 which means we change nothing but as we increase this you see that our gradient kind of goes from you know instead of zero to like somewhere above that one becomes the top of the model right so you can see as we increase this it's doing what we want but we don't know exactly what value it is that we need a stop at so to do that or to make make a way for you to check this you're going to add another math node such a greater than one and right now this whole thing is black indicating that at no point is our elevation greater than one so what we want to do is just increase this in multiplication this scaling value that we made keep increasing it until eventually there we go eventually you see that some white pops up at the top meaning that now we've kind of started clipping there's areas of this model that have an elevation greater than one which is not what we want so I'm just going to find the value exactly where the cutoff is and basically you want to find the biggest value where everything is blacks are just there and then delete this greater than node we no longer need it okay so now we should have a perfect gradient that starts a zero and one should be very very slightly above but it's a pretty good a tight range which is what we want okay cool so essentially what we've just done is we've kind of painted our a model with what's called a height map and of course we need to extract this but we have height or elevation information on our model where as zeros the bottom one is very very close to the top so now the question is how are we supposed to render this because there's a lot of ways to mess this up first thing you need to do is in V render tab let's go to their camera view let's go to layout as well just so we can see what we're doing first of all go to the render tab and I want you to go to color management and do not forget this don't leave it on filmic change it to standard and you can see already this very very drastically changes the look so filmic standard what standard does is it basically says where it's 1 it's going to be white which is what we want filmic is useful but part of what filmic does is 1 is just this gray and then as you go towards infinity gets brighter and brighter and brighter never actually reaching white we don't want this set it to standard again boom standard next let's say that we render this you're gonna notice that the background is grey right where really we want the background to be black because it has an elevation of 0 almost as if that almost as if this model is like sitting on a plane which you could either like change the background or for this model apply the same material which will make it black as it has an elevation of 0 already sorty on the XY plane but assume you didn't do that to fix this without adding that point what you do is in render tam go to film enable transparent render now technically this made our background transparent but if we get rid of the Alpha Channel the transparency it will by default set to 0 so effectively we fixed it ok cool and now for the biggest mistake that sound a lot of people make do not buy displacement Maps or bump maps or whatever do not purchase them if they make this mistake in the output tab we do not want to render this as a PNG or a JPEG or almost anything in here you need lint something that has linear space meaning that something that goes from zero to one like this height gradient we've made stays like that when we render almost all of these file formats PNG JPEG do some kind of gamma correction meaning that it's very useful for making stuff look good and most people can't notice it but it adds this curvature that we don't want as stuff doesn't stay linear right meaning and in here's why it's important if you render with one of these bad file formats and then you use this displacement map things will not ascend vertically there will be some curvature meaning you've actually changed the geometry that you want to be deforming into in the first place you need something with linear space some I think tiff has this but what I know for sure has this as openexr so I'd recommend using openexr you can maybe use tiff look into it make sure it has a windier space but openexr definitely has this do not use PNG or JPEG I don't know how many times that can stress this so openexr is good we don't necessarily need the Alpha Channel again we want our background to be black right there's nothing necessarily wrong with keeping the Alpha Channel maybe it's even useful information but I'm just going to keep the RGB data and the second reason that we use openexr over anything else is because is it's because it gives us the option to save this as either 16 or 32-bit color information I'm gonna go for float full which is 32 bits here you can see this is 16 and basically what this means is that we get a ton of precision and this is important to where in in the case where we use this for displacement where we want our points to be elevated by certain amount and any amount of rounding error is going to make our model look choppy right it's going to look like it's made out of steps instead of a nice line so you want as much precision as possible so openexr fixes the linear space issue and it fixes this you know maximum amount of decimal places issue we got the most amount of precision so keep this at 32 bit 16 is fine there's no reason to not do 32bit okay cool and now that you have this all set up you know we've done our height map you've done your standard you've done your orthographic camera you've done your openexr these are all things that people forget right once you've done all this you can hit render and the nice thing about this is it really doesn't take that long so yeah we can't bake with cycles but you set it up with Eevee with all the correct settings it's nearly instant and once you have this rendered you do alt shift S or you could do image save as so alt shift s we're gonna save this on the desktop calling it proper proper displacement and notice this is an X R as an open e XR make sure that before you save this yes it's RGB openexr and full full float meaning 32-bit color channel data click save as image and now we have our displacement map and I guess this is the end of the tutorial however I would like to show you that this actually does work we could do it on a sphere you could do it on any geometry technically but I just want to do a nice quick example so here's how you might use this here we have everything set to cycles and a displacement map if we don't want to use this as a bump map which would work fine does it just hide information but if we want to use this as a displacement map make sure to add a subdivision surface set to adaptive by the way experimental is what gives you this adaptive option this is gonna let us subdivide on-the-fly by whatever amount that we need and then initiated workspace we're gonna work on our material make sure that your material by the way once we make it it's not gonna actually do any displacement if you don't set the settings to not only bump only but either displacement only or a displacement and bump so make sure you do that and then to set up our displacement map you should already know this you just import and your displacement map just need to find it here it is per proper displacement DX R I'm gonna take this put it on in our displacement socket and you're thinking oh wow what a you made this long tutorial and this is what the displacement ends up looking like what you need to do is at a displacement node in between connect this two Heights there's a couple things we need a fix to make this you know not look like garbage so first of all mid-level set this to zero meaning our plane stays where it's supposed to be right so black means don't move it at all second of all it wasn't this tall at all is something closer to like point one and scale maybe point two so you can see now we're getting close however we have heavy heavy heavy distortion on our geometry so the rest of this is pretty much saying we don't have enough geometry right now my laptop's clicking we don't have enough geometry right now to add this amount of detail so you just want to take your dicing scale bring it down and the lower you bring it the longer it's gonna take to render but the more detail we have and this is still way too tall so something like 0.1 should do the trick and you can already see we're getting pretty pretty I don't know I said a choice we're getting very close results to what we originally had you can still see that there's some detail especially when we look at the sides there's some choppiness and that will be fixed by lowering this even further or you could render out a higher resolution displacement map but you can see that vertical lines remain vertical there's no curvature from that PNG nonlinear workflow type of stuff and everything's working exactly how you expect and again we've kind of made this a procedural thing in the sense that it's a displacement map not you know raw geometry meaning that we can always like change where it is it's gonna take a while to update but that's the cool thing about using displacement maps you can pretty much control them you could add noise to it you could do whatever you could even cut off at certain elevations but there you go this should be the best tutorial on YouTube about how to bake displacement maps it goes over all the common errors so hopefully you found this useful and you can start baking your own height maps which really are displacement maps or bump maps and really displacement maps you just do this whole 32 bit thing to get that precision that's the difference but hopefully you enjoyed this tutorial if you did the best way to support this channel is via patreon if you have the means to do so and you find it you find this channel valuable and you want to do it I greatly appreciate it all the patrons I already have thank you for watching I'm assuming a lot of you are watching so again patreon you get of exclusive stuff you got some exclusive tutorials early access behind-the-scenes stuff tutorial files however I do like to talk about it as if it's a donation cuz that's what it is so if you have the means to do so and you want to thank you but otherwise I hope you enjoyed this free tutorial about baking the perfect displacement Maps I've been cg matter default cube you've been you bye bye thanks for watching
Info
Channel: Default Cube
Views: 291,327
Rating: undefined out of 5
Keywords: blender, tutorial, bake, displacement, bump, height, map, texture, procedural, cg, 3d, cgi, vfx, cycles, eevee
Id: arvhK4tvYuY
Channel Id: undefined
Length: 16min 2sec (962 seconds)
Published: Mon May 04 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.