Don't use Alpha Channels in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay this is going to be a quick video just going over the hidden cost behind alpha channels in your textures and on real engine so alpha channels very popular way to pack in a opacity mask or something similar in order to save on texture samples and reduce the amount of textures that you have inside of a material and in your project so just to showcase we have two materials here i have one that has a packed texture and on this one you can see that it has an alpha channel and that alpha channel is driving the opacity of this material so if i disconnect this real quick you'll see it update and so this is no longer translucent where it should be and it's opaque everywhere so this actually drives that translucency and i have that baked into this texture under the alpha channel and along with it i have metallic and red roughness in green and ambient occlusion in blue very standard practice now if i go to this other one i have the exact same material it's set up in the same way the only difference is that instead of having this opacity mask in the alpha channel i have it as a separate texture that's the only difference so you can see that between these two materials they look identical the only real difference uh is there's an extra texture sample so if i look at the stats down below i have 6 out of 16 with a shader count of 7 and if i go back to the previous one i have 15 with a shader count of 12 that's partly because i just changed this it should be 5 and it's going to jack up there just due to how unreal does things but if i reopen them real fast you can see that they've updated they're now identical but you still have that extra texture sample so these are for the most part identical there's no real difference minus one has a bit more clutter because you have a whole other texture sample here and yeah pretty simple so this is a very common practice to bake it into an alpha channel and the main reason for that is once again just simplify things less texture samples to deal with make sure materials cleaner once they get more complex reduces the amount of files that you have on disk and because of that you tend to see this technique all over the place you see it in different production studios you see it on tutorials on youtube you see it in udemy courses and so on so i see a lot of people using this however even though these materials look identical and if i go to the shader complexity under the optimization view mode so just go to lit optimization view modes shader complexity i can see that they're pretty much identical in terms of performance they are slightly different when it comes to being on disk so let me go to these actual textures to show you what i mean so if i go into uh this one this is the packed texture and this is the one with no alpha channel so you can see that the alpha channel is great out here if i click on it nothing happens but i have the red green and blue so the red being the metallic green being the roughness and the blue being the ambient occlusion right so three textures packed into this it's a 4k texture so over here on the right you can see it's 4096 by 4096 and if we look down below here we can see the resource size so the resource size is its size on disk so it's almost 11 000 kilobytes or 11 megabytes when you convert now if i go to the other one this is the exact same texture the only difference which you can see is that it has the alpha channel right so i've essentially baked that opacity mask that you saw in that material into the alpha channel of this texture that is the only difference now if we look over here on the right you can see that it's still 4k right nothing's changed there however the resource size is actually doubled right it's close to 22 000 kilobytes instead of instead of 11 000 or 22 megabytes when you convert now the reason for that is because when it comes to alpha channels and compression they have to compress the alpha channel as though it's these three channels more or less in terms of size i know the exact programming and math behind it that was a oversimplification but in essence the alpha channel is as large as the red green and blue combined so as soon as you add an alpha channel you double the size of the texture now you might be thinking that's not such a huge deal because if we think about it if we were to just open up this separate one this by itself is 11 000. so if you have this plus the one without the alpha channel it's the exact same size on disk as just having the one so why wouldn't you just want the single texture instead of having both right doesn't that seem a bit more optimized well the problem is while they're the same right now should you need to optimize your texture memory later on in production let's say you're targeting something like a lower specs pc or perhaps a console or a nintendo switch something like that you might not have the same amount of texture memory available to you to stream and because of that you have to make some optimizations so let's say you want to lower the size of your mask right so your mask that drives the opacity you want to lower the size of this because you don't really need 4k for this because on those lower spec machines they're not running uh as high of resolutions for their monitors because they can't drive that so they have less pixels to actually see these so if this gets a little blurry on the cutout it's not going to be that noticeable to them right it's not going to be a huge deal so that's a really good way to lower your texture size so let's say i lower the mip value to 2 right so instead of 4k now it's 1k over here on the right as far as displayed now you'll notice the resource size didn't update here because this is just a preview i'm not actually changing the size of it right now i'm just showing what mip 2 looks like but what you could do is on a package so like when you package up your game to be an executable to run on a machine for steam or something like that you could say that all of your alpha channels are going to be or rather your opacity masks not your alpha channels you're going to cap them at mip 2. so you're going to say the largest they can be is 1k so that's going to drastically reduce the size on disk and open up a lot more performance the problem is that if your opacity mask is baked in you can see that we also crunched all three of these other textures to 1k even though we didn't really want to because we want those to stay really nice so even though i only want to affect that alpha channel i'm forced to affect the entire texture right i have to crunch down my metallic my roughness and my ambient occlusion that's kind of unfortunate well yes it does solve your problem it makes all of your textures also look worse rather than just making the opacity look worse right which is a lot less noticeable now if you had a separate texture instead of baking it in now i have the ability to set all of these as a single texture group and i could say that texture group which is maybe like opacity mask or something like that i'm going to set all those to a max mip of two on package so now i was able to set this guy to 1k but this remains at 4k so my metallic my roughness and my ambient occlusion are unaffected and i can just crunch down specifically the opacity mask so you can see where this actually gives you a lot more options while being the same size up front the only difference you're going to notice is that the actual materials once again are just going to have a slight bit more complexity because you have more textures to deal with more wires to connect so it can make your materials a bit more cumbersome but at the end of the day it gives you a lot more flexibility than going with something like this because you now have more control over the individual channels or not channels rather but individual textures that are baked into the channels you've separated them out and now you can control them on their own thus you have a lot more options when it comes to making your game performance on different build targets at the end of the day so it can really save your butt later on in production so hopefully this was helpful gave you a bit more insight into should you or should you not pack alpha textures typically i do not for this reason and uh it'd be up to you if you want to do it or not for your production but i think it's worth knowing and it could save your butt later on so yeah if this was helpful let me know leave a comment drop a like subscribe if you want to see more videos like this i'm trying to upload more and more so if you want to see more videos like this if you found it helpful go ahead and subscribe and yeah have a nice day
Info
Channel: Z-Axis Up
Views: 14,574
Rating: undefined out of 5
Keywords: unreal engine, unreal engine 5, unreal engine 5 tutorial for beginners, unreal engine 5 tutorial, unreal engine 4, unreal engine optimization, unreal engine optimization tips, unreal engine tips for beginners, unreal engine materials tutorial, unreal engine alpha channel, unreal engine 5 alpha channels, unreal engine texture tutorial, z axis, alpha channels, unreal alpha channel, hidden cost of alpha channels, don't use alpha channels, unreal texture alpha channel, game dev
Id: 6ymlJVcV6Pg
Channel Id: undefined
Length: 8min 54sec (534 seconds)
Published: Sun Sep 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.