Fixing Bad Grass Shadows in UE4! (READ DESCRIPTION FIRST)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] well hello welcome today i'm going to be teaching you how to make your grass not look like this if you're working with stylized grass chances are you're probably gonna want your grass to look like it's sort of one big blob like uh like the movies do like animated studio ghibli movies the grass is just one big sort of plane except where there are little details and stuff now a common trick that i've seen amongst the internet folks is to take a 3 vector put it into the normal make it a 0 0 1 which is upward facing and then to disable tangent space normals in here so we're going to go ahead and do that and you're going to find out that it just doesn't do what we want it to do right over here you can see the grass isn't blending with the landscape properly and over here you can see the grass also isn't blending with the landscape nicely and so you just got a bunch of issues that you know from from some angles looks perfect you know from here looks absolutely fine but as soon as you have slopes in your landscape and shadows being cast across those slopes like i have at sunset at the moment you start to run into issues like this whereas ideally you want your grass to look more like this don't you you want it to be smooth along the landscape and then where the shadows are cast on the landscape from this hill you want it to become shadowed basically um now this doesn't just apply to cell shaded or even stylized grass i think this is an issue among a lot of sort of grass styles and it's with one one weird trick doctors hate him so first thing we're gonna do is we're just gonna troubleshoot what's going on here so if we click this button up here we go to buffer visualization [Music] sorry i had a stroke buffer visualization and we're going to go to world normal click that everything looks like 70s disco and you can see straight away that the normals of the grass are not matching the normals of the landscape whatsoever all of their little faces are pointing out in the direction that the vertices actually face if we then go ahead and apply our you know non-tangent space normals that are facing up you can see there's still an issue the landscape is facing out this way like diagonally out this way but the grasses normals are all just pointing straight up into the stratosphere and while it can look all right from some angles it just isn't going to cut it for what we're trying to achieve so for context this is what this one looked like it was the one that was nice and flat but it was still not shading properly so if we go back and we get my grass you'll see that my grass looks like cotton candy the landscape underneath its normal is facing out diagonal and the grass matches that perfectly and as a result of that you know we get actual shadows on one side rather than that sort of mess that we had before so the first step to achieving this is going to be getting blender blend is a free 3d modeling program i'm sure that you probably have some experience with it if you don't this is going to be very comprehensive i'm going to take you through every step so you shouldn't really uh you shouldn't really get lost all right so we're in blender uh this is my grass mesh first thing we're going to do with our grass mesh we're going to copy it and we're gonna paste it and you're gonna think well that just did nothing but if you click it and move one then you've got a duplicate and we want them to both be overlaid perfectly on one another so when you've got them overlaid you're going to click it once which will select one of them then up here in the top left corner we're going to click edit mode bammy wham you're going to click the number 3 on your keyboard that's going to go to face select mode you're going to hit a then you're going to hit alt n and you're going to flip the normals bam if we actually go into this little tab here and go all the way down to this icon under the normals thing the second icon from the left hit that so this is the way that the normals are facing for each vertex of the mesh so next thing we're going to do now that we flip the normals is go back to object mode we're going to highlight select and just move it to make sure you've got both selected then we're going to hit control j and that's going to join them both together so they become the one mesh then we're going to go back into edit mode so we're gonna hit a to select all faces then we're gonna go alt n and we're gonna click point to target and then just click anywhere after that now you can see all of our normals are facing straight into where we click where you clicked is irrelevant because down here we are going to click this and we're going to set the zed to 1 billion or 1 million or maybe 1 trillion doesn't really matter now you can see all of our normals are facing straight up now um and the reason they're slanted is because my actual object has been rotated so i'm just going to rotate mine this way cool cool right they're facing up now they're facing straight up into the air this is exactly what we want and by duplicating the mesh we've actually created a double-sided mesh so the material when we put it back in unreal we don't want it to be a double-sided uh material to export it we're gonna go back into object mode up the top left we're gonna click on our on our mesh we're gonna go file export fbx and then we're gonna click mesh and selected objects only and then i'm gonna call this uh grass with double sided upwards facing normals.fbx we're gonna click export sick all right back into unreal fantastic so now the only thing you have to keep in mind with this is that when you go to your landscape grass type or maybe you're placing it manually with your foliage it needs to be set down here align to surface now this is important because what it's kind of going to do is um because this is our grass okay and the normals are pointing straight up right relative to the mesh so if our landscape looks like this and we've got some grass like this and then some grass is like this right it's gonna be it's gonna be sloped over its normals up here are gonna face like that and then over here they're gonna point out with the landscape perfectly with the landscape and that's why this will look a lot better than having the the forward-facing non-tangential normals so after you've imported your grass mesh in and you've placed it on the landscape aligned to the surface if you've done the no tangent normals thing get rid of that zero zero one normal value and having tangent space normals ticked or unticked doesn't actually matter at this point and basically your grass should now be behaving a lot better and blending with the landscape properly so one little issue that this brings up it might not be much of an issue for you but if you've ever looked at grass before which i have a few times that i've gone outside i've noticed that grass always grows upwards it doesn't actually grow outwards if it's on a slope so one thing that i actually did to combat this is in blender i actually made my grass a lot shorter i i scaled it down in the zed about like maybe a quarter of what it was before so it looks really short and stubby basically but the vertex paint is still the same and then in my actual grass material i apply a an upwards zed offset in the wheel position offset which basically just stretches the grass upwards so if we go back into paint for a sec so basically if this was our grass beforehand jutting out the side of the landscape you know like this um what is gonna become of it is that it will grow out and then because of the vertex paint it will slope upwards slightly and it will look a lot more natural so that's completely optional if you don't mind your grass being diagonal um then this isn't an issue at all for you uh it might not even be noticeable depending on the style of your grass you're probably thinking charlie why did i need to duplicate the mesh in blender and flip the normals of one of them um and i will show you what happens if you try and do this with a double-sided material instead of actually duplicating the faces of the mesh this is white grass um but you can see even though it's completely white there are these huge dark ugly you know patches that just don't don't really play nice with the uh with the overall look that we're going for and if we jump into our world normal mode you can see that the the back faces of the mesh are like like the opposite color of the front side of the mesh so the landscape here is that nice cyan blue and the front sides of the mesh are also nice cyan blue but the back sides of the grass mesh are like the complete opposite color and you can see the same thing over here we get we get purple and green and and uh i don't even want to think about what those colors are if you make a double-sided material the normal is always the opposite of you know the other side naturally so that's why we had to duplicate the mesh and have both sides pointing upwards so that it would look nice now i'm not actually sure if a double-sided material like internally is extra vertices or if it's just another weird way of you know engines rendering double-sided faces and whatnot so this might not actually be much more expensive than a double-sided material and modern graphics hardware is like extremely extremely good at rendering more vertices as opposed to more textures and stuff and more complex shaders and whatnot vertices are basically a walk in the park which is why i can have you know millions and millions of verts on screen all at once and i'm still getting you know 120 fps now there is one little other idea that i had and it might be cheaper but at the same time i think it might not be it might depend on the actual render distance of your grass and that idea was to get a runtime virtual texture of the landscape normal and then use that in the normal slot of the grass and have non-tangent normals and blah blah blah and that way it would basically be copying the landscapes normal and applying that to the grass so you know on this point it's blue on this point it's purple and the grass would match that perfectly and it would probably look the exact same and that way you wouldn't have the the diagonal grass problem but you'd also be using another runtime virtual texture and rendering another texture in your grass material which might not scale as well as this but you know that's all theoretical for now i haven't actually tried it myself it was just a little a little thought that i had in the shower all right so now we're back with our newly found beautiful normal world landscape aligned grass normals it's a lot nicer and i hope that this has you know fixed some issues for you if your grass wasn't blending very well one little extra thing to note is that if you're using grass cards so flat plains with a mask texture on it in blender you'll have to flip the uv's of the other side horizontally so that you know if the grass looks like this then usually from the other side it would then look like this which isn't what you want you want it to look like this so that's just a little consideration to keep in mind as always if you need any help with unreal especially anything in my tutorials you can join our discord which is in the schneebleb it's full of super super lovely people we have some like professionals in there and a lot of indie devs as well mostly focused on unreal engine but we do have a lot of blender gurus in there as well so if you need a hand with anything or you want to share some of your own knowledge and your own progress on your projects um pop in say hello introduce yourself everyone is super super friendly and very enthusiastic about solving your problems so yeah do that if you want to find any more you know little tips and tricks and snippets like that feel free to watch my devlog videos i actually do a lot of less in-depth stuff but there's more more that i cover and i also stream on twitch uh most days of the week developing my game and you know if you have any questions that you want answered in real time um with some visual explanations then just drop into the stream chuck some questions at me i'll answer them while i do my work and with that i say goodbye bye see ya [Music] bye [Music] you
Info
Channel: PrismaticaDev
Views: 43,145
Rating: undefined out of 5
Keywords: ue4, unreal engine, materials, indie dev, game dev, game development tutorial, game development tutorial for beginners, video games, game art tutorial, unreal engine 4, editing normals in blender, flip normals unreal engine 4, unreal engine grass foliage, unreal engine grass texture, unreal engine grass shader, ue4 grass tutorial, ue4 grass material, ue4 grass shadows, ue4 bad grass shadows, ue4 grass, ue4 tangent space normal, ue4 stylized grass tutorial, ue4 grass tips
Id: U94pwpZQsRY
Channel Id: undefined
Length: 15min 11sec (911 seconds)
Published: Fri Jan 29 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.