How To Use The Map Range Node || Blender Concepts

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you think the map range node is just a worse version of the color ramp then this video is for you i'm not bashing the color ramp at all they both have their use cases and can do things that the other can't here's a brief summary of what i'll go over in this video i'll start off by comparing the visual differences between the color ramp and the map range node this is the kind of stuff that would be useful for making roughness maps and stuff like that then i'll do my best to explain the math behind the map range node and talk about interpolation and clamping with some cool displacement examples i'm not a math person so hopefully i don't butcher this then i'll finish up with showing you how to use the map range node with multiple colors like you would with the color ramp alright let's get started so if you want to use the map range the same way you would use the color ramp treat the from values like the position of these two flags and treat the two values as if you're coming in here and just changing the value like that and just to give an example i'll take this black flag right here and set the position to 0.5 and i'll do the same thing over here and you can see they're exactly the same right now and if i take our black flag again and just change the value to something like 0.1 you can see it turns kind of gray over here like that and if we change the 2 min value right here to 0.1 and compare the two they're going to look exactly the same so once again i treat the from values like the position of these two and i treat the two values as if you're changing the color like that i think a lot of people have an easier time understanding the color ramp because visually it makes more sense say for instance you want more black in your noise texture right here you can pull this black slider up right here and now you visually have more black in this bar right here and you have more black over here too so it's easier to understand visually and if you want more white you just have to move the white slider and then when you look over here your texture is more white and the transition between the two is just smaller the same way like it is on this graph right here so when this is clamped it works pretty much the same way the closer these two are together the smaller the transition between the two visually but one nice thing about the map range is that you have all these inputs and you can control them externally whereas the color amp you don't you just have this one input right there so to give an example i'm going to add in a value node and a math node i'll plug the value into the from minimum then i'll plug this into the add node and the add node into the from max so basically what's happening here is this value node is going to be the position of this black flag right here and this add node is controlling how far away the white flag is from the black node so basically this add node right here is just the distance between these two flags right there and when i change one it's going to change both like that so if i wanted these two values to be really close to each other so it visually looks sharp i would just have to change this to a small number like point one and now when i move this it's as if i'm moving this and the white flag is following it and so they're always staying the same distance from each other just by moving this one value node and this is something i actually use a lot for roughness maps so basically i can control the maximum and minimum roughness with these two values right here similar to how you would just change these colors like that so if i want our roughness to not go all the way up to one i could change this to like 0.3 or something like that and then i can control the transition between the two so right now we have a pretty sharp transition i could make it even sharper like point zero zero one and now it almost looks like it's just on or off uh if i want a more gradual transition i can change this to like a 0.5 and then you can control just the balance of these two colors by changing this so you can see when i turn this up then there's more of the low value when i turn it down there's more of the high roughness if you wanted to do the same thing with the color ramp every time you move this you have to move this also if you want to use the color amp in the map range interchangeably make sure you leave this clamped we'll talk more about clamping a little later one thing that the color ramp offers that the map range doesn't is actually the ability to change color beyond grayscale so i could change this to like red and blue or something like that and you can also add multiple stops in here to add multiple colors it also gives you some interpolation modes that the map range doesn't have we'll talk more about this later when we get into displacement and you also have this section right here that allows you to change from rgb to hsv or hsl and when you do that it gives you some more interpolation modes and basically the way i understand these is if it's set to near it's going to find the nearest route between these two and what i mean by that is we have red and we have blue right here and it's just going to take this root right here and if we set this to far now we have these other colors in between it's going to take this root and you can visually see that those other colors are in there too and it's just following that same root you have uh clockwise and counterclockwise basically it's not going to look at how close they are and just go in one direction all right this next part i'm going to try to explain the math end a little bit and so right now i just have my plane again and i have a gradient texture on it a spherical gradient texture where the middle of the gradient equals one or white and the edge the lowest point is black or uh with a value of zero so when you just place it it'll look like this and i set up these backgrounds so that each of these squares equals one the blue is positive and the red is negative so where they meet that would be zero you know this would be one unit and this would be negative one and i'm going to use this to explain how the math works behind the map range and once again i don't consider myself to be a math person so hopefully i don't mess this up if i explain any of this wrong feel free to correct me in the comments below so i like to think about the froms like the starting value and the twos like the ending value so you can see right now they have the same values they have the same distance they both have a distance of one so you can think of this kind of like a ratio like one to one they're both the same size but if i make this something larger like two now the distance between zero and one is one and the distance from zero to two is two so it's like telling it to double in size and you can see that right now our plane is twice the size it was before instead of going from zero to one it's going from zero to two and this works when you go the other way too so if you wanted it to be half as big you could change this to 0.5 and this works the other way around too so if we change this to two right here the distance between these is two and the distance between these is one so it's like saying start with a value of two and then half so now you can see this is half the size and when we talk about clamping you can see if i turn this up like this that it's getting cut off right here and when i unclamp it it continues like that so basically when this is clamped it's using these values right here and saying don't go below the minimum and don't go above the maximum so you can see even though this wants to go above one it's cutting it off instead to stay at this value right here so if we change this value it will allow us to go above so i set this to two and now it's treating the maximum like two like that it's just clamping it but it's also kind of distorting our plane right here uh because the distance between these two is different now so when you unclamp this it won't stop any of the values from going through and it'll just keep continuing and this is something that is pretty important when you're using the map range for math or for something like displacement where you want negative values to come through so most textures like the gradient texture they keep their values between zero and one but there is an example of one texture that doesn't and that's the musgrave texture so like i said before normally when you see black that would be a value of zero but if it goes into the negative you can't visually really see a difference because going lower than zero will still just look black so when we're using the muskrate for displacement you can see that it does actually have negative values like i said uh where the red and the blue meet that would be zero so the musgrave by default goes from negative one to positive one and the midpoint is a zero and so if we run this through the map range node while it's clamped you can see that it cuts off all of the negative values and just leaves it flat right here and when we unclamp it it lets them through and so as far as i know clamping is something that happens at the end and i know that because if it happened at the beginning if it just didn't let negative values come through right here then all of the negative information would be lost but if i move this up like this you can see that it lets us view the negative information as long as we move it and so i'm pretty sure clamping happens at the end it doesn't actually destroy any information it just kind of stops it from leaving and restricts it to this range right here so a big difference between the color amp and the map range is that you can't unclamp the color ramp it just won't let negative values leave you can even come in here and try to type in negative one and it just won't accept it it does allow you to input numbers higher than one it won't let you scroll but if you type in two it will stretch like that and it will let a value of two come in here but pretty much i'd say you probably shouldn't really use a color ramp for math because it's gonna prohibit you from doing anything in the negative range so let's talk about interpolation now this is something that is going to be easy to see when you're using displacement and would be important for something like a bump map so when we have this set to linear you see it's going from zero to one and it's just taking a straight line so it's kind of pointy at the top when we change this to stepped linear you can see it's going up and sideways like that and we have this right now set to four so it's taking four steps you can just count them one two three four there are four steps we change this it's just always going to equal however many steps we put in here and if we look at this without displacement this is what the texture would actually look like you can see it's hard edge with no gradation no transition like that and this could be really good for something like a tune shader and other non-photoreal textures so you can see with smooth step instead of just taking a straight line from zero to one it is a more gradual transition and smooth step and smoother step are really similar you can see that smoother step it's just more gradual right here and if you look at the slope you can start to notice the difference if you're using this for texturing you can see the difference it just kind of looks more like i mean i would use the word smooth kind of like airbrushed but it's a lot easier to notice when you're using this for like a bump map or displacement so the color ramp also has linear and it's the same as the linear for the map range it has cardinal which is kind of like smooth step you can see it starts off smooth but it doesn't go um straight like horizontal it kind of starts at an angle then we have ease which as far as i know is the same as smooth step i don't see any difference visually then we have b spline which is very smooth and if you look at this graph right here it doesn't actually hit its target point it kind of like overshoots it so we don't get pure black until like right over here i don't usually use this for displacement because uh it kind of lacks control and i get these weird artifacts too i find this more useful for actually like blending colors and then finally we have constant which is similar to stepped linear uh except there's there's no gradation at all there's no transition between the two it's just sharp and you could get a similar effect as stepped linear over here if you just change this to linear and start adding stops in here like this and then you change it to constant like that and then you could also arrange this distribute stops from left like that and now they're all evenly spaced if you're trying to have more control with displacement or bump mapping i would recommend using rgb curves or vector curves i usually use rgb curves for this you can pretty much just drop it in and draw um the shape that you want right here so if you wanted it to be like completely smooth like a bubble you could do it like this or if you wanted it pointy but curved you could do it like that and it's pretty much just matching this shape right here and you can just kind of draw whatever shapes you want and you can even come in here and change these handles to be sharp vector handle like that so now this one's sharp but similar to the color ramp it doesn't have that many inputs right here for you so you can't control any of these points from the outside so here's a situation where i'm just using a voronoi texture to create a bunch of spikes and when we have this set to smoother step you can see these are just like smooth mounds we change it to smoother step there's a slightly smoother transition right here when it first starts if we change this to linear it now looks like a bunch of sharp spikes and this also works for bump mapping if we're not using displacement so you can see these look pretty sharp right here but if we change it to a smoother step now these look a lot smoother and once again if you want more control just add in an rgb curves you can use that either instead or in addition to right here so i would change this to linear so it's not distorting it twice so if you wanted something a little more like bubble wrap you could use a shape like this you can just adjust the strength of your bump right here and here's what it would look like with displacement all right so this part i'm going to explain how you can use multiple colors like this but with the map range node and use it similar to the way you would use the color ramp node so for this i'm just using this noise texture right here and i'm running it through the color ramp and i have these three stops one is red blue and white and i just have these at position point four point five and point six so i'm going to show you how to first use the map range with just two colors and this is pretty easy uh it's pretty much just two nodes i usually use the map range and the mix rgb for this and you can just plug the result of this into the factor and then your black value would be color one and your white value would be color two so i could just change this to red and this one to blue like that and then if you wanted them to be sharper you could just do like point five and point six like that and this is how you would use two colors so when i switch to three colors this starts to get a little more complicated but it's not too hard basically you're just going to want another map range and another mix rgb make sure that your texture is plugged into the value just like here one above you can plug the result into the factor just like this one right here and this mix rgb you're gonna plug into color two of the one above it like that and then these would be your three colors so i'm just gonna hover over ctrl c and ctrl v to paste that color and i'll change this one to white like that and to make this easier to control i'm going to add three value nodes like this like that and these are going to be the positions of these stops just like we have up here so we had point four point five and point six so i'll put point four this one's already at point five and i'll change this to point six okay so i'm going to use this for our minimum value right here and the 0.5 is going to be our maximum so the maximum here is always going to be the minimum right here so i'll plug that in here like that so where the range of this one stops this one begins if that makes any sense and then i can just plug our last value into the from max for this example i'm going to ignore the two values just like entirely so don't even worry about changing these values at all so now that we have this set up we can compare these two right here and i made sure that the colors i'm using here are the same colors that i'm using here and when we compare them they're exactly the same and this is also because we have it set to linear here if you set this to ease you would have to come through here and set all of these to smooth step like that and when we compare them now it's the same as if we were setting it to ease so if you wanted to add more colors you would pretty much just repeat the steps that i took before by duplicating it like this making sure this mix rgb is going into color two of the one above it i can change this color to something different i'll just change it to like yellow or something you want to make sure that your texture has plugged into this third one right here i'm going to change all these back to linear and you want to make sure you have the same amount of value nodes as you do colors and like i said before where the range ends of this one the range will begin with this one so so it's going to share one value right here the from max of this one is going to be the from min of this one and then we can use this for the last value right there from max and i'll just change this to 0.7 and so now we have four colors one problem with this is that these have to be in order from smallest to largest and if they overlap it starts to not work like that so just remember that you have to keep these going from small to large like that if you wanted to you could turn this into a group node basically what i would do is um make sure you're using node wrangler for this you can go to preferences add-ons and then type in node wrangler and just make sure this is enabled and when you have that you can shift and right-click to create re-route nodes like this so i'm going to do that for all of the values and i'm also going to do that for this texture input right there and then just select all these nodes including those reroute nodes we just made when you have them selected hit ctrl g to group them like this and then you can hit n and to open up the side panel to change these values around the fields and you can rename them and stuff like that you can also plug these into the colors so that you can control the colors from the outside also and what i like to do is just line the colors up so that they're next to the value that is controlling them i like to make sure that these are all clean in here i just removed the reroute nodes and i'm just going to go through here and rename some and so now this is what it would look like from the outside and you can control all the colors and positions of each color alright that's it for this one i hope i did a decent job explaining how these work if you'd like to download the node group i made at the end you can get it for free on gumroad along with some other free node groups that i made if you find them useful consider giving a donation or a rating thanks for watching have a good one
Info
Channel: Joey Carlino
Views: 5,466
Rating: undefined out of 5
Keywords: blender, cg, cgi, blender 2.9, ColorRamp
Id: 3ilYr-_UkJQ
Channel Id: undefined
Length: 19min 37sec (1177 seconds)
Published: Thu Apr 29 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.