Using combined textures for effortless shaders in Unity.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome back to poly toots in today's lesson we're going to be doing just a just a little quick tip actually so it's not actually a lesson at all I lied about that sorry but I was just thinking especially because uh I've done a hype blended vertex painting shadowed tutorial before and I'm not making this just to plug that honestly but I was thinking about a lot of the things that I do in my job that I'm not actually sort of teaching here and this is just a three channel shader here so it's just you know it's kind of like three materials but already you see this textualist just you know it's insane and this could even be even more you know I could have a lot more materials to to blend here so you know it gets kind of out of control pretty quickly and if you're using like the HD render pipeline from unity of you even if you're not actually but one thing that you may have seen let's just actually this if I just creates a unity material and I won't use the HDR P so we'll just actually just go to standard it won't work because I'm using HDR P now obviously we're used to things like the albedo containing the transparency and it says here so the transparency would be in the Alpha and then you have the same thing for your metallic so your smoothness map would be in in your alpha so let me just get rid of this and they take it a bit further with the HDR pipeline and so they have this you know this mask map which has your metallic AO detail and smoothness and so I thought it would actually be maybe a good opportunity to kind of talk about why you should think about making your own because there's there's a lot of materials of the textures that you might want to use and things can get out of hand pretty fast especially if you're doing any kind of vertex painting and just just using like an absolute boatload of textures so let's just open the scene here I have some very well a very simple example so this is obviously just one material so it's just it's it's all the maps that you would need to do all of this although it's worth noting that although I have a height I'm not actually using it here but you know you might have a use for your height but anyway yes so this is just one material you got your albedo normals emission I mean occlusion metal smoothness alpha and obviously to begin with you think well you've condensed the Alpha into the albedo smoothness into your roughness but this this quick tip is just about like why not why not push it a bit further so I have this example over on the right here so this is just three textures there's an albedo and normal then this is everything else sort of I have have an alpha in my albedo and I'm also using the Alpha of the normal channel and then there's the mask which is just all of the others so we just have a quick look at what these textures contain over here in the Photoshop so I have my albedo with an alpha pretty standard normal map and in its alpha channel I'm using the height map which is a good habit I think it's not uncommon for the Alpha channel of a normal map to contain the height map info like that's pretty that's pretty safe so then here's the the actual sort of like you know the if you could see me doing air quotes I would be saying mask texture right now with the with the quotes on that so this has my metalness my roughness my mission and my ambient occlusion kind of all in one and the reason that my albedo and my normal map only have two extra textures is because these are actually RGB textures like we need the red and the green and the blue channel in order to display the actual you know the correct texture so you can't unfortunately just go and like cram all of these other channels here the RG and B in your albedo with any other kind of grayscale image that you want because yeah it won't work but my use of the word grayscale there was pretty important and that you kind of wanted reserve this for greyscale two protectors only I mean you'll see here as these all get combined into the RGB it will have a color but this is basically sort of redundant information for you the thing that matters the most is everything will kind of be converted over to greyscale so there's your red and your green and your blue Channel and you know obviously your alpha now I'm not going to show you you know how to put these into the RGB and a channels I'm sure if you have Photoshop you can work that out there are also some you know some automatic texture packing tools that you can get I haven't used any of them so unfortunately I won't be recommending any but I think it is just as simple as like a like an asset store thing and you just select which of your textures will go in the RGB and a slot so if you're wondering kind of how to even do that without something like Photoshop I'm pretty sure there are tools available so hopping back into unity for a second it makes life not only easier for actually just sort of inputting the textures like after you've built the shader but it also kind of helps when you're making a shader so if we look at the first one here so the example on the Left which just uses all of the maps we have you know all of our properties and we have all of the detective duties and again like I said I wasn't actually using the height but you know it's you it's a classic sort of a grayscale image so that's why it's there yeah and I do just have just a little animation happening for the emissive this obviously it's not important I just have to put it there to show you that I'm using an emissive mask so yeah so you have this this is the normal one this is kind of what you would build if you were making use of each of these two textures like individually you know obviously your shader probably wouldn't be this simple and you wouldn't just have texture 2ds but either way it's just an example let's just close that one down and we'll open up the the packed one and so you see here it's just it's a lot simpler so it's just it's quicker to make the actual shader that you want and then after you've created it you or whoever else is working like we in a project with you it's gonna be so much easier for them to just propagate things correctly which kind of streamlines me into the next bit which is naming convention so I have just an example here that I've used in the past it's not the best but I will just have like an underscore like lowercase a if I could actually have done that wrong I think I do uppercase to be the channel and then lowercase for the map so alpha alpha in this example and then this one would be your alpha height and then of course this one red channel metallic green roughness blue emission alpha equals AO you know I'm not saying you have to stick with this naming convention but it just kind of helps also I suppose you probably want to include it in the shader itself yeah that would make sense I haven't done that but you know whatever and another thing to kind of mention is if we look at sort of all of these textures that we have so there's eight that we were using before sort of all split out this I think you know you're looking at 2.7 megabytes 5.3 2.7 I think in total because we've got two point seven two point seven so seven two point seven s and a 5.3 which if I just do some quick editing now to grab a calculator and to do the math so that you think I'm smart but actually I'm not that would equal about twenty four point two megabytes so if we come down and we have a look at the three that we've actually packed we have you know a five point three or five point three and the last one probably still yeah five point three so you're looking at fifteen point nine megabytes for that we can round it up we can say that there's sixteen megabytes being used here which is a saving of something like eight point three maybe I think which is pretty good but also while I'm here mentioning that you probably should be using crunch compression this has nothing to do with a tutorial but if we just actually say so we knew that these were five point three or something on that so if I just a name and apply now for the most part crunch compression is pretty amazing but if you do find you getting some weird artifacts just mess with the quality so now we're looking at you know 1.1 0.5 0.8 megabytes that is that is insane like if you're not using crunch compression you you need to be it's it's beautiful so yeah that's kind of it for all of I guess the the good sides I haven't really talked too much about the examples vertex painting being like a great sort of place where you may want to adopt this kind of pipeline I believe like the original left4dead I think they were using some of the mask stuff either for clothing that got wet or perhaps a spread of decals don't quote me on that I probably shouldn't have even mentioned it at all yeah so we talked about some of the good things like why you might want to kind of go down this route but of course one major floor it has is if you only have you know your albedo with an alpha if you only have your normal with the height in the Alpha and then you have this sort of this special mask texture that you created it's not really going to be compatible with much else that you use like if you're using some shader from somewhere else or even like the unity standard ones or the HDR P whichever way you look at it it is it is uh Spaghettio all over the place because you you're basically putting yourself in a corner where you kind of have to use like your own custom shaders for these textures that you're packing these other textures into so that's something to keep in mind but you know if you're super organized and you have everything planned out you know what will exist where then you know I would say to go for it the savings are often pretty good and the time that it takes to sort of create and to propagate is also pretty good so yeah that's that's kind of it basically I don't know I mean it's probably pretty obvious just from this screenshot but of course so this is my mass texture ran through a sample texture 2d and this isn't a shader forged specific thing like at all also it's just rather sad shader for shader graph you can use that any node based shader editor that you want yes so this isn't this isn't a shader graph specific thing but yeah as you can see I'm basically just splitting out you know the RG B and the a into their own places because this is you know it's the equivalent of four textures in one we've just crammed all that information into different channels see I'm expecting that's a lot of people watching this probably you know they're already aware of a workflow like this but I was just mulling it over with the with the vertex painting tutorial that I had done this one because obviously you know I'm teaching these things because it's sort of trying to introduce ways that you could be working in your actual projects and ultimately I wouldn't use this in a game that I was working on like I would swap it over to compacting or other combining textures into other textures in an example like this so yeah that's all it is just just a quick little tip and so that's pretty much I think all I have to say about it I think although what always happens is the moment I stop recording I just realized that there's 20 things that I forgot to mention but you know it is what it is so yeah thank you for watching but that does completely wrap it up so I will see you in the next one [Music] you
Info
Channel: PolyToots
Views: 53,792
Rating: undefined out of 5
Keywords: unity, game dev, texturing, game art, shaders, tutorial, texture packing, textures, combining, RGB channels, RGB, Alpha, Tip
Id: 60kVc4xHPX4
Channel Id: undefined
Length: 13min 6sec (786 seconds)
Published: Mon Mar 18 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.