5 Tips to Optimize Environments in Unreal Engine 4.26

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Op-timi-zation, is a process of making something as good or effective as possible. In our case, finding the balance between quality and performance. Maintaining both of them at the same time is quite a challenge, so today I’ve prepared 5 tips to help you optimize your environments. Let's check it out. There are many things that can cause poor performance, but one of the leading causes is overdraw. Okay, but what is it? Scientifically speaking overdraw is a process in which, during the rendering of a pixel by GPU, it's replaced by one that is closer to the viewport. Tough definition, I know, but for example, we have an object and there is a fog card in front of it, so the GPU will first render what’s behind the fog card and then overlay the fog on top of that because fog is in some way transparent, so the initial pixels are behind replaced by those that are closer to the viewport and this process of over rendering can happen several times for a single pixel which is not good. When it comes to optimization Unreal Engine has a lot of features and different viewports to help us visualize and find where the problem is, and they’ll be very useful to us today. Let’s jump into Unreal. So, when I go to “View Mode”, “Optimization Viewmodes”, we can see that there are bunch of different view modes. We’ve talked about overdraw, so let’s start with it and select “Quad Overdraw”. This view mode shows us how many times each pixel is rendered by GPU, and in my case, I have a lot of green so here we can see that every green pixel is getting rendered 4 times. So, what we can do about it? The first tip (actually one of the most important one which helps reducing the number of triangles and overdraw) is to use LODs on your meshes. Level of detail or LOD is a system that basically creates multiple versions of the original mesh, that have less and less triangles, and then manages them based on your distance to a given mesh (in Unreal it’s based on screen size). And when you are very close it will load the highest LOD mesh, which is the most detailed and has the most triangles, and when you move away it will swap to another LOD which has less triangles, so generally, LOD system reduces the amount of triangles you have and save some overdraw calculations. Setting up LODs is very simple. If you are using models from Megascans, they include LOD’s to every mesh, and everything is automatic so you’re just chilling. But if you have your own custom models and want to create LOD’s, double click on the mesh, in details panel find the “LOD Settings”. Unreal has various presets that are really useful, and you will find them in the LOD Group. This mesh is small, so I'm gonna set it as “Small Prop”. Give Unreal a few seconds, and when we move away, we can see that triangles are being reduced here to the top left, and LOD system is working. If you want to have more control and don’t want to use any presets after opening mesh the first thing, we have to do is to determine the number of LOD’s in “LOD Settings”, so I’m gonna type 4 and give Unreal a few seconds to generate them. The next thing we have to do is to disable "Auto Compute LOD Distances", switch on "Custom" mode, and now you can change "Screen Size" for each LOD separately, and change the percentage of reduced triangles in “Reduction Settings” to your liking. Once everything is set up Unreal has a special View Mode to visualize it, so hover over “LOD Coloration”, and choose “Mesh LOD Coloration“. Especially when you have multiple models next to each other that's when you see the power of this system, how quickly and smoothly it changes meshes, reduces triangles, and overdraw. This is overdraw comparison of pure objects, and after applying LOD's. And these are the renders without and with LOD system. Looks identical. We’ve reduced the number of triangles which helped a bit with Overdraw, but that’s not the end, because the biggest Overdraw burden are particle systems. For example, here I have a simple fog particle system, and as you can see it’s extremely heavy. Pixels are being rendered 10 times, which brings us to the second tip, which is use LODs on particle systems. So, this time based on distance we are gonna decrease the number of particles that are being generated. After opening your particle system, I’m gonna create for example 3 LOD's. It's very easy to move through them using these buttons, or you can type the LOD number here. First off all, let's set the LOD distances, in "Details" panel find the "LOD" tab, and here we can set the distance in units, so I'm gonna set for example 2000, 5000, and 10000. And now let’s set reduction of particles, which is in "Spawn" and here in "Rate". So, let's go to LOD 1, let's duplicate Spawn Module so we can edit it, and now change the constant to, (I had 50 on LOD 0) so this one gonna be 30, let’s go to another LOD, duplicate Spawn Module and I’m gonna set it to 15, and our last LOD, Duplicate Spawn Module, and I’m gonna just enter 0, so it'll just slowly disappear after 10000 units because when we’re really far away, there is no need to make these calculations by GPU. Let's go back to LOD 0 and close this window. And btw you won’t see any changes in Viewport (I’m not sure why), so you have to like launch the game to see results. Here is the overdraw comparison, LOD 0, 1, 2, and 3 which disables the particle system. And remember set your own distance settings, set your own particle reduction setting, adjust everything to suit yourself, and it will definitely save you a few milliseconds in performance. So, we’ve done triangle and particle optimization, we’ve dealt with overdraw, now let’s focus on textures. And my next third tip is to make sure that you use right-sized textures in order to generate mipmaps. Mipmaps are something like LODs but for textures. So, Unreal generate multiple versions of a particular texture which are progressively lower resolution, and then manage them automatically. Here you don’t have to do anything just make sure that your textures are the power of 2, which is industry standard. And if you want to check it, double click on a texture, and you can actually see here that 13 Mips have been generated. So, if you are using any custom textures I recommend to verify if they are the power of 2. If not, you can simply resize them in Photoshop, Gimp, whatever software you use, or pad them in Unreal in “Texture” settings. My fourth tip is to don’t use oversized textures, and I mean ask yourself what texture size for a given model is needed is it 8K, 4K, maybe 2K. For film quality of course use the highest resolution, who cares, but when it comes to games, I think 8K is pretty much overkill. Of course, you can use it, on certain larger objects but remember when you have hundreds of different textures you can run into some memory issues. If you don’t know which texture resolution, should you use, Unreal has “Required Texture Resolution” view mode to help you with it, I’m gonna choose this view mode and select for example this mesh and choose albedo texture. Now we can see that this texture is in green, which means it’s 2 times over resolution, (of course, if we get really close to it, we will find that the resolution is missing), but really ask yourself if you ever will be that close to it in a normal situation, if not consider reducing the texture, and not just Albedo, but also Normal map and Roughness, which will save a lot of memory especially when you have hundreds of different textures and prevent any memory or streaming problems. And finally, as the fifth tip, I'd like to talk a bit about lighting optimization, and we gonna mainly focus on small lights because they are the ones that most often cause a drop in performance. Overall, in Unreal there are 3 types of small lights: “Spot Light” and “Point Light” and “Rectangle Light”. So, the first thing we need to ask ourselves is do we need these lights to be dynamic, or static. Dynamic lights are really heavy so whenever you can set them to static, and later bake the lighting and simply forget about them. This is the best solution. If you need to use dynamic lights the best thing, we can do is to change the effectiveness radius of every “Point” and “Rect Lights” (you don’t have to do it in “Spot Lights”), because the default value is often too big. Unreal has a special view mode that shows light complexity, and it visualizes the same color pattern as Overdraw, so blue is great, and the closer you get to white the worse it gets. So, I’m gonna select “Light Complexity” view mode and we can see that this light affects a crazy amount of space and in this situation, there is no point to make useless calculations, so to fix this we can decrease the “Attenuation Radius” and eyeball the size more or less, and now it looks way better. This is the comparison between leaving default settings on 4 dynamic lights close to each other, and here optimizing it. And here are renders, looks identical. The next thing we can do is to set up “Draw Distance”, which basically means that light will no longer be visible from a certain distance. It may sound a little strange that we disable lights from a certain distance, but this solution is actually very common among games. Unreal Engine made a presentation a few years ago and talked about how they use it in Fortnite. You can even notice it in Cyberpunk especially at night where there are tens of different lights, and when you drive through the Night City you can observe they slowly appear in the distance. So, to set it up I’m gonna select light, and in "Details" panel find “Performance” settings. And here you can set after how many units light will disappear. I’m gonna set it to for example 3000 thousand, and to make it less visible the second option will help us with fading it out, so I’m gonna set it to 500. And when we move away it’s very fluent. And the last thing you can do is turn off casting shadows on certain lights. You know, in some cases it's not the lights but the shadows that are the source of the problem, especially when there are a lot of triangles in the range of the light. For sure you have some lights that are very close to the ground or simply not that important in your scene, so consider turning shadows off and for sure it will improve your performance. And to do it, select your light and in “Details” panel turn off “Cast Shadows” option. So, let’s wrap everything up: firstly, always use LOD’s on your meshes and particle systems to help reduce overdraw and number of triangles, make sure your textures are the power of 2 in order to generate mipmaps, don’t use oversized textures, so you won’t run into any memory and streaming problems, and try to optimize all the small lights and by that, I mean bake lighting whenever you can, decrease the “Attenuation Radius” and whenever you can turn off the “Casting Shadows” option Thank you for watching. Remember that optimization is finding the balance between quality and performance, so try not to go to any of these extremes. Consider subscribing for more content just like this and if you have any more questions, please let me know.
Info
Channel: Jakub Hałuszczak
Views: 6,023
Rating: undefined out of 5
Keywords: optimization in unreal engine, 5 tips to optimize environments in ue4, unreal engine 4 tutorial, ue4, ue5, ue4 lighting optimization, LOD system ue4, how to optimize game in ue4, optimization, unreal engine 5 tips to optimization, Jakub Hałuszczak, Jacob, Haluszczak, ue4 optimize, ue4 optimize open world, ue4 texture tutorial, ue4 streaming problems, how to optimize ue4 game, how to have more fps in unreal engine 4, ue4 performance optimization, ue5 optimization
Id: gZkKcaF4Ifk
Channel Id: undefined
Length: 12min 22sec (742 seconds)
Published: Sat May 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.