Class AbstractUpscaler
Base class for an upscaling technology implementation.
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public abstract class AbstractUpscaler : IUpscaler, IRenderGraphRecorder
Properties
hasQualityMode
Returns true if the upscaler exposes a quality mode that can dictate the render resolution (e.g. the DLSS/FSR presets). When false, the upscaler has no opinion on resolution and the pipeline drives the render resolution (e.g. STP, spatial filters), which is equivalent to CustomScaling.
Declaration
public virtual bool hasQualityMode { get; }
Property Value
| Type | Description |
|---|---|
| bool |
isSupportedOnDevice
Returns true if the upscaler can run on the current device.
Declaration
public virtual bool isSupportedOnDevice { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Queried when selecting an upscaler, so it must be cheap. Implementations that need to probe hardware or a plugin should do so once and return the cached result.
isTemporal
Returns true if the upscaler uses temporal information from previous frames.
Declaration
public abstract bool isTemporal { get; }
Property Value
| Type | Description |
|---|---|
| bool |
name
Gets the display name of the upscaler (e.g., "FSR2").
Declaration
public abstract string name { get; }
Property Value
| Type | Description |
|---|---|
| string |
reactiveMaskSource
Returns the type of reactive mask that the upscaler requires.
Declaration
public virtual ReactiveMaskSource reactiveMaskSource { get; }
Property Value
| Type | Description |
|---|---|
| ReactiveMaskSource |
supportsAlphaUpscaling
Returns true if the alpha channel of the upscaler's output is valid.
Declaration
public virtual bool supportsAlphaUpscaling { get; }
Property Value
| Type | Description |
|---|---|
| bool |
supportsSharpening
Returns true if the upscaler supports sharpening within the upscaling pass.
Declaration
public abstract bool supportsSharpening { get; }
Property Value
| Type | Description |
|---|---|
| bool |
upscalerId
Gets the stable identifier of the upscaler (e.g., "unity.stp"), which render pipeline assets serialize.
Declaration
public abstract string upscalerId { get; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Prefix the ID to keep it unique, and never change it once shipped: This is never localized and never shown to users.
Methods
CalculateJitter(int, float, out Vector2, out bool)
Calculates the pixel jitter for the current frame.
Declaration
public virtual void CalculateJitter(int frameIndex, float upscaleRatio, out Vector2 jitter, out bool allowScaling)
Parameters
| Type | Name | Description |
|---|---|---|
| int | frameIndex | The index of the current frame, used to cycle through jitter patterns. |
| float | upscaleRatio | The ratio of output resolution to input resolution (e.g., 2.0 for 1080p → 4K). |
| Vector2 | jitter | Outputs the calculated sub-pixel jitter vector. |
| bool | allowScaling | Outputs whether the jitter vector permits scaling relative to resolution. |
CalculateMipBias(Vector2Int, Vector2Int)
Calculates the recommended global mip bias for texture sampling during rendering. Temporal upscalers typically recommend a negative bias to sample finer mip levels, providing more detail for temporal accumulation.
Declaration
public virtual float CalculateMipBias(Vector2Int preUpscaleResolution, Vector2Int postUpscaleResolution)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2Int | preUpscaleResolution | The render resolution before upscaling. |
| Vector2Int | postUpscaleResolution | The target display resolution after upscaling. |
Returns
| Type | Description |
|---|---|
| float | The recommended mip bias value (typically negative when upscaling). |
Remarks
The standard formula is log2(renderWidth / displayWidth), which produces negative
values when upscaling (e.g., -1.0 for 2x upscaling). Some upscalers recommend an additional
offset (e.g., -1.0) for sharper results.
When a temporal upscaler is active, the render pipeline should use this value directly,
bypassing any TAA mip bias settings.
The render pipelines must guarantee this method is only called when upscaling is active
(preUpscaleResolution < postUpscaleResolution). Implementations do not need to handle
the no-upscaling case.
CreateContext(UpscalerOptions, Vector2Int)
Creates a new context for this upscaler. Upscaler authors implement this to create per-camera state. Called by the context manager when a new camera needs upscaling or when an existing context is invalidated.
Declaration
public virtual IUpscalerContext CreateContext(UpscalerOptions options, Vector2Int displayResolution)
Parameters
| Type | Name | Description |
|---|---|---|
| UpscalerOptions | options | The upscaler options to create the context with. |
| Vector2Int | displayResolution | The target display resolution. |
Returns
| Type | Description |
|---|---|
| IUpscalerContext | A new context instance, or null for spatial upscalers that don't need context. |
GetResolutionInfo(Vector2Int, UpscalerOptions)
Gets resolution information for this upscaler given a display resolution and options. Used by pipelines to configure DRS bounds or display resolution info in UI.
Declaration
public virtual UpscalerResolutionInfo GetResolutionInfo(Vector2Int displayResolution, UpscalerOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2Int | displayResolution | The target display/output resolution. |
| UpscalerOptions | options | The upscaler options to use for resolution calculation. |
Returns
| Type | Description |
|---|---|
| UpscalerResolutionInfo | Resolution info containing optimal and optional min/max resolutions. |
Remarks
DLSS and XeSS provide per-quality-mode min/max ranges via their SDK APIs. FSR2 provides only optimal resolution (no per-quality range). Spatial upscalers return the display resolution unchanged.
The options parameter is provided by the framework (Upscaling.GetGlobalOptions) and enables future per-camera quality settings; pipelines pass the framework-resolved options (asset default today; per-camera later).
Example usage:
var info = upscaler.GetResolutionInfo(displayResolution, upscaling.GetGlobalOptions(upscaler));
if (info.constraint == UpscalerResolutionConstraint.Range)
{
drsSettings.minPercentage = (float)info.minResolution.x / displayResolution.x * 100f;
drsSettings.maxPercentage = (float)info.maxResolution.x / displayResolution.x * 100f;
}
RecordRenderGraph(RenderGraph, ContextContainer)
This function is called during render graph recording and allows the implementing class to register the relevant passes and resources to the passed in render graph. To access information about the current execution context (current camera, ...) the ContextContainer can be queried. See the render pipeline documentation for more information on the types that are available in the context container. (The exact types available may differ based on the currently active render pipeline). This is where custom rendering occurs. Specific details are left to the implementation.
Declaration
public virtual void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
Parameters
| Type | Name | Description |
|---|---|---|
| RenderGraph | renderGraph | The graph to register resources and passes with. |
| ContextContainer | frameData | A ContextContainer that allows querying information about the current execution context (.e.g. RenderPipeline camera info). |