Baking Materials to Textures | Live Training | Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
it wasn't right we have a Zoidberg here to help us out Thank You Herbert thank you Oh technical errors y not zoidberg y not zoidberg okay so oh so hang on we sure please start all over since everything got bashed uh repeatedly hi girl hi everybody and welcome back to the Unreal Engine training stream I'm your host Alexander Pascal and joining me today Sam dieter hi everybody we're gonna be talking about baking materials - textures for optimizing your game so now that we've done that oh yes so I was working on something for gear vr I'm doing some optimization stuff and Alex came to us and was like look we need somebody for a livestream I'm like hey I kind of cannibalizing some tools and using them in some interesting ways and that's kind of how today's talk came about I asked he had something um some of the stuff that I am talking about today I did come some of that inspiration I pulled from the great in influential Ryan Brooks some of the the last example I'm going to show you guys today is the most complex I'll go super simple intermediate and then kind of complex and that one builds upon Ryan's blueprint and render targets stuff which you can find but coming here to going view options show engine content and if we click on engine content we go down to art tools render to texture right here you can have all the glue pits oh yeah thanks we turn up we go back there you go okay so let me just go ahead and do this again really quick so to go ahead and see the tools that Ryan built you can come here to view options you go show engine content and we're going to scroll down here to an engine content will be collapsed for you so engine content art tools and down here into blueprints and these are the three blueprints that you'll use and there's some documentation on the web as well oh yeah those links that you gave me yeah I got actually one of them here hold on let me pop this in the browser really quick and I'll just pull over the so the render to texture blueprint tool sets um this some of this stuff is way easier to do with render targets and blueprints now but this is still very very useful and like I said I used a lot of this there's some inspiration on ways to bake some things out when I ran into some problems of stuff not baking correctly the other thing that I wanted to share with you everybody today is this right here which is the NVIDIA texture tools for Photoshop what this allows you to do is it allows you to create normal maps inside Photoshop and we're going to use this when we export one of the normal maps out we're going to need to recompress it and actually renormalize it so that when we import it back into unreal it shows up like a proper normal map and finally I actually uploaded this entire project to box yeah and so if we go to this link right here you can download this project it uses 4:16 it's just the realistic rendering example um no I am linking these into Chet and they will also will have links to these in in the description of the YouTube or calf but just as a note sometimes box gets overwhelmed so I might also like archive it somewhere else and post a link to that archive okay so if you are all watching this live and you all rush in because I just posted those links note you might accidentally step on each other's toes and box won't let you all grab it at once okay just drag in a little bit good to know so let's go ahead and now that we got the shout outs out of the way and some of the tools that we've been using let's go ahead and get started with creating textures from material so overall why would we want to do this well the main reason we'd want to do something like this is let's look at this desk lamp and we see this desk lamp has two materials on it has something for and I'm in I'm in an unlit here that's why you're not seeing any reflections but basically there's a material a metallic material for the base here and then there's another material for the shade now two materials that's not so bad but if you had you know ten of these lamps in the scene each one of those having two material IDs that's going to add up to be a lot of rendering this required just to draw this stuff to the screen now what would be better obviously is to have one mesh with one texture with one material so it just makes one draw call for that object because it's super cheap and you're getting it at a fixed cost because you have effectively taken any complex shader math you've done and you've cast it aside you've baked it into that texture and now it's all there for you to use so a couple caveats before we move a little bit further if you're doing something like crazy world position offset or you're doing like animation or stuff like that it's not really going to work in looking this like dynamic in the move around this will be really good for say you make a really complex weapon and when you're modeling it's a lot easier to just assign a texture to a bunch of polygons groups and maybe you plane or map that and it's not in the 0 to 1 space and it's just a little easier to build depending on your workflow some people go straight up you v's and they just you know flatten everything some people like to just you know dump a material on a poly like but what this method allows you to do is no matter which way you do that using this method you can actually just bake everything out to a texture and you will get everything back in now you're going to get a few precision errors because you're if you're especially if you're using like a masking style system where you have a mask and then you have a texture that you're repeating Li tiled you're just going to have better fidelity with that but if you're doing a mobile project or a console project or you're trying to bake something down maybe for your L o DS you're going to do a different material for your LEDs or something like that or you're ok with a little bit of a drop in fidelity this method will save you tons of time doing stuff because you're not going to have to do it and Max or Oh Maya and Photoshop you can do everything inside unreal with everything that I'm showing you and this is the cool part is that it's all done in engine so let's go ahead and get started the first one we're going to talk about is the merge actor tool now normally with the merge actor tool you grab a bunch of different meshes you merge them all together and what that's going to do is it's going to take every single mesh it's going to lay out its UVs and a 0 to 1 UV space and then it's basically make a texture Atlas so it's going to put the base color roughness and normal for one object and then the second object third object so on and so forth but one of the cool things you can do is you can actually use the merge merge actor tool to just merge this object for example we're going to merge these two material IDs so these two draw calls we're going to merge them down into one draw call so let's go ahead and take a look at how we're going to do that so to access this tool we come up here to window developer tools and merge actors so here's the merge actor tool first thing we were going to do here is we're going to set to use a specific LOD level and what that's going to do is that's going to allow us to now adjust our material settings because if we don't do this all it's basically going to do is just merge it's going to merge everything together but it's going to give you this monolithic static mesh like 20 material IDs and so one material ID for how many things that you want that's the things pretty bad practice I don't know I mean I don't know maybe you want it if you're exporting a level or something who knows there might be a way that you want to use that but for our purposes we're going to want to go ahead and kick this down to specific LOD level right now we're just going to capture it at LOD zero to make sure we get the highest version of the mesh then we're going to go merge materials I'm going to kick my merge material settings down right here our texture size 1024 by 1024 this is going to be the size of our ending Atlas so how big it is I'm going to keep it to 24 by 1024 for now because the larger I make it the longer it's going to take to compile and we're just going to have to sit here because there's nothing I can do with the editor while this is baking out actually and since we're live that might take us a call.we gonna kick that down to 256 by 256 just to be on the safe side a little bit and I actually you know as a true live show cooking show style I actually have this pre-made and a - it's beautiful like the full turkey out of the oven like haha and this is the complete turkey so what I'm doing now is a normal maps and metallic map or roughness map so basically I am telling this tool which Maps I want it to generate once I click the merge actors button so I know that I want a normal map I know what a metallic map and I know I want a roughness map I'm not going to use a specular because I want to create as few textures as possible because I want this to be as small as possible I'm going to leave the blend mode here at opaque I'm going to leave use vertex data for baking materials enabled that's just basically if you're using vertex colors or something it's going to transfer it over finally this use texture bidding I'm not going to use this but this will basically scale stuff down according to how relative if it is or how important it is um with this feature I usually do something like I'll do 256 by 256 I'll turn it on I'll see if it gives me what I want I'll turn it off I'll bake it again um it's just kind of one of those things that you have to kind of test with a little bit to see if it's going to give you these settings that you want it's more of an art than a science I see a little bit a little bit so finally we're gonna click dart I was going to say actually Clint can you drop us from the from the thing here because technically we're covering up that button no no no show just the main screen I meant ah yeah full screen full screen main screen because there we go yeah because the button was underneath the picture so now what we're going to do is we have everything set I'm going to click on merge actors now I'm going to have to give this a location so I'm just going to come up here a new folder and I'm just going to click Save and my new folder there we go and so this is going to go through and again I went relatively quickly because it's only 256 by 256 but if I open this guy up you see he's only one material let me go ahead and I will pull him into the level and let me just zero out his transform really quick zero and let's just hold down shift and we'll move over so we move our camera it was really far away I thought it was scaled down a lot now it's just it's there's nothing in there I see but so now we can see that I have so if I click on this one I have two materials I click on this guy just have one material so this is really really really powerful tool to use um and you're not actually doing anything different with the tool other than instead of selecting maybe 15 or 16 meshes at once in doing this I'm just selecting one so this is really good if you're at that point in your game where you're trying to optimize everything that you can in order to hit your target frame rate and you see a bunch of meshes that have two materials three materials on them this is a great way to optimize all of that stuff very very quickly and then non-destructively as well because this mesh right here that it created is actually a copy of the other mesh that is actually copy of this mesh right here so I'm not actually losing any data I'm just generating another mesh now while it does add another mesh to your project if you happen to screw it up or you want to revert or something like that you can always go backwards and that's awesome because again that's non-destructive to your workflow it's non-destructive to your pipeline which is a good thing so the next one that I want to talk to you guys about the merge actor tool is using blueprints and render targets so in this guy here let me go ahead and we're going to go to blueprints and render targets and double click on this level we're not going to save anything so um what I'm going to do is basically see this coffee table right here and if I come to his main material and let me just open this guy up and zoom out you can see right here we're using so this mask material we're using this texture two three four five so we're using oh I guess I could have done that by turning on the stats and showing them down here in the window actually using eight out of our 16 available texture sampler so on mobile this would be a very expensive shader to use right we wouldn't necessarily be able to do this and if we look at this what this is really doing is it's using a lot of masking you know based off this texture right here which I think this guy's like 2k or something like that the the size of this mask right here and while but if we look at the coffee table let me pull him into the scene and just hit F to focus in on him I mean there's not a lot going on with this coffee table right it's just it's got a super super super high fidelity wood on it and that's because if we look back over here in the material we're actually scaling the UVs to give us that super awesome fidelity but what if we could take this in this final material that we have here and just again bake all of this down to a material so that we have all of this stuff at a fixed cost and we can do that using a blueprint and a render target so what we would do first I'm going to delete this guy I'm just going to right click I'm going to create a blueprint class based off of actor I will just call this VP underscore render target okay and the next thing I need to do is right click in here go to materials and textures and we are going to create a render target we just call this arty texture Baker having problems coming up with names on the fly for some reason so and this guy's popped over here I just called them all bill John you know just to be really confusing with my name in convention so the first thing that we're going to do is we're going to come over here we're actually delete everything from our event graph I'm going to come here we're going to make a custom event so and we're going to call our custom event bake and then off of bake we're going to do a draw material to render target okay and then what we're going to do is we're going to pull off this guy and we're going to promote to a variable and we're going to pull off this guy and we will promote to variable as well let's compile and then we'll come down here we'll just rename these really quick we'll call this one render render target I'll call this one material to render okay I move these guys down so we can see what they look like press compile now over in our construction script what we're going to do is we're actually going to want to call our bake function here and what this is going to do is basically when we move this guy around oh and the last thing I want to do what this is going to do is sorry I get jumping ahead of myself here in my head what this is going to do is each time we move this thing around in the level it's going to update the render target so that we can then right-click on the material the render target and save that as a static texture and I'll show you that in just a second but first I want to come down here and I want to make these guys public so that I can go ahead and actually change them in the level so I don't have to keep coming back to the blueprint supplying the material that I want to bake and doing all that because that workflow can be a little cumbersome we should it's a Maitre to renderer material to render ah yeah material so I just figure you're gonna be typing that in like wait that's not right material to render typos are the funnest kind of snow in tech there're no global spelling checks so what I'm gonna do is I'm gonna drop this guy in the world and I'm just going to zero him out and I'll hit F to focus in on it and i actually have my other one there so let me delete that really quick so first i'm going to take my render target i'm going to drop my render target up here now for our coffee table if we look at this guy and I go ahead and notice he has this very dark like dark red stain on the coffee table but if we look at the actual coffee table and pulls back up around the screen you notice it's not as dark well that's because inside the material instance right here they've set a bunch of different things up no this is something kind of cool that I found out you can do and I didn't know you could do this what we can do here is I can actually grab this material to render I can pull this material instance on it and then you'll see why this is cool in a second so before I didn't realize material instances could go on there because I'm calling material that's what I used I used a material node inside the blueprint that's why I was a little confused when this started to work but it kind of makes sense so what I'm going to do now is I'm going to come in here and in order for this to work I have to turn the material that I want to render to the material target I have to turn it unlit and then I have to pass each one of the inputs to the emissive Channel so what I can do is I'm going to come here and I'm going to go oops under my shading model and we're going to click on unlit I'm just going to click apply really quick I'm going to come all the way up here to this input which was my base color and I'm going to right-click on him and we're going to go to the emissive color and I'm going to apply that guy so now what should happen is when I move this you can see my texture baker updated so I'm going to right click and let's just double check really quick how big it is so 256 by 256 let's go we'll bump it up to 512 by 512 to give us a little bit of extra fidelity but again I don't want to go ridiculously high because I don't want any crash to take place so let's go ahead and move this guy one more time so now it updated so I'm going to right-click on a create a static texture and if I come over here and we disable the alpha you can see now I have my base color so that's all the inputs for my base color right so let's go back to my coffee table and we will go to what's going into my metallic so we'll right-click on this will connect to a missive color I'll click apply again let me just move this out of the way drag him over right click create static texture and I will bring this back on screen for you guys there we go there's my metallic man I just switched over to alpha and now you can see it so the last and then we will do let's see here where's my so we'll connect this over to miss of color that's my roughness and we'll close this guy move this over and right-click create static texture so in the little jostle is an important thing to do right yeah the jostles basically that's updating that's changing the data that's inside the render target without me actually having to play the game or doing anything like that so again you can see there's my roughness and then finally the coffee table is a little bit of an interesting one there's actually no information inside of the normal map the normal map isn't being augmented say by a detail normal or by some other parameters so for this one you actually wouldn't need to render out another normal map but just to show you guys that you can actually get everything out of here we're going to go ahead and click on this so we put the normal map into the emissive I JA cyl this thing around right-click create static texture and if I bring this back over and I click alpha channel you can see I have my alpha or my normal map here now one thing I want to bring up about the normal Maps all of these textures um I actually should have converted all of them and I messed one thing up here I forgot to turn on on my du to do my render target where's yet yeah this guy right here whoops I forgot to enable no HDR is enabled that is one thing it's very important because HDR is going to give you a little bit more fidelity than the standard texture output like outputting to PNG or something but so if I come here and I export this guy out so we go Asset actions export and hopefully it will do it there we go I was a close one I was a little scared we're going to go ahead and save the reason that I'm doing this what I'm going to do is I'm going to take this photo and take this texture into Photoshop convert it to 8-bit and then bring it back in the reason that I'm doing this is if I try to convert this texture that it output the normals either are too steep or they're not steep enough I don't know what is going on internally inside of unreal but just doing this little bit of an extra step will make it so that all these textures are the proper format but they'll also work with the streaming system and all that other stuff so you're not losing anything although it introduces a little bit more work what I'm about to show you is super simple to do so now that we've exported it let's go ahead and pull up Photoshop so we'll do a file we'll do an open we're going to go to our desktop and let's see where is our there's our texture so you can see I'm opening up an HDR texture so what I'm going to do here first I'm just going to go to image mode I'm going to change this to 8-bit and right here for our method I'm just going to go exposure and gamma I'm going to hit OK and you see I have the exact same color space that I had before okay so I'm not a you know my texture didn't change the information didn't change now if I hit ctrl shift s on the keyboard you can see I can say this is a PNG or a TGA and then when I reinforce this it'll come back in now let me go ahead and jump into my finished folder here and let me actually do one other things sorry let me pull the coffee table back out and we will 0 0 0 so come here to the coffee table and I go to my finish because you can see my finished one here I have them at 2048 by 2048 so you can see they're very very high res and if I go ahead and pull this material on here and let that guy compile really quick and let me just pull another copy over and we will go back up to this guy pull him back over the screen so what we're going to do now is we're going to come to the emissive we're going to disconnect it and then we're going to come here and we're going to say default lit and click apply and voila you can see basically this is our baked one this is our unbaked one and you can see there's almost no difference in between the two of them and again I'm looking at them unlit but I'd do this anyway just to show you guys that there's all very very very little difference between the two of them in fact like look at the fidelity right here okay and this is our baked one and we can check out the same fidelity over there it's almost identical yeah so again super duper ooper powerful way to optimize stuff even though you have to introduce a little bit of photoshop this method will still allow you to optimize your level and have full control over the optimization so it's on which the ones that I use the one that I'm about to show you now is the one that's based off of Ryan Brooks and this is using a much more complicated blueprint it's using the high resolution screen Strout tool to capture but the reason I had to use this one was and the realistic rendering example we have a bunch of books on the bookshelf well those books are colored by the position and the rotation of their world of their placement in the world it's very true if you give them physics and throw them all over they start flashing different colors I found out so little seizure causing books yes basically so when I went to go bake them out they were all turning black and I'm like well how do I do this how do i how am i able to capture this it I can't rotate it because the rotation isn't taken to account and either of the methods that I just shared with you rotation doesn't matter so this last method what it's basically going to do is it is literally going to flatten two meshes UVs and then we are going to do a play in editor and we are actually going to make our window 512 by 512 we will high-res screenshot times whatever multiplier we want so times 2 would give us 1024 by 1024 times 4 would give us a 2048 by 2048 and so on that will output to a folder or saved folder like we do with a screenshot and then we'll be able to bring that information inside a Photoshop convert it to 8-bit and then import it into unreal that is some interesting trickery that yes and like I said this is all thanks to Ryan I was he mentioned something to me about flattening out meshes and [Music] I just I was on the way home in my car I have like a hour drive home and I was how can I do this how can I do this I'm like wait if I rotate it and then I flatten it it'll still retain the same color and so that's kind of how I got there so go ahead and look at that do we have a question someone was wondering if the materials on both of those were actually can you click on one and then click on the other they have the same material oh do they have you same material no wonder it looks a similar yeah I hold on one second Darrell see here um good catch Lucas thought they had the same one let's see here oh so there's that one yeah see like I said they're very similar though you'll see uh yeah that's the that's the actual parent so so yeah it definitely changed all right cool yeah let's just double check just one more time on paranoid now I didn't want you guys to think that I'm some okay does it just look really that similar yeah and they look the probably the beginning of the name is so similar yeah so there we go there's that one and there is this one over here so yeah they do look very very similar so there's almost no difference in this one um but that was a good catch that was a good catch furball took me but I just want to make sure you guys know that there is no trickery in there and you can download this project and check it out for yourselves as well yes I'll put the link up again in the check because we have some new people around so let's go ahead and open up the flattened example so here's my book and as you can see like as I rotate it around you see it's going to change color so this one what we've got here is I have this flattened pond so if I come here to my window and we're going to go to my world settings actually no I'm going to do this another way I'm gonna take my pond which I should actually already have it in the world right here and we're going to make sure that auto possess is set to player zero okay so basically when I spawn into the world I'm automatically going to possess this pond because we are going to be taking a screenshot you can actually see this right here well what our pond is right here so this books you v's are going to be unfolded and then mapped out into this little plane right here and we're actually going to take a screenshot of this plane and to do that the first thing that we need to do is we need to come up here to our material let me go ahead and close this down and close this down and I've included this but basically there's this material function called on unwrap UVs for render okay and it it's this material function right here I just took it out and paste it into my graph and added the little static switch so I could use it inside material functions if I wanted to or not and what this is simply going to do is I can just I can show you right here whoops need to add an actual one there oh I am NOT firing on all cylinders day I need to actually enable it so let me find my book mesh really quick so I'm going to select the book mesh in the content browser and when we get back there we go so this is what this material function is doing so basically it has taken my book and it has just flattened out the UVs and made it so that I can see everything on it right it's not ridiculously complicated what I'm going to do next though is a little a little involves a little bit of trickery so I'm going to go ahead and hit cancel and I'm going to set this guy back to false because I don't always want him unwrapped I'm gonna go ahead and close this and on this guy should have this material instance here yep and I'm going to enable the flatten on my material instance okay and this is the same material that comes from the actual book mesh itself I just made a copy over here in the folder so that I wouldn't be affecting anything else so here's our material or here's our object that we want to capture let me go ahead and hit control X really quick now if I hit play right now you're not you see you're not seeing anything see I'm controlling it I don't I what I really want is I want my viewport to look something kind of like this where I have the book there and then I can do something like you know alt printscreen or the high-res screenshot but obviously there's a couple problems right now like it's it's offset it's rotated a little bit to the left and also it's not as big as the UV sheet itself so no matter what I try to take right now this is going to be offset and it's not going to match up so how do we go about and doing that well if I hit ctrl-v and I put the my player back-end let me go ahead and hit play now if I hit f2 to bring it in on lit you can see there is my entire book inside of a 512 by 512 window so if I was to go high-res screenshot times 2 this is going to output me a base color a roughness a specular metallic a normal a world normal map which I'll show you how to convert inside a Photoshop um it's basically going to take all this stuff for me but so how did I get that how did I get from not being able to actually from being able to control this window to having this window perfectly line up with everything well that's inside of the blueprint so first off what I did is I right clicked I made a new blueprint class that's based off of pawn then inside the blueprint I added a scene and I added a camera and go over to my viewport really quick so you can see where they are where's my camera come here camera where are you there we go with my camera I moved it up about 3500 units and in the air and then I said it's rotation to 90 and negative 90 so that it's basically facing down because I want to be able to capture what I'm looking at the next thing I did is over here in the camera settings we changes to orthographic we changed the ortho width and we constrained the aspect ratio to 1 again a lot of this stuff I was triumphing around with it and then I looked into Ryan's render target blueprint and I saw some of the stuff that was similar so I started just kind of taking apart what he did at a very very low level and just got got the simplest thing working and then added a little bit more and a little bit more and a little bit more until I have what you guys see right now so um you know it wasn't just all of a sudden everything started just kind of coming together it started with me figuring out how to get stuff to flatten and then after that okay now that I've gotten to flatten how do i how do I capture this so the next thing that you need to do is add another variable called sheet size i'ma I set it to a thousand you might be tempted to set this to like 1024 by 1024 you know if you want to take a large scale or 512 by 512 if you do that though you end up cutting off a few pixels on the left and the right so you want to make it slightly smaller than the dimension that you want to actually capture I haven't seen any issues with it missing pixels or anything like that but there could be an instance where it maybe breaks down like that but that's just something to be aware of inside the event graph only thing that we're doing here is we have this to execute console commands one our buffer visualization dump frames one and our busier our buffer visualization dump frames as HD are basically this is telling the high resolution screen shot command that we want to dump out the the roughness all of the layers of the G buffer and we want to dump those out is HDR format photos inside of our construction script what we're doing here is we are going to offset the cameras location by the size of the sheet okay and what this is going to do is when we change our sheet size here it's just always going to make sure that our camera has a proper distance between what we're trying to capture so that we don't miss any detail okay the last thing that we need to do and this is super super important is we need to come up here and of course I've already done this so this will be set up for you if you download the project but if you start out on brand new project you're going to have to do this so you come here to go to edit you go to editor preferences and inside of your play you're going to want to set your new window to something that's a power of two so 512 by 512 or 1024 by 1024 okay once all of that is done we go ahead and click Play I'm just going to go ahead and hit the console that the back tick key or the tilde key to open up the console I'm going to hit up on the keyboard to populate my previous command and I'm going to hit enter and it's going to take a second here to render off all of that stuff and you can see it went to Alex's desktop and we have all of somebody let me move this over and pull up in Photoshop here really quick and [Music] open that is transparency and you can see I have my base color here I've got oh wait I think that might be my old one maybe I don't know nope that's the same one okay I have a basic color here I've got let's see I got the world normal the world normal is one that looks a little funny right so like like how can I get information out of this guy what can I do to fix this well there's a couple different ways to fix this first we come up here to our image and no matter what we do we're always going to have to come up here to image we go to mode we go to mode and then we come here to 8 bits I'm going to click don't merge because this is going to keep all the gamma and luminosity information the same then I'm going to come up here to my filters and my Nvidia tools and my normal map filter I'm going to go ahead and set the height field to 1.0 and the Alpha so what this is basically doing is you see if I have this set the unchanged or what height right here basically there's no information here it's just transparent and I don't want that that means I'm going to have transparent background if I set this to 1.0 it's basically going to fill in the back layer for me just with a flat normal color value the next thing I want to do is I'm just going to go ahead and hit max RGB and I'm going to hit OK I'm going to do this one more time I'm going to go filter I'm going to go in video normal map filter and what I'm going to do is I'm going to hit and normalize and press ok and this is just so what I did is I took that world space normal map I converted it and then I renormalized it to make sure that I put everything back together between negative 1 and 1 ok mmm so that's it that's normal map conversion now with this guy get hit ctrl shift s on my keyboard and as you can see I can save him as a PNG or a Targa whatever you know format you happen to use in your project let me go ahead and pull out another one so let's go ahead and pull out here we go pull out the roughness and another interesting note I've just found out is that a few people were asking in chat about a free version because a people don't all have Photoshop and if you're familiar with like art tools actually has an extension that mimics okay in video clone yes video you could also do this in substance designer you could do it in painter you could do it in I just I don't know I was thinking about actually trying to figure it out for for this top foot I use it all but I didn't have I just I didn't have time some other stuff came up but what I want to show you about the roughness here is you notice that I have it in EXR so I had to do all that stuff for the normal map for the roughness texture all I literally have to do is come up here to my image go mode change it to 16-bit I'm not going to merge and now if I hit ctrl shift s you can see I can save it as all the other formats now what I can do is let me go ahead and we're going to find this guy's parent material and actually know my bad we're going to come to his material instance we're going to disable flatten and we'll zoom in on him now what I can do is if I hold down ctrl + alt and I move over and I can put this material book on there and you can see I have the exact same material on there what looks to be the exact same material and the book one this you know it was one material but the thing was I couldn't get this to capture because if I put this guy at 0 0 and 0 he's going to capture like that alright and I needed it to be I need to capture the various colors you know all of these colors and there's no way using the other two methods to actually capture this stuff because they're not taking world position offset into account and that's what's actually changing the color of this particular book see how we doing on time here I think we're doing ok yeah we've got to start a little bit late so I think good we can make up the time okay I remember what the other thing I wanted to talk to you guys about was so we've talked about there are three different ways to bake a material down so there is just using the merge actor tool which will allow us just very simply without having to do anything else merge a multiple material object into one material with one one set of textures we learned how to bake the data from a material to a render target to create a static texture out of that then we learned how to do something very similar to using the blend the blueprints and the render targets but this time we did something that took into account world position offset okay the last thing I want to share with you guys is something that's in a similar vein but not related to textures and materials at all and what I mean by that and a similar vein is that it is actually a way to use a tool that already exists and a completely different way so let's go ahead and hit ctrl e on the keyboard to open up the static mesh editor of this book and he's not as many Poly's as I want so I'm going to go ahead and we're going to look in a mesh really quick and let's see let's find something that's super high poly okay look at this plant this plant is pretty crazy stupid high poly okay so he's 8200 triangles so this is way way way way super high poly especially for a mobile game okay not so much for anything else but let's say we're using this for a mobile game so barring that it has three materials aside what if we wanted to reduce the just the base level on geometry on this so we wanted to take the base level of this from 8,000 triangles so we want to bring it down to 4,000 triangles now what we could do is we could take this mash we could come up here we could go edit or wait maybe actually my bad we can come here right-click on it asset actions export this guy out to 3d max then inside 3d max we could run pro optimizer on it or we could take it into ZBrush and decimated or there's a million different ways that we could take the Poly's out of this but the common theme among all of these is that we have to export this out of the engine through some third-party program and then bring it back into the engine wouldn't it be cool if we could just optimize it right here in the engine you can actually do that if we come here to LOD zero and we just come here to our build settings oops not our build settings or reduction settings I'm just going to set this down to 50 and click apply and now you can see I am at 4139 triangles you think okay well you know that's pretty cool but you know maybe I wanted to export it out well the cool thing about this is that say your art director comes by and he's like yeah you know that 50% reduction you might want to take that back to 75 okay done now I didn't have to do anything look it went up to 6,000 triangles I literally just took something that would take me about a five minute round-trip and I can do it in like 10 seconds 15 percent done well look and you can barely see the difference too because of the way it's triangulating good yeah it's really nice and it's I mean this reduction logarithm is so powerful that I do a lot of stuff a lot of the stuff that I did for the example project that I'm working on once I figured out that this is such a great logarithm for doing the reduction I just stopped exporting stuff out of out of unreal and just started reducing everything inside of here because again this is non-destructive so if I if I go show this to Kim and he's like dude everything is super low poly everything needs to come you know crank it all the way back up I can just come in here the meshes and Craig them back up and click apply and I've done something non-destructive right it's all about being able to save yourself time and energy and making sure that things are are not destructive and everything that I've shown you today is a non-destructive workflow to generate a new optimized version of an asset that you already have and that's super super powerful stuff yeah yeah I mean overall I think that if you apply like any of these techniques as applicable you're going to see a pretty big turnaround I don't think that we've got like just because we're working with such a small like one object here one up there if I turn on your GPU like visualizer you're not really going to notice a difference at this rate but a couple of people are asking about like if I have a whole forest of things I guess that's more instancing I guess well okay so here's here's the problem I'm on a phone for example you know a phone uses a tile GPU um I don't yeah we don't have that we needed to flip cameras but I'm holding up my gear VR and it's gear VR enos and there you go ha ha on a phone on a phone it has a title GPU and with a tile GPU if you have a mesh object that contains a ton of vertices or just has this massive bounding box on it you're gonna see all these stray vertices coming at you because you basically blown out the index but you've you've blown out the and you have forced way too many vertices at the tiles and they just they can't handle it because it's it's too many so the the rule of thumb is you don't want to say say you had a giant square room like in the room that we're in now I would want to use and merge stuff down that are localized clusters so I'd want to merge the stuff in this table down but not necessarily this stuff and this stuff and all of this stuff right I'd want to localize this because what this allows me to do is it allows me to also make this disappear while still having these two objects here as well right and I can make these a cluster as well um doing an entire force to our correct you'd want to use instancing for that because an instance is basically free because you have rendered it one yeah you've rendered it once and then you're sharing that data what this is doing is this is actual physical mesh data that you will be adding so doing the forest like that you have just turned your you know 200 poly bush or whatever and you put them all together now you have a 50,000 poly monolithic mesh that has all your bushes but you but with culling issues they're going you're gonna lose holing issues you're going to lose all LOD stuff that you can do um so and if I had to do something like that I'd use the foliage tool um this this is this method is more like I use this when I wanna bake stuff down that HD law doesn't necessarily give me the results that I want or I just need to I really it on mobile especially having to material IDs is worse than having too many vertices like it will cause more performance issues it's the biggest thing that you need to clamp down and especially in VR not so much in beer I don't want to say especially in VR but having as few material IDs as possible yeah is the best way to go no matter what your platform is but is this general will reduce reduce reduce draw as much as humanly possible everybody's real that's applied to it material element this pledge hood is another draw call always keep that in mind yep and you want to spend you draw calls as possible so this is something that I would approach towards we're getting ready to ship maybe I'm having a little bit of problems you know on my on the switch or the Xbox or the ps4 like how can I quickly and non-destructively see if this is actually giving you results because you can't just say hey I fix something by optimizing these messes your your technical director is going to strangle you right yes you what you need to do is you need to show them hey look I did this control shift , GPU profile I did this oh this had some unintended consequences because you were working on some code oh let me go backwards really quick undo instead of making this entire trip oh I have to go Oh crud I'm sorry Oh crud I uh I have to open I have to UM I have to go back through perforce I have to back sync a bunch of revisions and then I have to import this new mesh again this just saves you having to make that entire trip through the pipeline again yeah it's it's definitely a pipeline reducer for sure as well as in optimizing a technique and actually I think it's going to interesting like normal when we talk about optimizing it's like from the beginning we thought about optimizing but this is as you said maybe you got to the end and you're here and your goal is here and you didn't quite make it so maybe try yeah a little bit of conversion a little bit of tweaking it's always easy to tell people in the beginning you should plan and you should do this and you should do that and while that's a that's the best practice that it's it's hard to pull off sometimes in reality and this is one of those things where if you've been doing this for a little while and you do have some proper just some proper practices and procedures in place this can help rein in something that can become unwieldy but again it's just like forward rendering it's not a magic bullet that is going to make your project run faster it's not a magic technique that is all of a sudden going to take a poorly performing game and make it run at 90 FPS it's just it's it's a little bit of extra performance boost here if you need it at the end it's sort of like when we talk about crunch like try to make sure you never have crunch and everyone in the industry knows you tried and never have crunch you end up having crunch so one of those three weapons reducing techniques to try to actually stop it like binary searches for the bug etc etc so yeah that's really good advice oh that's uh that's that's all I have for you guys for today um let's go ahead and jump in and see if we've got any questions or anything like that yes sir all right so we got a few of them coming in here will this work with skeletal meshes it will not work with skull I was trying that yesterday um so but I have that but you have an idea I had an idea and I and I tried it out and it didn't really the I tried it on the infiltrator character and it just it just didn't really come out all that well um but I tried to flatten the entire infiltrator character as a whole and I think if I had a little bit more time I was going to try to show it on the stream but it started become super complex really fast and I didn't want to show you guys anything that just wasn't achievable you know it was just it was unrealistically like a people at epoch tend to make these grandiose Oh awesome things and it's really hard sometimes for the other people to come up and be like oh my god this thing is so awesome but you feel like I can't approach this and I wanted to try to make this as approachable as possible to everybody because what I'm talking about what I showed you to do today is very very simple to do but one thing you have to take into consideration like the Ryan's render target tool it looks super complex but it started off as just solving one problem and then he built upon it a little bit more and that's exactly what I shared with with everybody today for today's dream is little tiny examples that you can use in your projects and feel to build upon this to add more functionality to it if you find something that you really like or really works for your project it was kind of give you the small building blocks to then make something awesome because that's what everybody I think forgets and that we don't tend to see or people don't realize is that maybe we don't advertise it yeah but we're like here's a list are small we start small here at epic and we make these big huge grand things but you guys aren't seeing that you aren't seeing this small things start and then grow into this big thing you're just seeing the big thing when it's done and this what I shared with you today is how a lot of this stuff starts off and then you know in a couple of months it'll mature to something that's really big I know that's a random tangent but actually I was going to say this is actually pretty good tangent because this this kind of leads into so we've actually gotten a chance to almost document this live through streams is a through talking about bullet train and also through Odin our well Robo recall Here I am like all it's all through the code to let go the old handle for it um but yeah so you saw us when we talked about bullet train I first came out I think I might have mentioned I walked into the room when it was it was Nick Donaldson in a vibe waving a box around in the air er and I'm like looking on his monitor say is that a box he's like it's a gun he's like okay and then that became Robo Rico but you know there's like the magical step number two it's all question marks but you know you don't always get to see that but yeah it's like iteration after iteration and we just go oh hey can I make this thing solve one more problem exactly you know for example some sweets of tools exactly yeah um cool so got a lot of other questions I'm going to try to grab some users can um let's see here is the merge actors tool would you call that a replacement for the simplygon tools the native tool set but we actually do have a way of reduced so which is a totally different it's the hierarchical ellow hierarchal i cannot say that hierarchical hierarchical LOD tool i we my role ian yeah yeah yeah H LOD that's what you thought H Lodge is on H LOD is a replacement for that this tool is similar to what simplygon does sim the only thing that's simply gone provided for you if you bought it was skeletal mesh reduction so you could reduce the skeletal mesh down and its animations and everything like that and simple gum would automatically handle that for you this is a much much less robust version than that and it only handles static geometry right now so everything I showed you right now applies to static geometry I mean you could if you really wanted to and you were here you wanted to fly by the seat of your pants you could take your character you could convert the skeletal mesh inside of unreal to a static mesh yeah bake it down export that back out and then reskin it and your modeling package I mean yeah I guess so yeah well you could yeah that right that's why I said you want to fly by the sea your onions after has you'd have to like put the skillet until I completely redo you'd have to totally redo all your wings and all that stuff but yeah it could be a way that you had a rig built around it too then you would well you wouldn't have to rebid build your rig I don't think you would just have to RiRi wait Andrey oh you would just have that basically you'd be starting with the mesh again oh right because the skeleton would have stayed in the rigs or attached to the skill more you just had your character artist do it inside of unreal in the beguine there there's this it's called reproduction as the name of this technique inside of a like inside of 3d Max and 3d max in Maya and ZBrush as well and a 3d code and bunch of other programs basically you can reproject UVs on two completely different geometry and have like you know I could reproject a square on a cube that probably won't work but that's basically what you're doing and this method is a little similar to that so if reprojection isn't something you're familiar with it's super advanced technique but it's definitely something I would I would have a mighty a tool belt for sure let's see here are any of these methods that we've talked about today documented in writing somewhere that people get their hands on no I have some plans to cover some of this documentation but what I showed you guys today if you looked at the merge actor documentation I am literally using the merge actor exactly the way that you would use it normally according to the documentation but instead of selecting multiple meshes I'm just in one mesh and yet that has multiple elements that yeah that has multiple elements all right cool does emerge it does the merge actor intend to be used with properly UV mapped UV unwrapped models or does the UV not matter at all so one thing that I've noticed is if you haven't an object it that goes out of the zero to one bounds which basically means when you look at your UV sheet and I can actually let me see let me show you really quick what I mean by that if we come here to our UVs you see this box right here this little black box and you can see that's our zero to one range okay so that's what we mean when we talk about zero to one so when I look inside of 3d max or Maya I'll also have a box like this and that just is a way for us to know that if there's a UV down here in the lower left hand corner it's going to be down there in the lower left hand corner now when I say out of the zero to one range you can have you v's that come over often to here it'll start kicking back errors on you though yeah it will um let's see if I'm not sure if any of these have them but we're going to just take a quick look and see and no he's pretty well laid out the floor might have one or the ceiling yeah here we go okay so you see these crazy lines that are going out here basically what someone did is they took probably all the Polly's in the ceiling right here and they planar mapped them and then they scaled the UVs really really big to give a bunch of fidelity to the material that you're seeing underneath here so basically where we're increasing the size of our UVs to give us more stuff to look at so for this particular mesh right here what would happen is basically if I went to go run this through its gonna cut all of this information off and put it in the zero to one space so if you have something that's super tiled you're going to get some weird pixelation in it so to answer his question it is actually better to use a zero to one method when you're building assets if you're going to use the merge actor because you will have better you will not better control you'll understand what meshes will actually work better with the merge actor and which ones aren't so it's going to introduce less um less debugging time on your part if that if that makes sense right um here we have quite a few of these here will this be recorded at a later date yep these are all going to be on archived on YouTube Co do multiple UV channels use multiple draw calls and it's the draw calls are based off of the elements not the UV Chad's yeah what are multiple UV channels though do make your mesh heavier yes okay so if you have you so first off let's just run down UVs so UV channels zero which will be UV channel one and everything else is going to be your base your base color your normal map should be on there and your normal that has to stay on that channel because unreal is expecting the tangent information to come from that particular channel your second channel is always reserved for your light Maps now if you want to get clever with some of your material logic you can of course flip these orders and do all that stuff but that's very few part of the people there's some ways that you can store the information differently to get different effects but just for for for simplicity sake um every time you add another UV set so UV set zero UV set one UV set two three four and five it's going to make your mesh that much more expensive to hold into memory because it's that much more data that it has to hold all right won't the UVs overlap if you merge two or more textures into one and anything you should optimize for you for UV in 3d softwares if you later want to merge the textures in unreal I guess we kind of talked a little bit about how to set up the UVs in that but so what what prevents the UVs from creating overlapping UV is when you merge two different meshes together I mean let me show you guys really quick black coffee cup was a horrible idea yes a black coffee cup and they'll just do a new level for lack everything yes I got lost in the void there okay so I and we'll do know it stupid coat hook kind of had like a vantablack effect we're just vanished sorry guys did not mean to burp into the microphone hmm ah you wouldn't be realized though all right so let's merge these three guys together so we're going to go edit no we're going to go window developer tools murder actors and I'm just going to hit okay and we're going to hit replace source actors so so what it's going to do is so I think yeah they so this is all one actor so if I hit ctrl e on the keyboard here now you notice I don't have any everything still looks the way it should this looks a little pixelated but that's because I did a super low self reflection looks great yeah if I come here to my UVs and so so this is my light map right here I don't know why I put another one right there I think it might be a bug I'm not sure but this is my map right here so this right here that's the mosula quartered it into chones mmm if I had another mesh so see I have I had three meshes that's why I have a gas right so it is almost better to do it as like even numbers or yeah yeah yeah it comes that was I you reminded me one thing I wanted to show you which was that in Rodge I didn't even know I had of this particular method if we look at this map really quick here you see I have a lot of space that is ended up being wasted right here so right here and right here now you could get into the nitty-gritty of this is going to you know that's a waste of space and there's all this and that but what it really comes down to is if I can make this texture smaller and save myself a material call it made my game faster yep like that's just that's literally what this comes down to and everybody who's made a game gets to a point where the quality stops mattering and what really matters is getting out the door so you can feed your family and trust me you will get really honest that you will get to that point and this is a great way to help you get past that line without completely destroying the quality of the artwork that you made there's a lot of other methods that would totally destroy everything but this method is very very good at keeping that to a minimal awesome so we're pretty far over time so we made up a bit of time because we were about 20 or so minutes late at the beginning due to some audio issues but I'm just going to kind of cut it off on that one I guess because we have a couple I have meetings everyone else probably has other things that they're gonna have to get to eventually pleasure I did want to say thank you so much Sam yes was very enlightening hope you guys learned something um I did I mean I didn't know I didn't know how it quartered things when the action merges things together so at least learned a few things for sure so if you all out there also have any other questions whatnot please go to forums dot Unreal Engine comm under the events section you'll see one that's titled you'll see an event that's titled that down there baking materials detectors and that's going to be the one for this stream you can ask additional questions there and we'll try to get back to you if we get and get to your questions here but I want to say thank you all so much for coming out and watching stream thanks for down with the technical problems I said then thanks for actually letting us know that there were technical problems so we could get them resolved and we'll be seeing you all again on Thursday at 2:00 p.m. Eastern Time we're going to be talking to actually a third-party software developer about arm which would be really cool check out the forums for more details and also don't forget to like subscribe hit all the different buttons that are around us depending on what you're watching us on because we stream to a few different things now and that way you can always have the latest in Unreal Engine news also follow Sam on Twitter because he needs like so many more followers he makes so many awesome things oh yeah but yep alright so we'll see you all next time bye now see everybody [Music] you
Info
Channel: Unreal Engine
Views: 50,327
Rating: undefined out of 5
Keywords: Game Development, UE4, Materials, Textures, Photoshop, Optimizing, Optimization, Cats, Zoidberg
Id: WaM_owaUpbE
Channel Id: undefined
Length: 62min 24sec (3744 seconds)
Published: Tue Jun 20 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.