Parallax Occlusion Mapping | 5-Minute Materials [UE5]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome back to another 5 minute materials today we're going to be looking at Parallax occlusion mapping what is it why is it let's find out all right we're jumping straight in first thing we're going to do we're going to go to a new material this one's called yum we're going to Chuck that on our Cube we're going to go into the material and we are going to get a texture sample cool we're going to go for the old uh Prismatic uh path regular very cool we're going to grab this I'm going to unpack my normals you don't need to do this part Chuck the normals into here um I use a color mask so we're going to do this into a three lurp you probably aren't going to do this but we're just going to get our three colors you're going to just be chilling and O MCD doy so this is our standard texture mapping on our standard Cube uh you can see it looks fantastic honestly it just it lacks a bit of depth when we're we're looking at it down here so one thing we could do uh and this is probably the cheapest way to do Parallax and whatnot we're going to get bump offset and we're going to get our height map which for me is in the alpha channel of my texture you might have a separate texture for your height map and we're just going to get our coordinates we're going to Chuck that in there we're going UVS and Bam we have a little bit of of three dimensionality uh now I could just Chuck this up a tiny bit further just so we can really exaggerate the effect and you can see we do get some 3D kind of looking whatever whatever but it kind of falls apart at shallow angles and we can't push it as far as we would kind of like to so what is the solution to our conundrum how can we get it like really like really like uh you know like popping out at us well the answer can be parallx occlusion mapping if we look at bump offset what bump offset is doing is just taking our camera Vector it's taking you know the uh vertex normals whatever and it's just applying a very simple UV offset to the texture as you know before it gets sampled parallx occlusion mapping on the other hand is a bit more extreme so let's Yeet our texture samples into Oblivion we're going to go Parallax occlusion mapping this is the standard unreal implementation if you want to figure out what this is actually doing under the hood you can double click on it it is a material function as with most of the unreal material functions it is delicious spaghet and you can see that it also uses a custom node which contains all of this stuff it's a whole thing thing the reason it has to use this node here is because the max steps and the step size and all those variables essentially have to do a loop and Sample the texture you know up to like 16 different times in order to actually do the effect so if we just jump back out of there we'll kind of run through all the settings and you know get this set up for our material so the height map texture is we need a texture object bam we're going to grab our pris Stone path height map texture goes in here the height ratio will leave default the Min and Max steps will leave it default ideally you want these to be as low as possible but still achieve the desired effect the UVS we're just going to use our default UVS this could be in World space if you wanted to but for now we're just going to do this the height map Channel um I use the alpha channel so I'm going to put that into there if yours is in the blue Channel then you might want to use you know 0 0 1 0 our reference plane now by default the reference plane will be set at 1 which means that all of The Parallax effect is kind of being pushed down under the true surface for something like bump offset usually it's 0.5 as the default which means at like the midpoint of the height map that will be kind of intersecting the plane and then you'll have bits that sort of come up out of the plane and some bits that go in and then obviously if we put this down to zero then the entire thing will kind of look like it's going above the plane now a little trick with this reference plane is you can actually kind of just apply extra deformation using the reference plane so if I just grabbed a radial gradient exponential just one minus and chucked that into the reference plane right here then you'll see that our texture bulges up and obviously if I remove it again the texture goes back down so this can be really handy for certain types of effects if you're doing like vertex painting you can use the soft vertex color into the reference plane so if you had like vertex color or something and you're doing like a damage effect with a parallactic cluded mapped sort of damage texture that was being revealed by a height lurp then you could use the soft vertex color so the original vertex color and you could put that into the reference plane so that it kind of looked like it was taking big chunks out of you know whatever you're painting damage onto all right so here are our outputs we have The Parallax UVS which are then going to go into our text just sample as before so this is essentially taking our input UVS doing a bunch of stuff to them and then outputting it here and then we can just sample it as normal so pris Stone normals go into here color mask goes into here we can just hit save and you can see now we have very like three-dimensional stones and they look quite good they actually like olude one another but you can see at shallow angles it starts to do some really wacky stuff now you can alleviate this slightly by increasing the maximum steps so we could go up to like 64 but keep in mind that the more steps you're doing the more expensive this is going to be but you can see that this is extremely three-dimensional looking and there isn't as much sort of warping and Distortion as we move around it actually looks like it is you know geometry all right now there are a few extra outputs the offset only is you know if you took this uh and you then added the offset to it this would be the result and if we actually have a look at the original UVS so this is the regular texture coordinates compared to The Parallax occlusion did texture coordinates you you can kind of almost see like a a kind of ghost of what's going on and if you think about it uh for example if we're like in the Red Corner we would expect to see parts of the texture kind of creep up over into here and so essentially that's what we see we see more red over here because we're starting to see red parts so this corner of the texture include other parts of the texture and if you look real close you can see those kind of layers from the um like the ray marching we're going to skip Shadow for now pixel depth Offset you can plug in to the pixel depth offset and it will offset the depth of the pixels uh as per the name but you will get some really weird shadows um so if this wasn't casting Shadows then you know it's kind of POG because then if we had another Cube uh we just Chuck over here then you can see that our Cube actually like intersects with these uh where where it should whereas if we didn't have the pixel depth offset then it would intersect with it as though it was just a flat surface so pixel depth offset off you can see that it kind of looks a bit floaty because you know everything is kind of being pushed down by the parallx occlusion uh and all that kind of stuff now there is a kind of hacky way you can get around this with shadows uh if we have pixel depth offset we Chuck it into here we get a shadow pass switch into our world position offset uh our default is going to be zero but our shadow is going to be like uh I don't know just going to like move it down 10 units or something and then we're just going to put cast Shadows on and you can see we kind of alleviate the shadow casting effect um it can get a little bit when you're like moving around essentially what this is doing is saying when this object is rendered in the shadow pass render it 10 units down in World space um so you could kind of dick around with this and like figure out you know what the best value is so for now I'm just going to turn pixel depth offset off uh and then the last thing we're going to come back to Shadows uh this is like a kind of fake like raycast Shadow we're just going to get the atmosphere sunlight vector and negate that and that's going to give us the proper light Vector um we've got render Shadows turned on and we now have our shadows coming out here usually you would put into the ambient occlusion value I don't have ambient occlusion set up properly so what we're going to do is just multiply the base color which is a little bit dodgy but it'll kind of show you what this actually does so you can see that this is some fake cast Shadows uh so if this like does this you can see that this is actually casting a shadow you know in the appropriate Direction and we're just kind of multiplying that into the base color again you could put it in the ambient occlusion so that if you got a point light and just sha the point light on here it would actually get rid of the Shadows uh and everything would be all gra valicious let's just see how this looks with a few other texture examples I've got like a bunch of ones that I've you know set up for my project that looks pretty dope it's a little bit shimmery H spicy more [Music] rock very beautiful okay so you can see in this case it kind of falls apart and in this scenario we'd want to take the height ratio and just tune it down a little bit 0.05 and that will just squish it down so the kind of tearing is less noticeable [Music] Cobblestone oh wow that's spicy so if we just compare this result here to just bump offset which is it it's it's a lot more subtle uh keep in mind it is like orders of magnitude cheaper than Parallax occlusion mapping but obviously Parallax occlusion mapping will give a better you know visual result result for what it's trying to achieve so if you need just like a tiny bit like a very subtle effect I'd go for bump offset but if you really need something with like extremely small detail to have that kind of parallaxing effect then parallx occlusion mapping is probably the way to go now paralex occlusion mapping can kind of Be obsti by nanite dis placement provided that nanite displacement is actually any good uh you know at the time that you're watching this video the benefit of tessellation is that you'd actually get the silhouette of the shape um like against you know if I looked at this like dead on here we'd actually see the bumps of the stones altering the silhouette of the object now obviously that isn't the case with parallx occlusion mapping although you can do that with the pixel depth offset uh only for things that are intersecting the original geometry of the uh of the mesh so I hope you enjoyed our quick little introduction to paralax occlusion mapping uh we basically just covered how to use the inbuilt function we didn't really go into how it works because it's sort of just black magic and even if I wanted to explain it uh it would take a million years and there's probably a bunch of other videos about it on YouTube I think like Ace roller has a a video about pom like from scratch so if you're interested in that go check it out on YouTube somewhere but as for our own video uh it's finished so if you did like it make sure you've liked and subscribed stay up to date with more 5 minute materials videos if you do want to support monetarily you can do so for as little as $1 per month through the patreon which is linked below or you can purchase my Prisma Escape interaction plugin Extravaganza on the Unreal Engine Marketplace or Gum Road and with that we say goodbye goodbye [Music]
Info
Channel: PrismaticaDev
Views: 6,586
Rating: undefined out of 5
Keywords: unreal engine, ue5, ue4, 5 minute materials, ue5 pom, ue5 pom decals, ue5 parallax, ue5 bumpoffset, ue5 parallax occlusion, ue5 tesselation, ue5 shaders, ue5 materials, ue5 pom material, ue5 pom shader
Id: h0xytNFiqbQ
Channel Id: undefined
Length: 15min 20sec (920 seconds)
Published: Fri Jun 21 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.