{"_id":"594949e72be16d0026ec050b","category":{"_id":"594949e62be16d0026ec04db","version":"594949e52be16d0026ec04cd","project":"571fa55ca0acd42000af9545","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-01-01T17:01:47.129Z","from_sync":false,"order":13,"slug":"utilities","title":"Utilities"},"user":"571fa519db52d01700f5cf3d","project":"571fa55ca0acd42000af9545","parentDoc":null,"version":{"_id":"594949e52be16d0026ec04cd","project":"571fa55ca0acd42000af9545","__v":2,"createdAt":"2017-06-20T16:14:29.816Z","releaseDate":"2017-06-20T16:14:29.816Z","categories":["594949e62be16d0026ec04ce","594949e62be16d0026ec04cf","594949e62be16d0026ec04d0","594949e62be16d0026ec04d1","594949e62be16d0026ec04d2","594949e62be16d0026ec04d3","594949e62be16d0026ec04d4","594949e62be16d0026ec04d5","594949e62be16d0026ec04d6","594949e62be16d0026ec04d7","594949e62be16d0026ec04d8","594949e62be16d0026ec04d9","594949e62be16d0026ec04da","594949e62be16d0026ec04db","594949e62be16d0026ec04dc","594949e62be16d0026ec04dd","594949e62be16d0026ec04de","594949e62be16d0026ec04df","594949e62be16d0026ec04e0","594949e62be16d0026ec04e1","59497219f4a8980024dd0631"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Kunekune","version_clean":"3.2.0","version":"3.2.0"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-01-01T17:02:53.724Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":9,"body":"## Overview\n\nAdaptive Quality dynamically changes rendering settings to maintain VR framerate while maximizing GPU utilization.\n\n> **Only Compatible With Unity 5.4 and above**\n\nThere are two goals:\n\n * Reduce the chances of dropping frames and reprojecting\n * Increase quality when there are idle GPU cycles\n\nThis script currently changes the following to reach these goals:\n\n * Rendering resolution and viewport size (aka Dynamic Resolution)\n\nIn the future it could be changed to also change the following:\n\n * MSAA level\n * Fixed Foveated Rendering\n * Radial Density Masking\n * (Non-fixed) Foveated Rendering (once HMDs support eye tracking)\n\nSome shaders, especially Image Effects, need to be modified to work with the changed render scale. To fix them\npass `1.0f / VRSettings.renderViewportScale` into the shader and scale all incoming UV values with it in the vertex\nprogram. Do this by using `Material.SetFloat` to set the value in the script that configures the shader.\n\nIn more detail:\n\n * 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\n * In the `.cs` file: Before using the material (eg. `Graphics.Blit`) add `material.SetFloat(\"_InverseOfRenderViewportScale\", 1.0f / VRSettings.renderViewportScale)`\n\n## Inspector Parameters\n\n * **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,  the first green box that is lit above represents the recommended render target resolution provided by the  current `VRDevice`, the box that is lit below in cyan represents the current resolution and the filled box  represents the current viewport scale. 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.\n * **Allow 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\n * **Allow 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\n * **Msaa Level:** The MSAA level to use.\n * **Scale Render Viewport:** Toggles whether the render viewport scale is dynamically adjusted to maintain VR framerate.\\n\\n If unchecked, the renderer will render at the recommended resolution provided by the current `VRDevice`.\n * **Minimum Render Scale:** The minimum allowed render scale.\n * **Maximum Render Scale:** The maximum allowed render scale.\n * **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.\n * **Render Scale Fill Rate Step Size In Percent:** The fill rate step size in percent by which the render scale levels will be calculated.\n * **Scale Render Target Resolution:** Toggles whether the render target resolution is dynamically adjusted to maintain VR framerate.\\n\\n If unchecked, the renderer will use the maximum target resolution specified by `maximumRenderScale`.\n * **Override Render Viewport Scale:** Toggles whether to override the used render viewport scale level.\n * **Override Render Viewport Scale Level:** The render viewport scale level to override the current one with.\n\n## Class Variables\n\n * `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`.\n * `public static float CurrentRenderScale` - The current render scale. A render scale of `1.0` represents the recommended render target resolution provided by the current `VRDevice`.\n * `public Vector2 defaultRenderTargetResolution` - The recommended render target resolution provided by the current `VRDevice`.\n * `public Vector2 currentRenderTargetResolution` - The current render target resolution.\n\n## Class Methods\n\n### RenderTargetResolutionForRenderScale/1\n\n  > `public static Vector2 RenderTargetResolutionForRenderScale(float renderScale)`\n\n  * Parameters\n   * `float renderScale` - The render scale to calculate the render target resolution with.\n  * Returns\n   * `Vector2` - The render target resolution for `renderScale`.\n\nCalculates and returns the render target resolution for a given render scale.\n\n### BiggestAllowedMaximumRenderScale/0\n\n  > `public float BiggestAllowedMaximumRenderScale()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * `float` - The biggest allowed maximum render scale.\n\nCalculates and returns the biggest allowed maximum render scale to be used for `maximumRenderScale` given the current `maximumRenderTargetDimension`.\n\n### ToString/0\n\n  > `public override string ToString()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * `string` - The summary.\n\nA summary of this script by listing all the calculated render scales with their corresponding render target resolution.\n\n## Example\n\n`VRTK/Examples/039_CameraRig_AdaptiveQuality` displays the frames per second in the centre of the headset view.\nThe debug visualization of this script is displayed near the top edge of the headset view.\nPressing the trigger generates a new sphere and pressing the touchpad generates ten new spheres.\nEventually when lots of spheres are present the FPS will drop and demonstrate the script.","excerpt":"","slug":"vrtk_adaptivequality","type":"basic","title":"VRTK_AdaptiveQuality"}

VRTK_AdaptiveQuality


## Overview Adaptive Quality dynamically changes rendering settings to maintain VR framerate while maximizing GPU utilization. > **Only Compatible With Unity 5.4 and above** 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 size (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 * **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, the first green box that is lit above represents the recommended render target resolution provided by the current `VRDevice`, the box that is lit below in cyan represents the current resolution and the filled box represents the current viewport scale. 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. * **Allow 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 * **Allow 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. * **Scale Render Viewport:** Toggles whether the render viewport scale is dynamically adjusted to maintain VR framerate.\n\n If unchecked, the renderer will render at the recommended resolution provided by the current `VRDevice`. * **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. * **Scale Render Target Resolution:** Toggles whether the render target resolution is dynamically adjusted to maintain VR framerate.\n\n If unchecked, the renderer will use the maximum target resolution specified by `maximumRenderScale`. * **Override Render Viewport Scale:** Toggles whether to override the used render viewport scale level. * **Override Render Viewport Scale Level:** The render viewport 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 static 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.