Unreal Engine 5 - Parallax Occlusion Mapping Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video tutorial we're going to take a look at how to create Parallax occlusion mapping in unreal this will allow us to create surfaces that seem to have much more depth and detail as seen here but really these surfaces are nothing more than a much more simplified mesh or a flat plane if I take a look at the wireframe it's really just a flat plane for this surface so let's take a look at how we can create this effect of Parallax occlusion mapping and unreal first I'll start by creating a plane and then we'll also need textures for a parallax occlusion mapping if you're part of the patreon you'll get these sample textures available for download as well but first of all you'll need a diffuse color so something that has the coloring on the surface so in this case I have this sand type text here and then you'll also need a map that shows the height of the surface so this is height described as luminance or brightness at different areas of the surface and then you'll also ideally need a normal map and a normal map will describe the faked normal values of that surface and this will be useful and needed to be able to have lighting to react correctly with this surface because a lot of these shapes and details like these Footprints and dips in the sand don't actually exist in the model so the neural map helps fake those details by manipulating the normals or the direction of pixel on that surface and that can be used to emulate Lighting on these details that don't actually exist once you have your textures the next thing that we'll do is have to create a material so I'm going to go in here and right click and create a new material and I'm just going to call it m underscore pom for Parallax occlusion mapping and I'm going to open up my material editor so once we have our material editor open we're going to have to set up the material and unreal already has a parallax occlusion mapping node or network that you can start to set up so if you right click and you search Parallax occlusion mapping you'll find this node that already does most of the heavy lifting and most of the work so it's actually quite easy to set up the very first thing that you're going to want to do is load in your textures so we first have to take our diffuse text here so our color text here for our surface so I'm going to drag and drop in my textures my diffuse my height and my normal and I will go properly organize and lay these out so first of all the height texture will have to go over here and connect up to the height map texter then diffuse text here will be able to go here and connect directly into your base color and your normal will connect directly into the normal now the UVS of these nodes will have to be offset by that Parallax occlusion mapping effect so the UVS will go to The Parallax UV output of The Parallax occlusion mapping node so we'll connect it up something like that now you'll notice that our height texture won't actually connect to our height map texture here because this height map texture is looking for a t2d a texture object whereas this right now is a texture sample not a texture object to convert a text or sample into a texture object right click on it and convert to text or object by doing that my height texture now becomes a text or object and I can successfully plug it in to our height map texture here which is defined as a t2d or a texture object the next thing we have to do is Define what channel of this texture are we using for height so I'll drag this out and create a constant 3 vector and I'm just going to use the red channel so for x or for red I'll put 1. or you could just choose the color red and that will use the red channel of this text here for height we'll also have to define a height ratio and you can see here that this is how deep the height map is in relation to its width so it says typical values are between 0.05 and 0.1 I'm just going to set that to 0.1 to give us a bit more of an extreme effect oops not 1.1 there we go now once we've set this up there's a few other things we have to keep in consideration first of all is the Min and Max steps these are quality settings if you have too few steps you'll notice that the surface will look like it has almost slices or Cuts in it so if you run into that effect and you're wanting to resolve it or try to make it appear a little bit better you may have to modify your Min and Max steps so for now you can see the default for Min steps is eight Max steps is 32 I could drag these out to constants and put in custom values and I would recommend making all these notes that we're adding parameters and using this as an instanced material if you're going to be reusing it in your scene but for now we're just going to type in the values and hard code them in so maybe for Min steps I'm going to do something like 16 and for Max steps instead of 32 I'll do something like 64. so I'll push the quality up quite a bit and that might not actually be needed so you might want to preview how things look before you start changing those settings now the next thing that we might want to have on this surface is Shadow support or have shadowing be enabled so there is an option here for rendering Shadows do you want Shadows to be red on this surface so we probably definitely want that so I'm going to create a Boolean parameter here and I'm going to check it as true we do want shadows and then we'll have to define a number of Shadow steps so default is 16. I'm going to make that 32 so I'm going to go in here and make that 32 and then you also have your Shadow penumbra which is how soft or sharp the Shadows are and I'm going to take that and just leave it at 1. so now we have shadowing enabled the only other thing we need is a light Vector the direction that the light is coming from that generates the shadow now the best way to do that you could put in a value that describes its direction but probably the easiest thing and probably the quickest thing to do is to drag this out and use the sky atmosphere light Direction and that will automatically get the light direction of any directional lights in your scene and you have a number here to Define which index or which light it is so if you only have one directional light then it's going to be zero and that the only directional lighting you you have in your scene if you have multiple directional lights then you may have to change this number to specify which directional light the Shadows on the surface will be calculated from one thing that I've just noticed here that you will want to be careful of is for the height map channel here I just put in a constant three Vector you can see it says V4 it needs a constant four Vector so that's going to give me an error here so I'm just going to want to swap this with a constant 4 vector still have the red Channel or r as being the the map we want to use for height from this text here but then that will successfully solve that error so be careful with that one so now that we have this all set up if we save this and apply this to our object in our scene we're going to see this Parallax occlusion mapping effect but there is one thing that we'll have to take into consideration and start adjusting or maybe actually two things the first thing is we don't really have shadowing working right now even though we enabled the Shadows if I change my directional light we had some shadowing from the normal map but we don't actually get any other proper shadowing and the other thing is if we go really close and I move this sphere you can see the ground just feels like it cuts off even though we have details that look like they're popping out of the ground like this lump here when I move the sphere to that area it's actually just feeling flat so we can make that feel as if it actually has bumps in the surface and occludes or covers up parts of this sphere but to do that we'll have to enable a feature called pixel depth offset so that's one thing we're going to be taking a look at next and the next thing is also how do we get proper Shadows on here we enabled shadowing but there's one more thing we have to do so I'm going to go back into the material here and the next thing that we're going to do is set up the shadowing so you'll see that when you connect up these shadows and you render Shadows it actually outputs Your Shadow as a mask here so this is the mask of your Shadow we have to manually add that shadow on top of our diffuse texture or on top of our surface somehow so there's plenty of ways to do this but the simplest way and maybe not the best looking way but definitely the quickest way of setting this up would be to take a lerp or a blend so I'll take a linear enter plate note and for the alpha I'll use the shadow so the alpha is the mask and then for the a color it will be my texture and for the B color the color that's going to overlap using the shadow mask I'm going to take a multiply node and multiply our text here by point two or something a much darker value so it just makes it darker and gives us the illusion of a shadow so I can do something like this and this will give us a proper Shadow on that surface now so I could do something like that so that's one thing that will help get our shadowing on our surface so now if I save this it might be a little bit subtle but if we go in here and we take our directional light and I start rotating it we got some Shadows on that surface now so something that you can kind of adjust and play around with and this also works for if we have like this ball casting a shadow on the surface that all works as well now the next thing that we want to solve if I move this ball we don't really see any of these details affecting it it just feels like a flat plane that's colliding with so this one's really useful and this is pixel depth offset feature that you can enable so to make this properly work you could take that pixel depth offset and connect it to pixel depth offset here and that's really it now you're going to notice your preview is going to look a bit messed up like this and this is because when using pixel depth offset the shadowing gets messed up on Parallax occlusion mapped surfaces the objects will start to Shadow themselves with their original Geo and not with the kind of Parallax occlusion mapped details and that will cause a bit of an artifact like you see here now it might not be a problem in a lot of cases if I save this and I look at this actually applied to our object in the scene it doesn't seem like there's really anything wrong and if we look at this sphere and we push it into the ground you could see that pixel depth offset effect is now working where there these details in the ground are actually cutting away from the ball properly and not just being like a flat surface so everything here is working as expected and it looks pretty awesome and it actually looks like a very detailed surface but if you do notice on certain shapes let me move this a bit higher up as well there we go but if you do notice a certain shapes and you apply your your Parallax occlusion map if you're getting weird Shadow artifacts you might have to take your surface that you're doing The Parallax occlusion mapping on and go into the static mesh component and disable cast Shadows so if you're using you can see here cast Shadows is off and that's on this plane if I turn it on there we go we get this strange effect see that it self Shadows itself and you only run into that problem if you're using pixel depth offset if I disconnect my pixel depth offset and I save no problem but then you don't get any proper offset for intersections but if I enable pixel depth offset then you get those proper intersections as seen here but you get this weird shadowing artifact so to solve that just take your plane or Surface turn cast Shadows off they won't cast Shadows they'll still be able to receive Shadows this is a little bit of a technical problem where it could be overcome but the way to overcome that starts making a much more heavier solution where you might off might be better off just using nanite geometry or something very detailed and unreal as an actual mesh but for most Parts you don't really need that when using Parallax occlusion mapping because this effect is best used for piles of rubble on the ground and things that wouldn't really matter for casting Shadows themselves are on the ground and if you really need some sort of solution where you do have shadows and you have pixel depth Offset you can always have no Shadows on this mesh and then have a secondary mesh that doesn't get rendered but just cast shadows and kind of solve it that way as well but this is how you can set up Parallax occlusion mapping in unreal and add a ton more detail and it's especially useful for any natural organic ground if you've enjoyed this video and you've learned something new Please Subscribe click the like button let me know what you want to see next in the comments and if you're part of the patreon you also have available the PDF for this video as well that will go over in a little bit more detail of setting up this Parallax occlusion mapping and going through all these steps that we went through in this video
Info
Channel: renderBucket
Views: 47,677
Rating: undefined out of 5
Keywords: Unreal Engine 5, parallax occlusion mapping, POM, UE5 tutorial, game development, 3D textures, advanced materials, game design, UE5 POM, virtual texturing, height maps, shader setup, game engine, visual effects, UE5 graphics, level design, 3D game art, game assets, game artist, create realistic surfaces, game dev tutorial, learning UE5, UE5 material editor, parallax effect, game environment, next-gen graphics, game technology, POM technique, bump offset, normal map
Id: jrJP__JRjEY
Channel Id: undefined
Length: 16min 37sec (997 seconds)
Published: Wed Apr 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.