Lesson 113 +10 XP

Dynamic Resolution

Dynamic resolution dynamically scales the primary render targets to reduce GPU load and maintain stable target frame rates.

How It Works

Instead of modifying the viewport display window size:

  1. Unity renders target buffers to a smaller fraction of screenspace.
  1. The scaled render target is upscaled back to match the native display resolution before post-processing.

Enabling Dynamic Resolution

  1. Open your URP or HDRP Render Pipeline Asset.
  1. Enable the Dynamic Resolution checkbox.
  1. On the Camera component inspector, check Allow Dynamic Resolution.

Controlling Scale with Scripts

To set the scale at runtime, call the ScalableBufferManager API:


csharp
using UnityEngine;

public class PerformanceManager : MonoBehaviour
{
    void Update()
    {
        if (GetPerformanceLoad() > 0.9f)
        {
            // Reduce render size to 70% in width and height

### ScalableBufferManager.ResizeBuffers(0.7f, 0.7f);
        }
        else
        {
            // Reset to native scale

### ScalableBufferManager.ResizeBuffers(1.0f, 1.0f);
        }
    }

private float GetPerformanceLoad() => 0.95f; // Mock implementation
}

Using FrameTimingManager

Combine dynamic resolution with the FrameTimingManager class to scale rendering according to measured GPU frame times:


csharp
// Captures timing data from the GPU rendering cycle

### FrameTimingManager.CaptureFrameTimings();

TL;DR

  • Enable Dynamic Resolution to adjust rendering load dynamically.
  • Use ScalableBufferManager.ResizeBuffers() to set resolution scale.
  • Integrates with FrameTimingManager to calculate performance scale targets.