UE4 Pearlescent Material Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right welcome to another tutorial here where i'm going to be taking a look at creating a pearlescent paint effect um giving that kind of oily sheen that you see on some uh on some very high-end car paint jobs uh now this is a request i'm doing this for a couple of uh students here that are looking to see how you would do this inside of the unreal engine so i've got open here a uh an older project that i've been working on and uh and the main reason i'm using this project is that i need a surface upon which to place my pearlescent material and i have a block out here of a car i've been working on and so this is actually going to work really nicely to place this on now currently in this material i have nothing more than just a a red value with zero going to metallic and zero going into roughness so i just made a really really shiny red material and what we're going to do is we're going to turn this shiny red material into a pearlescent material now there's a couple of different ways that you can go about doing this and i'm going to show you kind of one of the easiest ways that i've done this in the past i think the first time i done this was in the early 2000s working on a game where we had to do an oil slick on the ground and i wanted to capture that kind of uh shimmery color that you get there so i've got open here in photoshop a 256x256 image and really what i want to capture is just kind of some of the the coloring that you get uh in those reflections um and so that kind of uh that kind of pearlescent or that reflective color that you see all over the place to do that i'm going to do something really simple i'm just going to go into my channels here and i'm going to run a filter called render clouds and what that does is it randomly assigns a pixel value to each pixel that is a random amount between your two selected colors so i have black and white selected and as such i'm going to get pixels that are somewhere in between there may be completely white pixels and completely black pixels um but then what i'm going to do is go to the green channel and i'm just going to run the same filter and the blue channel and i'll run the same filter and what that's going to give me is this kind of rainbow mixture of colors here at a fairly low resolution um but what's really nice about this is that when you use that filter clouds the image tiles and so you can see there's this kind of orangey blob here that kind of pokes through the other side and so that is going to make this useful because as we start applying this to the uh to the material in the world um we're going to end up with this thing tiling more than once so i'm going to go and save this on my desktop here as a png and we'll call it reflection or reflected color like so and we'll go and bring that image directly into um into unreal so i'm going to open up a folder here go to my desktop and drag that reflected color in okay the next thing that i need to do is i need to set up a material function that is going to be used inside of my material so one of the ways that i work in unreal is trying to add a lot of reusability to the things that i make and so i don't want to just one off this material and have it just be the symbol uh this simple pearlescent material that goes onto one thing i would like to be able to reuse it as as many places as i can in different ways and so i tend to kind of go about about this in a way that has some reuse and using material functions as a way of doing that so i'm going to first right click go into materials and textures and go and create a material function okay and we're going to call this uh mf from material function underscore uh and pearl essence like so and then i'm gonna go into that material function and we are going to need a few things that need to be uh that need to be set up here so the output of this um this node here is going to be our our color and so i'm going to put that as the name here base color and this is actually our pearlescent color now what we need is we need to create a series of inputs here that we're going to use um there are going to be uh a couple of different ones that we're going to use here that you're going to see so let's right click and create an input like so and i'm just going to duplicate this three times here we'll move one over here so the first two that i need are actually going to be part of our normal map and the reason i want this is i want the the shape of the normal to appear in our iridescence and so that's going to be kind of important but what i'm going to do is i'm going to split that normal map up i'm going to grab the red channel and the green channel independently of one another and what that'll do is it'll actually give me the ability to to get the uh left and right information and or the horizontal information and then the up and down or the right information uh like that so let's go take this node here and we're going to give it a better name which uh we'll call it normal map red so nm for normal map underscore red underscore channel and we'll do the same thing with this one this one is going to be nm underscore uh green underscore channel but we've got those two channels coming in i'm also going to well since i actually want to split these um we're going to go and do a uh let's see let's do a component mask and we're going to make just two of these things here for now we're actually gonna need more than two of them actually let's make another one here while we're at it we'll use that in a moment so we're gonna take these two here and we're gonna get the red channel in here and the green channel in here and i wanna get these down to just a single channel so the red channel in the first one and the green channel and the second one this is just to make sure that we're not adding any extra information here in any way the next thing i'm going to do is get my camera vector so the camera vector is a vector um that gets its directionality from the camera so wherever your camera is pointing it's kind of like an arrow shooting out of the camera in that direction so we're going to take this i'm going to mask its red and green channel and i'm also let's make a duplicate of this i'm also going to mask out the green and blue channels so we'll get rid of the red like so okay i then just want to add these things together so i'm going to right click and hit plus and we'll make another one of those so we're going to add the red and green channel of the camera vector and we're going to add the red from our normal map and then we're going to add the uh green and blue with the green like so so that'll give us and i can actually probably uh make a less messy version of my lines here if i go and orient them in a better way so we'll put the camera vector in between here and then we'll put our masks in here we can see this a little bit easier like so okay so we have a normal map coming in we're masking it we're taking the camera vector and then we're adding that black and white image from the normal map into the camera vector the next thing that we want to do is we want to then feed this into the uvs of an image so that's where our um our uh our image comes from now you can do this as an input if you wanted to change your image i'm not gonna bother doing it as an input i'm just gonna grab my image and bring it into the function here so you could do this as a uh you could do this as another input if you wanted to give your user or yourself uh using this material the ability to change what image you're using you know sometimes you might want to use something a little bit different looking and so we're just going to make two copies of this a and b here um and you can see as i move my camera around here where i move the uv thing around we start seeing various areas of those colors and that's kind of what we're looking for then what we're going to do is we're just going to blend these things together so i'm going to create a lerp and we're going to take the rgb value from a and the rgb value from b and we're just going to blend them at 50 so this is half of this one and half of this one then we're going to let's use this other input here to get our base color input so let's call this base color and this needs to be a vector three which it is and then what we're going to do is we're going to learn this uh alert where's my alert linear interpolate and we're going to learn that with the color coming from here into the output and that's going to give us this kind of effect we get these shiny colors here kind of all over the place and uh and what i want to do you can see there's a lot of yellow in this i may want to go and adjust that um what i want to do is i want to give this a a parameter here that i can use to turn up and down the uh the strength of this and so let's create one more input and we'll call this one this is going to be a scalar and we're going to call this pearl essence strength and uh by default i'm just going to go and give it a value um where are you uh x of 0.25 and i'll just go and throw that into the alpha like so okay so we're going to save this now and there is one more thing that i want to do which is to go and sort my inputs so that they make sense so i want the base color to be on top so it's going to get sort priority zero followed by the two normal maps so the red channel i want on top so it's going to get one the green is two and then we're going to do our pearlescent strength as three okay so we'll save that and close that and i'm gonna have it selected here in my uh in my content browser and inside of here we're gonna right click and we're gonna say uh function and we'll get a material function called so here is now our function call because it was selected in the content browser it has shown up by default when i selected it if it doesn't show up you can use the drop down menu here to go and select it but here is now my pearl pearlescence node now this vehicle here is not going to work ideally because um i don't have a normal map on this thing this mesh just doesn't have a normal um which is something i probably should have thought of when i was doing this uh no worries i do have other vehicles in here and so what we'll do is we'll just grab one of these guys and we'll apply it to this one instead so let's get rid of this um no let's not do that let's move this out of the way so that it's out on its own over here okay so i'm not going to have a mask or anything though the entirety of the car is going to be covered in this or actually it'll just be in the paint area we'll replace it with that so if i go back into here and we'll go name this material here master material underscore pearlescent okay and i'm just going to put that in the paint job of this car so that should give us what we need again i don't have a mask on here so it's it's i'm not getting the proper white material that should be in there uh however this will still work so now uh this thing does have a normal map and that's what i'm really interested in so i'm going to go into his textures here i'm going to find the paint normal map which is for that part of the car and i'm going to drag that into my pearlescent material okay i am going to um [Music] parameterize this get the parameter and this is uh normal map like so and we can now go and start plugging this in i actually need two instances of this one one to go into the normal which i could just wire this across but i don't like having too many nodes like that then we've got a red normal map and we've got a green normal map in the pearlescence node in this case i have a just a flat color going into my vector three but we'll we'll actually go and pull the paint job color into here too and we'll be able to switch between those so i'll put this up here um [Music] now that i have this let's see uh i'm going to leave this super shiny i'm not going to make any changes to that um i need a a couple of uh lerps here we'll actually need one loop here so we're going to learn between our base color and the base color from here which is going to go into this base color uh we're going to get an error out of the gate because i don't have a strength in here so i'm going to create a scalar parameter which we'll call strength and let's set this to a fairly low number to begin with let's give it a default value of 0.1 i'll put this into the pearlescence node here and that should actually get this thing going now we're not seeing too much here at the time being but that's okay uh and i think that's really all i need in order to make this work so we've got this uh let's go do a uh switch so i want a static switch parameter and we'll call this texture question mark go true if it has a texture it'll use this guy false it'll use a color which we're gonna parameterize as well and we'll call this base color okay we can do that and then i'm just going to use the uh the parameter here to replace our inputs like so um and then we can go and save this all right so in the world here now we have this material on the vehicle and so far there's not really much going on um let's go back into that folder and create an instance of this and we're going to do an instance so that we can actually better edit this material so i'm going to go and put it in here now an instance can actually be run it uh edited at runtime as well which is why this is kind of useful to do this way so we're going to go and pull this guy out here and i'll just go and put them beside the car and we can start to make modifications to this thing now uh i don't need the normal map to be a parameter at the moment i don't need the base color to be either but we'll actually we'll turn that on so if i turn up the the strength of the pearlescence here um like so we'll start getting that swirly kind of color effect happening to the vehicle now i've got it at 0.75 which is probably strong let's go and change our red color to make this a little bit more noticeable i'll go and make the vehicle black and you can see now that we're starting to get those kind of color swirls up here inside of the vehicle and so the stronger or darker um i make this the more we'll start getting it now you can also use a a fresnel in here to kind of give it a glancing effect as well um in order to make that work um but yeah you can you can totally set that up however you like um if i go into my uh my values here let's go play around with uh this and go into uh there's the strength uh oh that's what i'm missing i didn't create there's one more node i didn't create here which is a another scalar parameter that i want to put in here and this is the blend so this is going to blend between the pearlescence um and uh and not pearlescent so if i go and save this so this gives us a little bit more control over it so if you look at it here now um you can see that a lot more of that black paint is in there but when we get kind of these weird glancing blows at the normals you start getting some of those really pretty colors showing up now again i'm doing this with a um i'm doing this with that just that image there um which you know doesn't really have a tremendous amount of color variation in it let's go see what we could do with a uh a rainbow image here as well so i'm going to go into google and we're going to go and find just a a rainbow colored image here i'm going to grab this flag i'm going to copy this copy image we can close that and then i'm going to go into here and i'm going to paste that in here and i'm just going to force it into the right uh size like so we'll just move it over here like so i'm going to just crop this like so and then i'm going to go filter blur and gaussian blur and we'll just get it to the point that we we start getting a lot of really nice blending between the colors now ideally uh again this doesn't this doesn't tile um which is problematic right we would want to have some of that some of that purple and red mixed together so i'm going to filter and i'm going to go to uh let's do other and offset and we'll just offset this a little bit like this and then do a filter blur again filter blur and gaussian blur um just to blend those those colors together so it does tile so let's go and save this as a png like this um i have one here is a tga actually let's just import that one let's go back into our material here and back into our folder and i've got this this is only a uh a one pixel tall by 256. um but the end result is going to be identical here we've got this pretty rainbow of colors in order to uh to make this something that we can access um access inside of here as always saying i would need to turn these images here into a input um and so if i go and create another input like so and this is going to go uh no that's not going to work like that uh no we don't want to do that uh yeah yeah that's fine let's just replace that image oops we're unreal go there we go so i'll just go and select that image and then in the function we'll go and replace it this is going to have a slightly different effect we're going to see a little bit of a checker board on here you can see the colors are a lot brighter however so let's go and save this function and go look at the vehicle here again and you can see we're now getting really bright values on this thing as it goes up and again i've got these now these two strength nodes here that i can play with in terms of just how powerful that effect is and so i probably don't want to drop this below uh one here but that gives you that pretty pearlescent effect um and then i can go into my texture here and let's say that yes this thing is textured and we're actually getting that pearl essence here with the texture as well now you need to do a little bit of finessing uh with the numbers in order to uh to get it to be more visible when you've got a variety of colors because it may be more visible in one and less visible in another and so getting to a point where you can see it and and where it's reading the right way um is going to be useful and so i've got it kind of on here like this again with uh with some of these darker colors it's a little harder to see and let's put the strength up to one there's now it's actually just completely blown out so you can see that it's there so yeah i want to probably keep this on the you know on the soft side that um let's bring the car back do that um that uh that bright color that i have on here doesn't really lend itself well to the um to the effect and so if we turn off that texture and then go and uh and soften these up again here again so that they're very very minuscule 2.006 i'll set this just at 0.5 for now and yeah there you go there's this kind of neat pearlescent color shift that you can do you can also set this up so that it does a specific color um when it does this and and again i'm not blending it with uh um with anything uh fresnel or anything like that but we can do that as well um again where we are blending right here's our base color um where we're blending it with the uh the color here well we could use the pearlescent value here and take a fresnel and again create some inputs for the for the now and then we can actually go and blend the fresnel and the input together and put them into the alpha which would give you that kind of glancing blow where the color is either stronger or weaker depending on what you want but yeah that is a pretty quick and easy look at doing something that reads as being pearlescent um and giving you all the really kind of cool colors that you get um with something that is iridescent uh and whatnot and so yeah i hope that's uh been helpful and uh something that you are able to reproduce on your own and uh yeah let me know what kind of things you make with this pearlescence and until next time we'll catch you later
Info
Channel: Christopher Turner
Views: 163
Rating: undefined out of 5
Keywords:
Id: iYU-0neLImM
Channel Id: undefined
Length: 23min 2sec (1382 seconds)
Published: Wed Oct 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.