- Unreal Engine 4 Shaders and Effects Cookbook
- Brais Brenlla Ramos John P. Doran
- 962字
- 2021-06-24 14:12:08
How to do it...
No matter if you've opened the level provided with this book or one of your own, we are going to be looking at the rendering cost that materials incur when being displayed. To do so, we'll be taking a look at several different indicators that can help us understand our scenes a little bit better. Take the following steps:
- Let's start by taking a look at the following scene:

I've included four different objects with their respective materials applied, which should help us understand the cost to performance that each one of them has.
- Continue by selecting the chrome ball (named SM_ReflectiveSphere) and navigate to the Details panel, specifically to the Materials tab. Double-click on the material that is currently applied to the model to open the material editor.
- With that editor in front of us, let's take a look at the Stats panel:

The values we see in there can give us an approximation to how expensive the material is to render. You can see that this M_ReflectiveSphere has 115 instructions for the base pass shader, 135 if we are using static lighting, and 191 if we use movable lights. The numbers themselves will be useful if we compare them to other materials.
- Let's go back to the main scene, and select the object named SM_Glass. Open up the material that it has applied just like we did for the reflective ball, and look at the stats panel again:

As you can see, the instruction count is much higher than in the last example we saw. This is due to the fact that the complexity of translucent materials is higher than that of opaque ones, and we can see that in here.
- Another way of looking at the Shader Complexity is by navigating to the main viewport and selecting one of the available Optimization viewmodes. You can find it in here:

- After clicking that button, you should be looking at something like this:

This is a more visually appealing way of looking at the shader complexity. However, it is one that is not 100% accurate, as Unreal only takes the instruction count as a reference to calculate the gradient you are seeing in the preceding image and not the complexity of the material's nodes themselves.
You might see similar values for two different materials that are really not equal in terms of their complexity—for instance, a material that is made out of several textures versus one that uses simple constants might show a similar complexity in this viewmode when in reality using the first is more demanding on the Graphics Processing Unit (GPU).
Now that we've seen one of the optimization viewmodes, why stop with just that one? All of them are useful for understanding how our scene is working from different technical points of view. Let's go over them in a quick way to see how they can help us.
- The first of these modes is called Light Complexity. This can serve us to analyze how expensive the different lights we have in our scene are. Toggle that on and let's see how our scene looks.
- At first you'll see that the whole scene is being rendered in black. This is because we are using a HDRi static type of light—and as the lighting has already been calculated, there's no light complexity at this stage at all. You can only see the object's I've selected being outlined in yellow for reference purposes:

- If we place a new point light, you'll be able to see how the scene turns blue. This is to indicate that there's some complexity to the scene, but this is just as cheap a lighting method as they come:

- Placing more lights will change how your scene looks—getting away from its original blue color. That means that lighting is becoming more complex and costly for our hardware to compute, so keep that in mind! The following screenshot is what our scene looks like in that viewmode with seven different lights:

- Another viewmode related to the previous one is Stationary Light Overlap. If we have multiple stationary lights it will tell us how expensive our scene is to render, in a gradient that goes from green to white.
- Finally, the lightmap density viewmode shows you how dense the lightmaps are for the objects that occupy your scene. Using static or stationary lights means that static objects will have their shadows baked, and this is the viewmode that lets us see if the settings we've chosen for our models are evenly distributed. Let's take a look at the two following examples.
- In this first set of images, we've set up the lightmap resolution for both wood planes to a high value of 1,024. That means, as you can see in the first image, that the shadows look correct even across the two surfaces:

- In the next set of images, we've lowered the resolution, but in a more dramatic way for the vertical wood plane. That means that the vertical plane has much lower quality shadows to the point where they are barely visible, even though they are still there in the horizontal plane:

There are a couple more viewmodes that we haven't talked about, but they deal with the amount of polygons that a model comprises and are not related to the materials we are using. You can take a look at them in the same panel we saw before, and they are called Quad Overdraw and Shader Complexity and Quads. They can be very useful in order to diagnose our scenes, especially when we have many high poly meshes or semi-transparent models—so keep them on your radar in case you ever need them!
- Delphi程序設(shè)計基礎(chǔ):教程、實驗、習(xí)題
- C語言程序設(shè)計基礎(chǔ)與實驗指導(dǎo)
- C++新經(jīng)典
- C語言程序設(shè)計
- Learning R for Geospatial Analysis
- Hadoop 2.X HDFS源碼剖析
- Mastering HTML5 Forms
- 從“1”開始3D編程
- 深入理解Kafka:核心設(shè)計與實踐原理
- 基于JavaScript的WebGIS開發(fā)
- 自己動手做智能產(chǎn)品:嵌入式JavaScript實現(xiàn)
- 狼書(卷2):Node.js Web應(yīng)用開發(fā)
- LabVIEW案例實戰(zhàn)
- 微軟辦公軟件認證考試MOS Access 2013實訓(xùn)教程
- C# 4.0權(quán)威指南