Guides
Guides
These docs are for v2.2.1. Click to read the latest docs for v3.3.0.

VRTK_AdaptiveQuality

Overview

Adaptive Quality dynamically changes rendering settings to maintain VR framerate while maximizing GPU utilization.

The Adaptive Quality script is attached to the eye object within the [CameraRig] prefab.

There are two goals:

  • Reduce the chances of dropping frames and reprojecting
  • Increase quality when there are idle GPU cycles

This script currently changes the following to reach these goals:

  • Rendering resolution and viewport (aka Dynamic Resolution)

In the future it could be changed to also change the following:

  • MSAA level
  • Fixed Foveated Rendering
  • Radial Density Masking
  • (Non-fixed) Foveated Rendering (once HMDs support eye tracking)

Some shaders, especially Image Effects, need to be modified to work with the changed render scale. To fix them
pass 1.0f / VRSettings.renderViewportScale into the shader and scale all incoming UV values with it in the vertex
program. Do this by using Material.SetFloat to set the value in the script that configures the shader.

In more detail:

  • In the .shader file: Add a new runtime-set property value float _InverseOfRenderViewportScale and add vertexInput.texcoord *= _InverseOfRenderViewportScale to the start of the vertex program
  • In the .cs file: Before using the material (eg. Graphics.Blit) add material.SetFloat("_InverseOfRenderViewportScale", 1.0f / VRSettings.renderViewportScale)

Inspector Parameters

  • Active: Toggles whether the render quality is dynamically adjusted to maintain VR framerate.\n\n If unchecked, the renderer will render at the recommended resolution provided by the current VRDevice.
  • Draw Debug Visualization: Toggles whether to show the debug overlay.\n\n Each square represents a different level on the quality scale. Levels increase from left to right, and the first green box that is lit above represents the recommended render target resolution provided by the current VRDevice. The yellow boxes represent resolutions below the recommended render target resolution.\n The currently lit box becomes red whenever the user is likely seeing reprojection in the HMD since the application isn't maintaining VR framerate. If lit, the box all the way on the left is almost always lit red because it represents the lowest render scale with reprojection on.
  • Responds To Keyboard Shortcuts: Toggles whether to allow keyboard shortcuts to control this script.\n\r The supported shortcuts are:\r Shift+F1: Toggle debug visualization on/off\r Shift+F2: Toggle usage of override render scale on/off\r Shift+F3: Decrease override render scale level\r * Shift+F4: Increase override render scale level
  • Responds To Command Line Arguments: Toggles whether to allow command line arguments to control this script at startup of the standalone build.\n\r The supported command line arguments all begin with '-' and are:\r -noaq: Disable adaptive quality\r -aqminscale X: Set minimum render scale to X\r -aqmaxscale X: Set maximum render scale to X\r -aqmaxres X: Set maximum render target dimension to X\r -aqfillratestep X: Set render scale fill rate step size in percent to X (X from 1 to 100)\r -aqoverride X: Set override render scale level to X\r -vrdebug: Enable debug visualization\r * -msaa X: Set MSAA level to X
  • Msaa Level: The MSAA level to use.
  • Minimum Render Scale: The minimum allowed render scale.
  • Maximum Render Scale: The maximum allowed render scale.
  • Maximum Render Target Dimension: The maximum allowed render target dimension.\n\n This puts an upper limit on the size of the render target regardless of the maximum render scale.
  • Render Scale Fill Rate Step Size In Percent: The fill rate step size in percent by which the render scale levels will be calculated.
  • Override Render Scale: Toggles whether to override the used render scale level.
  • Override Render Scale Level: The render scale level to override the current one with.

Class Variables

  • public readonly ReadOnlyCollection<float> renderScales - All the calculated render scales. The elements of this collection are to be interpreted as modifiers to the recommended render target resolution provided by the current VRDevice.
  • public float currentRenderScale - The current render scale. A render scale of 1.0 represents the recommended render target resolution provided by the current VRDevice.
  • public Vector2 defaultRenderTargetResolution - The recommended render target resolution provided by the current VRDevice.
  • public Vector2 currentRenderTargetResolution - The current render target resolution.

Class Methods

RenderTargetResolutionForRenderScale/1

public static Vector2 RenderTargetResolutionForRenderScale(float renderScale)

  • Parameters
  • float renderScale - The render scale to calculate the render target resolution with.
  • Returns
  • Vector2 - The render target resolution for renderScale.

Calculates and returns the render target resolution for a given render scale.

BiggestAllowedMaximumRenderScale/0

public float BiggestAllowedMaximumRenderScale()

  • Parameters
  • none
  • Returns
  • float - The biggest allowed maximum render scale.

Calculates and returns the biggest allowed maximum render scale to be used for maximumRenderScale given the current maximumRenderTargetDimension.

ToString/0

public override string ToString()

  • Parameters
  • none
  • Returns
  • string - The summary.

A summary of this script by listing all the calculated render scales with their corresponding render target resolution.

Example

VRTK/Examples/039_CameraRig_AdaptiveQuality displays the frames per second in the centre of the headset view.
The debug visualization of this script is displayed near the top edge of the headset view.
Pressing the trigger generates a new sphere and pressing the touchpad generates ten new spheres.
Eventually when lots of spheres are present the FPS will drop and demonstrate the script.