UE4 - Tutorial - Gem Material (Request)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys and gals welcome to a new tutorial in this video we are going to be going over a nice gem shader this was requested we're gonna go through a couple of different ways to do this mostly just because these right here shader wise are going to be quite expensive we'll go through that a little bit later on I'll tell you why they're going to be expensive and how we can fix some of that the models have been downloaded from free 3d comm I'm gonna leave the link to these models in the description so you can follow along obviously if you want to use your models that's perfectly fine but I'm using these just as my set standard for now so what I'm gonna do is get rid of this guy goodbye OOP there we go now they're gonna appear broken but that's fine I don't need them serve a specific way for now so what do we need to do we're gonna right click new material we're gonna call this gem underscore 10 now what I'm gonna do is I'm just gonna quickly apply this to all of these guys there we go now oh well that's free compiling the shaders we're gonna head in here and the first thing we're gonna do before we touch anything is a run blend mode changes to translucent scroll down a little ways and we're going to change this to surface translucency volume this is really only if you want to use things like normals obviously if you're going to have some sort of scratches on the sub on the surface or in the subsurface then you're gonna need this enabled so that you can use the normals pin okay so what we're gonna do hold one and left click for a constant we're going to put this into both the base color and the metallic and we're going to set this to one hold one left click again leave this is zero and put this into roughness so this is going to be completely smooth hold one or left click once more plug this into the opacity we're going to set this to 0.5 to begin now what we need to do is we need to actually make our refraction right click get your for an L hold L on the keyboard and left-click for allert now we're going to do is plug D for an L into the Alpha hold one on left click for a constant plug this into the a set this to one and get us another constant put this into the B we're going to set this to the documentation recommended two point two for two for diamonds and other such crystally things where they're going to plug this into the refraction well this is going to do is it's going to look at areas of angle change based on our for an L and then it's going to look between basic refraction of nothing at all it's a quite a large amount of refraction we're going to get half of pasady so this is going to be half see-through it's gonna be really shiny and it's base color is just going to be white so it's going to be a zero as we can get we're going to apply this and we're just gonna wait for our computer to catch up I am building a new PC I'm ordering all the parts it's one thing good thing about having a job right now is that I can finally build a monster machine okay now this is gonna compile a shade it now this is gonna be quite an expensive shader and at the moment we're not even going as expensive as we can with it so let's see come on you devil it's on its way it's on its way for now we'll get ready for the next one well right click add gem material and we'll duplicate this guy and we'll just call this gem to underscore M and now we can pile them more shaders great there we are so you can see now we've got this it's basic crystal you can see the reflection the refractions working really nice here you can see this on the stairs and here on this little question mark that spins and especially on the type on the floor now you'll notice this is different from how it looked when I showed you at the beginning that's because this isn't as expensive as we can go as I say you'll notice here the top is missing from this gem the reason being just because the the face is it's got an inverted normal on this one on this gym and you know it's free download I'm not going to go ahead and fix that thing because I can't be bothered so what we're gonna do is we'll open this back up and we're gonna tick 2-sided and this is gonna allow it to render from both sides that will fix the hole in that gem so we'll get both sides of that render through and it will also render both sides of everywhere else on the gym so now when we're looking through it the first thing we're going to see is the other side of the gym the reason this is going to get expensive for us is because of the z-buffer so the sidebar throw or depth buffer buffer is basically the engines way of drawing an object so you can see here we've got the gems and behind it we've got the stairs now what the depth or Zed buffer does is it looks at where all the verts are in the world takes the closest to us and doesn't draw the ones behind so right now even though we've got some of the stairs rendering the whole stair object isn't rendering okay it's decided you know we don't we don't need to draw this piece of that so it's not drawing it the problem with the translucent material is that we're still rendering it through the material itself so what it's doing is it's looking from the very furthest away that it can see drawing drawing drawing drawing and then it gets the hang of it is are they is this is transparent so what it needs to do then is draw the transparency last the reason it's got to draw the transparency last is because the transparency is gonna change what's behind it see that we're getting the changes and that's in both color refraction shadow lighting all sorts of things like that you see these are really really nice but if we were to click on our little lighting mode View mode from lit head to optimization view modes and get to shader complexity these things is gonna be really gross so green is nice green is really nice going into the brown you can see here down at the bottom where we've got this PS MVS going into the brown we're starting to get a little bit expensive the reason that's expensive on the floor is because this is a plane that's got opacity on it so that's not getting drawn but that's that's not too much finishing here we have red because it's doing transparency and if we stack these together we start to get pink and white white is really bad you don't want white you can see here we've got PS right up the end here you don't want that okay having one of these on screen at a time so if these are gonna be like a hero object one is gonna be fine but if you start getting loads so they're like your main pick up it's gonna run really badly you don't want that it shows respect in it so what can we do well we can lower the complexity by turning off two-sided but we don't really want to turn off suicided cuz you're gonna lose a lot of its depth so for higher end machines you don't need to really worry about that but one thing we can do is we can try and fake it a little bit so if we open up gem 2 which is the little copy that we've made we're gonna take everything that we've plugged into a refraction we're gonna get rid of that we don't want it opacity we don't want that either now with nothing selected blend modes going back to a baked and what we're gonna do is we're gonna just kind of fake some surface reflection to make it look refracted then we're going to do that is we're going to search for well position now we need D D X and D D Y and I what we need from these is the cross product of both I'm just going to wait for this little ball to catch up and we're going to put this into the normal and watch what happens to our little preview you can see here now we get this cool mirror ball effect now the reason we're getting that is because it's gonna take each line where there would be a normal so every single face has got sets of normals in in every vert and every lie in every side well this is doing because it's basically taking those and drawing them regardless of smoothing groups so it's taking anything that should be smooth and breaking it down now we can kind of fake that with smoothing groups but sometimes even with no smoothing groups faces that are completely flat completely parallel to each other are still gonna look like they're smooth and that's just because their normals are facing the right the same way what this is gonna do it's regardless of the way they're facing it's gonna break them up a little bit so if we were to take one of our gems and pop this on there no it's not transparent but we get this kind of cool effects still are we getting this reflection that's kind of refract II but if we were to head into our optimization visualization for shader complexity you can see it's an it's an absolute well it's pretty much awesome as far as our runtimes going you see this this green area that's pretty much the best kind of green this guy's got pretty good but there's a gem now with the broken-down normals is actually far less complex than the ones that have got the transparency on oh it's gonna be a case of what your project needs I like them looking transparent but obviously the the complexity of going in there is gonna cause some issues depending on how your games are gonna run what its gonna like and you know everything else is getting rendered on screen so let's just mess around with these a little bit let's know we don't duplicate it let's delete that silly we're gonna do is we're gonna open this guy up it's gonna break off base color whole tree enough clicks for three constant plug this in right clicking convert to a parameter and we'll call it color klore and then we're going to do for this to white you know give them a little apply he says waiting for it to to catch up I really can't wait to build my new machine it's gonna have like quadruple the amount of RAM this guy's gone right out there we go we'll right-click it chrome material instance open that up hundred color we're now gonna give this a color I'm just gonna make it red you have a quick save we'll throw him on to the end Jim let that compile you'll be able to see how this is gonna work with a different color now obviously when you build the lighting on these things you're gonna get a slightly different look as well they're actually quite cool with the lighting built I believe that these guys have already got some built-in shadows which they did them earlier on there we go you can see how we've got a red here such a really nice color Azure some colors aren't going to look so fantastic obviously because this is the refraction index for a diamond which is it has less imperfections than things like rubies sapphires and emeralds so Reds some color song I'm gonna look quite as nice it's just the pure white they're still pretty nifty right so I hope some of you guys are going to find that useful it's quite a nice little shader thanks for watching see you guys next time
Info
Channel: Dean Ashford
Views: 22,540
Rating: undefined out of 5
Keywords: UE4, Unreal, Engine, Tutorial, Gem, Diamond, Crystal, Material, Transparent, Refraction, Optimisation, Game, Indie, Dev, Developer, Developement
Id: i4FEkbDK6m8
Channel Id: undefined
Length: 13min 14sec (794 seconds)
Published: Wed Jan 10 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.