In this second tutorial, you will learn how to optimize the performance of your scene.
Video captions: Hello and welcome to the second part of our tutorial series, Introduction to Real time and VR for Autodesk VRED Professional. We hope we could give you a first overview in the previous part. If you have any questions, just post a comment. A good place for questions, general exchange and feature requests is also the VRED forum at autodesk.com!
After we looked at different ways to calculate shadows and lights on our geometries last time, today we want to give a short outline of which parameters can directly affect the performance of a real time scene. The main purpose of this tutorial is to identify possible bottlenecks in order to be able to weigh up which ones can be optimized. This is important, because optimizing a scene can take a lot of time and patience - but if you want to render mostly stills, for example, you can do without it. However, we would like to stay in OpenGL for this tutorial and give you an important hint at this point: An important indicator for performance problems is the VRAM load! So always pay attention to this and if the frame rate drops, check this first! Also, always keep an eye on the statistics!
But first, an overview. We are sure that many things are already known from other render engines or VRED, but we hope that one or the other hint can be helpful anyway! So, let's have a look at the overview - the order doesn't matter! For example, we will deal with the polycount first, but it is usually not that critical in VRED.
So, consider the following overview as a kind of checklist. Things we will talk about are:
What should we already consider when importing and preparing geometry? Which parameters should be checked for materials? How can render settings affect the performance of our scene? And lastly: What camera settings can affect our framerate?
geometry
a. Import (Polycount, NURBS Data) > Node Information
b. NURBS vs. polygons
c. Scenetree (Hierarchy, Unused Nodes, Material Groups, Nodecount > print len(getAllNodes()), Transformnodes, Shared Nodes
)
materials
a. Intro + IBL Quality, Textureamount + Size > Texture Statistics b. Shader parameters (Bump, Orange Peel, Displacement) c. Special cases (Woven Cloth, Multipass + Layered Materials, .axfs / .substance) d. Alphachannels
render settings
a. Real time Antialiasing & DLSS b. Occlusion Culling / Backface Culling
camera settings
a. Depth of Field b. Light Flares + Glow + Glare
So, let's start with importing data: Basically, I would recommend setting the Tessellation Quality as low as possible. Especially when importing NURBS data we can selectively readjust the quality later in VRED and for example tessellate smaller parts like screws or icons. On the one hand, this gives us a lean model, saves us time during the import and also keeps the best possible performance in real time. At this point, it is important to make sure that Keep Surface Data is activated. Only then can the mesh density be iteratively adjusted later in VRED. At this point also a hint for the import of very large geometry like houses or streets: The Tessellation Quality can be set to Coarse and the Max Cord Length to 50000, which would correspond to 5 meters. When importing polygonal datasets with quads, we would like to recommend triangulating them already in Maya or the tool of your choice. Also, when importing polygonal data, we would always advise using the .fbx format: Compared to .obj or .3ds it is simply the more up-to-date format, industry standard and has the possibility to import or export cameras, materials, lights or animations in addition to geometry. Furthermore, VRED optimizes .fbx data already during the import - with .obj and .3ds data these optimizations have to be done manually. We will talk about these things later.
So, first of all, to get a quick overview, you can simply activate the statistics and read out the global polycount. Alternatively, you can select a specific node and check the polycount in the Scenetree by right-clicking Information. If a part is too fine tessellated and you see the possibility to save polygons, you can simply select the corresponding part and test other settings via Scene > Geometry Editor > Geometry - provided that the NURBS information is stored in the imported data. Here you can increase or decrease the density of the mesh as you did during the import. Finally, only create as many polygons as are necessary for a correct representation of the geometry. The only exceptions are vertex-based illumination modes, as explained in the first part of this tutorial series.
To be honest, VRED has no problem with a large number of polygons. Depending on the hardware, polycounts of 50 million and more should not be a problem! More critical are NURBS based datasets. Basically, stored NURBS data is a big advantage, but it can reduce the performance of your model during real-time presentations. Before presentations you can convert the model to polygons - but make a backup before!
By the way, you can identify NURBS data by this small rectangular area symbol. If you work with polygonal data, you can identify it by this small triangle. To convert, simply select the desired node and right click > Edit > Surfaces > Convert to Mesh in the Scenetree. But please save your File including the NURBS Data before converting.
After we have imported and tessellated our data, it is a good idea to take a look at the structure of our scenetree. Basically, it makes sense to keep the structure clean and tidy for a pleasant workflow. Your colleagues will also love a tidy Scenetree! This means that the hierarchy should be kept as flat as possible and unnecessary groups or material groups created during import should be removed. Furthermore, parts that belong together should be combined if possible. This can be done with the shortcut CTRL + Shift + M or by right clicking on the selected geometry in the Scenetree > Edit > Geometry > Merge Geometry. Alternatively, you could use the Optimize module, but since you can't undo operations via the Optimize module, you should at least know how to do it manually. By the way: If you want to know which shortcuts are preconfigured, you can see the list via View > Show Shortcuts.
Now back to the Scenetree: The easiest and fastest way to optimize the hierarchy is the so called Optimize Module. You can call the Optimize Module either via Scene > Optimize or via a right click in the Scenetree and Edit > Show Optimize Module. You can optimize the whole scene as well as single groups by selecting them. The default settings can already contribute to an increase in performance. These settings are also stored under File > Optimize Scene and can optimize the entire file.
At this point we will have a look at the most important functions of the Optimize module. First, we want to remove all unneeded groups. For this we activate "Cleanup Group Nodes". VRED will now remove all groups that have less than two child nodes. Do the same by activating “Flush Material Group Nodes” to get rid of all imported material groups, but you can also delete them manually.
Just remember, as a further step you can merge potentially related parts as shown before to reduce the number of nodes. By the way, you can read the nodecount via a small Python command: Just type the following command print len(getAllNodes())
into the VRED terminal and you will get the sum of all child and parent nodes. The lower this number is, the better!
Last but not least, and only if you don't need them anymore, you can remove all transformation nodes. Transformation Nodes can be recognized by this small pivot icon instead of the group icon. With the activation of "Flush Transformation Nodes" the coordinates and scaling of the respective node are reset to 0 or 1, whereby the geometry itself keeps its positioning. Note: This function is not possible as soon as a node is referenced, and it is a so-called shared node. In a few seconds we’re jumping back into our harbor scene because many shared nodes were used there.
As promised, here is a short hint how you can optimize imported .obj or .3ds data analog to .fbx data: Open the Optimize Module, check if 16 bit lengths and 16 bit indices is activated, activate Unify Vertices, Optimize Indices and Sort Indices. Additionally, you can activate Remove Invalid Texture Coordinates and Remove Degenerated Polygons under Filter. By the way, this is one of those things you can't find on your own, but you can find it in the VRED forum! But I guess that settings are stored in the global optimization settings anyway.
Welcome back to the coast and back to instances or Shared Geometries, as they are called in VRED. Shared geometries are geometries that exist several times in a scene with exactly the same geometry structure. To save polygons, the same geometry is used several times in a scene. Popular examples are screws, side mirrors or rims and tires. In our scene, however, I would like to demonstrate the process using these containers. Currently there are only two different containers - the 40 feet variant in gray and the 20 feet variant in yellow. When we click on a geometry, we can see from the underlined node in the scenetree that this is an instance. To illustrate that we can also briefly assign this material.
So right now, we're working with referenced objects, which is great in and of itself. Let's break up this to see if it has an effect on our performance. For this we can remove the references of the whole group in the Scenetree via right click > Edit > Unshare > Unshare Subtree. The process takes a little while but we can already see that the frame rate goes down but there is no visual difference in our scene. To reference the geometries again you can go back to the Optimize module. Just right click in the Scenetree > Show Optimize Module and check Geometries under Share. To check if this worked, just expand the hierarchy a bit and check if the corresponding nodes are underlined again. Please keep in mind that you can't benefit from render settings like Occlusion Culling in this case!
Let's end the chapter on geometry optimizations at this point and take a look at how we can check materials and textures. In the last tutorial we already pointed out that HDRI maps with 8 - 16k are absolutely sufficient in most cases. In some cases, you can even go to 4k, if you render a still with motion blur. At this point we would like to point out a relatively new feature, namely the possibility to adjust the glossy quality in the environment material. You only have to know here is that the visual quality increases with higher settings, but at the same time the calculation time increases. We would recommend to check this individually and consider if high quality settings also brings added value.
Let's stay with textures for a moment. Basically, the number of textures used as well as their size has a significant impact on the load of the graphics card memory. It also doesn't matter if the texture is activated or deactivated - only when you delete the texture out of VRED it frees up the occupied memory. To get a first overview, it is a good idea to check the VRAM usage – yes, I know again. But it is always good. You can also check the number of your materials and textures as well as memory usage under Materials > File > Statistics.
For a quick and convenient optimization, you can also clean up your material editor under Material Editor > Edit > Remove unused Materials or Optimize Materials!
However, if you run out of graphics card memory even after various geometry optimizations, it is recommended to manually rework the materials. You can try two different ways or combine them: One possibility is to reduce the resolution of your textures. Ask yourself for example if you need 8k textures everywhere or if 4k is good enough? Even in close-up, 4K textures usually look good! The easiest way would be to scale them down in photoshop or so and reload them in VRED. Just a note on the side: Pay attention to power of two, that means work with 1024-pixel, 2048-pixel, 4096-pixel textures and so on.
If downsizing different textures does not bring the desired success, you can check if you really need all texture channels. If your materials are not visible at close range, it is worth checking the different texture channels. Using this barrier as an example, we can see that both the Bump, Roughness and Glossy Texture have little to no effect. In addition, Glossy Color itself can be adjusted and the texture can be deleted.
It's also important to know that VRED inlines all textures into the .vpb file by default. If you want to change this and just link the textures, you can disable the use of inlined textures under Edit > Preferences > FileIO > OSB/VPB > Export.
Let's stay for a moment with the optimization of materials. There are some settings that can affect performance especially when using virtual reality glasses. These include procedural shader effects such as bump, but also orange peel in the clearcoat settings for carpaint materials. The same also applies, as in other render engines, to the use of displacement maps. In most cases you will see an immediate drop-in frame rate. So, we recommend to move your whole geometry into a material group to check if there are maybe some critical shader parameters activated.
Apart from that, there are some special cases. You should also be careful when using the procedural Woven Cloth Shader - avoid it and use textures to build up the material. Secondly, multipass and layered materials are very intensive to compute and should only be used if absolutely needed. The same goes for textures with alpha channels. The scene at hand is well optimized, so the many multipass materials do not matter.
Just a short conclusion: As you may have noticed, the performance of a scene depends on several parameters and compromises often have to be made. The next notes will therefore deal with another elementary component, namely the render settings in OpenGL.
Basically, there are two ways to use antialiasing in VRED. On the one hand you can trigger the standard still frame antialiasing mode via the interface or use the space bar shortcut. On the other hand, you have the possibility to use Real time Antialiasing to activate the antialiasing permanently. You can find this setting under Visualization > Real time Antialiasing, where five presets are also offered. Here it is clear to say that the higher, the better - but possibly at the expense of the frame rate. Just test which settings represent a good compromise between performance and quality.
Alternatively, you can also try out the new Deep Learning Supersampling, called DLSS. Simply deactivate the normal real-time antialiasing settings and test the different settings.
That said, if you are using VR glasses, it might also be worthwhile to test the Variable Rate Shading or to activate Foveated Rendering in the Preferences under Virtual Reality.
Finally, you should definitely test the Backface and/or Occlusion Culling Settings under Visualization > Advanced OpenGL Settings. Using Backface Culling, VRED only renders the surfaces normals which are aligned to the camera. Occlusion Culling ignores all surfaces that are covered by other geometries and that’s why it won’t work with instances.
To round off the topic, let's take a brief look at camera settings that can affect performance. First of all, there are the real time Depth of Field settings. Depending on FStop and Interactive DOF Quality, you will notice a deterioration of the frame rate. So, if you don't really need Depth of Field, we would recommend deactivating it.
We would also recommend to work with realistic values, i.e. leave the Focal Length and FStop of the camera in areas that can also be imaged by real world camera lenses. And a quick tip: You can set the focus point with a double right mouse click!
The other critical camera parameters can be found in your camera under Image Processing. The effects Glow, Glare, Fog and Lens Flares are deactivated by default, but can also cost some frames when used. Just consider if you need these effects or disable them when presenting your scene!
Okay, to announce the end I have activated the night scene of the first tutorial. As a short summary we would like to point out again that the performance of a scene can depend on many different parameters. Also, some optimizations work better in one file than in another. It is therefore important to develop a feeling for which optimizations make sense, which would be a bad compromise, and which are too costly compared to the added value. Basically, you should just make sure to use as few nodes as possible and merge related areas, reduce the polycount at the same time and load only as many textures as you really need and choose a low resolution for them as well!
If you have any questions or remarks, please write them as a comment! We thank you again for your attention, hope you enjoyed it and see you next time!