Red Orchestra 2 Level Performance Guidelines: Difference between revisions

From Tripwire Interactive Wiki
Jump to navigation Jump to search
(Created page with "The following is a list of items that LDs and Environment Artists should follow for a map to perform well. Most of these were lessons learnt while optimizing RO2 and should al...")
 
No edit summary
Line 49: Line 49:


[[Image:GroupedDynamicPerObjectShadowsDemo.jpg|thumb|600px|center|The image on the left has bAllowMergedDynamicShadows set to false on the two placed pawns, and they cast a per object shadow each. The image on the right has bAllowMergedDynamicShadows set to true on the pawns, and as such both the pawns are included in the same projected shadow.]]
[[Image:GroupedDynamicPerObjectShadowsDemo.jpg|thumb|600px|center|The image on the left has bAllowMergedDynamicShadows set to false on the two placed pawns, and they cast a per object shadow each. The image on the right has bAllowMergedDynamicShadows set to true on the pawns, and as such both the pawns are included in the same projected shadow.]]
= Draw Calls =

Revision as of 17:02, 22 March 2012

The following is a list of items that LDs and Environment Artists should follow for a map to perform well. Most of these were lessons learnt while optimizing RO2 and should also serve as a guideline for modders to make sure that they don't run into the same pitfalls.

Terrain

bCastDynamicShadow

This flag should be OFF. Setting this flag to ON will cast dynamic preshadows by the terrain for both per-object shadows and whole scene dynamic shadows, which can be very expensive depending on the number of dynamic primitives in the scene. Preshadows (which are dynamic shadows from the static environment onto dynamic objects) only make sense if the terrain has hills and valleys throughout the scene. If the scene just has a few mounds here and there it might be worth modeling the mounds with static meshes and have the terrain blend in at the bottom. The side effect of disabling bCastDynamicShadow is that terrain deco layers (e.g. grass) will not cast whole scene dynamic shadows. But considering that shadows from deco layers usually are low-res and don't look great, it is a good price to pay for a substantial performance boost.

Low Res deco layer shadows

Terrain Layers

The RO2 engine allows for a maximum of 12 textures to be blended for terrain. These 12 textures could be part of 2 terrain layers (6 textures each), 3 terrain layers (4 textures each), or any other combination thereof. This is a hard limit for the engine, and exceeding this limit will result in rainbow colored terrain patches. However, fetching and accessing so many textures is not cheap and since the terrain usually takes up a large portion of the screen, it is recommended that you keep the number of blend textures to a minimum.

One example for this is that say you have a terrain which comprises or dirt, rubble and snow and one part of the terrain is solid concrete. Instead of making 4 terrain layers of dirt, rubble, snow and concrete and blending between them it is more optimized if the terrain uses 3 layers of dirt, rubble and snow, and the concrete portion is modeled separately as BSP, static mesh or even another terrain actor. Doing this will reduce the overall cost of rendering the entire terrain since the concrete layer texture fetches are eliminated for the rest of the terrain that doesn't need it.

Static Meshes

bCastDynamicShadow

When placing a static mesh in the level, you should decide whether you want it to cast dynamic preshadows or not. Preshadows are dynamic shadows from the static environment onto dynamic objects, and can be very expensive depending on the number of dynamic primitives in the scene. Turning off this flag for a lot of static meshes in the environment in the scene such as debris, rubble, etc. will improve the dynamic shadow performance.

Dynamic preshadows cast by tree foliage onto character

Once the lighting in a map is finalized, you can also go through and set bCastDynamicShadow to false for all static meshes that are already in shadow (such as the truck in the following image, which is is shadow of the building) since any dynamic shadow cast by it will be drowned by the static shadow cast by the environment.

The truck does not need to cast dynamic shadows since it is already in shadow

Distance Culling

Using distance culling effectively will allow you to have a lot of detail in your environment whilst still allowing the map to perform well. There are 2 ways to do this :

  • You can either put a CullDistanceVolume around the map and the let the map build process choose the appropriate cull distances for the placed static meshes in the level. This method is not ideal though, and might cause certain cover objects, etc. to disappear at a distance (which is not desirable).
  • Or, you can manually set the MaxDrawDistance for each object.

Materials

Using Material LODs

In order to make the best looking environment materials as well as keep the overall performance cost low, consider using material LODs. The concept is very simple - assign the best looking/highest instruction count material to the base LOD for a static mesh, and then create another LOD for the static mesh (this can have the exact same triangle count as the base LOD) and assign it a simple material that does not have expensive operations such as depth biased alpha, specularity, cube maps or even normal maps. Such subtle lighting effects cannot be perceived from a distance anyway, and will make improve the fill rate for the rendered scene.

Base material using normal maps
Simple material that does not use normal maps

Dynamic Actors

bDisablePerObjectShadows

If you place an actor onto a level that casts dynamic shadows, the shadowing cost for it is one per object shadow and in certain cases a preshadow as well. If bDisablePerObjectShadows is set it will only cast dynamic shadows for the primitive if it is within the whole scene dominant shadow radius. This reduces the cost associated with shadowing for the primitive. If whole scene dominant shadows are not enabled, the primitive will not cast any dynamic shadows.

The flag pole is outside the whole scene dominant shadow radius in the image on the left and hence is not shadowed. When the player moves such that the flag pole is now within the whole scene dominant shadow radius, it will start casting whole scene dominant shadows (right image)

bAllowMergedDynamicShadows

If this flag is set, any primitive that allows per object dynamic shadows will be considered for being merged with other primitives that allow merged per object dynamic shadows and are close enough. As a consequence, the number of dynamic shadows in the scene are reduced.

The radius used to merge primitives is dynamically adjusted based on the distance of the primitives from the viewer. It starts at MinShadowGroupRadius (when the primitive is closest to the viewer) and increases up to MaxShadowGroupRadius (when the primitive is ShadowGroupRampCutoff away from the viewer). The rate of increase is determined by ShadowGroupRadiusRampUpFactor. For anything beyond ShadowGroupRampCutoff, the MaxShadowGroupRadius will be used. All these settings are available in the engine INI.

The image on the left has bAllowMergedDynamicShadows set to false on the two placed pawns, and they cast a per object shadow each. The image on the right has bAllowMergedDynamicShadows set to true on the pawns, and as such both the pawns are included in the same projected shadow.

Draw Calls