Skip to content

Game.Settings.GraphicsSettings

Assembly: Assembly-CSharp (game)
Namespace: Game.Settings

Type: class

Base: GlobalQualitySettings

Summary:
GraphicsSettings holds the game's global graphics configuration and wraps many per-feature quality settings (dynamic resolution, AA, shadows, volumetrics, water, LOD, etc.). It integrates with the Screen/Display helper code to enumerate and apply resolutions and display modes, manages a small HDRP Volume used for quality overrides, and contains logic to enable/configure NVIDIA DLSS via HDAdditionalCameraData when available. This class is the primary entry for graphics-related options exposed in the game's settings UI and is used by SharedSettings.instance.graphics.


Fields

  • private int m_resolutionItemsVersion
    Tracks a version counter that increments when resolution dropdown items need rebuilding (used to tell UI to refresh the resolution list).

  • private const string kName = "Graphics"
    Constant name for the settings file/section (used by Settings system).

  • private bool m_ShowAllResolutions
    Backing field for showAllResolutions; when true, lists all available resolutions including uncommon refresh rates.

  • private ScreenResolution m_Resolution
    Backing field for the selected ScreenResolution. resolution property clamps to an available resolution using ScreenHelper.

  • private int m_DlssQuality
    Internal numeric DLSS quality index used to configure HDAdditionalCameraData. -1 means DLSS disabled.

  • private static Camera m_Camera
    Cached reference to the gameplay camera used when applying DLSS settings.

  • private static Volume m_VolumeOverride
    A global HDRP Volume created by the settings class to hold runtime overrides for quality-related VolumeComponents (e.g., fog, clouds, volumetrics).

  • private const int kDisplayIndexNotSelected = -1
    Constant used to indicate that display index is not explicitly selected (falls back to active).

  • Several public and private constant group names (kMainGroup, kDepthOfFieldGroup, kQualityGroup, kUpscalersGroup) used by the settings UI to group items.

Properties

  • public int currentDisplayIndex { get; set; }
    Public property used by the UI. Getter returns displayIndex if explicitly set; otherwise it queries active display layout and returns the active display index. Setter writes displayIndex. Has platform/UI attributes (PC-only dropdown, hidden when multiple displays exist, setter calls OnSetDisplayIndex).

  • public int displayIndex { get; set; }
    Public auto-property used to store chosen display index. Default -1 means "not selected" (use active).

  • public bool showAllResolutions { get; set; }
    When set, toggles listing all available resolutions (including uncommon refresh rates). Changing this will rebuild/refresh the selected resolution to the closest available entry.

  • public ScreenResolution resolution { get; set; }
    Selected screen resolution. Setter clamps the provided resolution to the closest available using ScreenHelper.GetClosestAvailable(..., showAllResolutions).

  • public DisplayMode displayMode { get; set; }
    Selected display mode (Windowed/Borderless/Fullscreen). Changing to fullscreen triggers a confirmation UI in OptionsUISystem.

  • public bool vSync { get; set; }
    Vertical sync toggle. Applied to QualitySettings.vSyncCount on Apply().

  • public int maxFrameLatency { get; set; }
    Matches QualitySettings.maxQueuedFrames; exposed as a slider in UI (integer 1..3).

  • public CursorMode cursorMode { get; set; }
    Cursor behavior (Free or ConfinedToWindow), applied with Cursor.lockState on Apply().

  • public DepthOfFieldMode depthOfFieldMode { get; set; }
    Depth-of-field mode selection (Disabled, Physical, TiltShift). Some tilt-shift related properties are disabled unless TiltShift is active.

  • public float tiltShiftNearStart / tiltShiftNearEnd / tiltShiftFarStart / tiltShiftFarEnd
    Advanced per-tilt-shift sliders controlling the tilt-shift DOF distances (0..1 scaled in UI as percentage).

  • public DlssQuality dlssQuality { get; set; }
    Requested DLSS quality (Off, Auto, MaximumQuality, Balanced, MaximumPerformance, UltraPerformance). Actual DLSS enabled/quality may be decided at runtime (ApplyDLSSAutoSettings).

  • public bool isDlssActive { get; }
    True when DLSS has been detected and m_DlssQuality >= 0 (i.e., enabled and mapped to an internal DLSS index).

  • public bool isFsr2Active { get; }
    Currently returns false (placeholder for FSR2 detection/activation).

  • private bool isDLSSDisabled { get; }
    Private helper property used by UI to disable DLSS dropdown when DLSS isn't detected or FSR2 is active.

  • private bool isFSRDisabled { get; }
    Private helper property (returns isDlssActive) used to disable FSR when DLSS is active.

Constructors

  • public GraphicsSettings()
    Creates/initializes the HDRP volume override, registers and adds all per-feature quality settings (DynamicResolutionScaleSettings, AntiAliasingQualitySettings, CloudsQualitySettings, FogQualitySettings, VolumetricsQualitySettings, SSAO, SSGI, SSR, DepthOfFieldQualitySettings, MotionBlur, Shadows, Terrain, Water, LOD, Animation, Texture, etc.), then calls SetDefaults().

Methods

  • static GraphicsSettings() (static constructor)
    Registers default quality setting names and default GlobalQualitySettings instances for various Level values (Disabled/Low/Medium/High) using QualitySetting.RegisterSetting.

  • public override AutomaticSettings.SettingPageData GetPageData(string id, bool addPrefix)
    Builds the UI page data for the graphics settings. Adds a manual "global quality" dropdown mapped to the Level enum and adds each nested QualitySetting to the page.

  • internal override void AddToPageData(AutomaticSettings.SettingPageData pageData)
    (Empty override) reserved for adding to other pages.

  • public override void Apply()
    Apply global graphics options:

  • Calls base.Apply() to let per-quality settings apply.
  • Calls ApplyResolution() to move window/apply resolution/display mode if needed (may start coroutine to move main window).
  • Sets QualitySettings.vSyncCount and maxQueuedFrames.
  • Sets Cursor.lockState.
  • Attempts to get gameplay Camera and applies DLSS auto settings to it (ApplyDLSSAutoSettings).
  • Iterates and applies all registered quality setting objects and logs current state.

  • private int GetActiveDisplayIndex(out IReadOnlyList<DisplayInfo> displayInfos)
    Returns active display index by querying Screen.GetDisplayLayout(...) and comparing to Screen.mainWindowDisplayInfo. Also returns the list of displays.

  • private IEnumerator MoveToDisplay(DisplayInfo display)
    Coroutine that moves the main window to the chosen display (calls Screen.MoveMainWindowTo), rebuilds resolution list and triggers resolution item rebuild.

  • public void ApplyResolution()
    Ensures displayIndex is valid relative to available displays; if active display differs from selected index, starts MoveToDisplay coroutine. Compares current resolution and display mode to desired; if different and resolution.isValid, calls Screen.SetResolution with the selected settings. Logs errors for invalid resolution.

  • private DLSSQuality ToDlssQuality(DlssQuality dlssQuality)
    Maps the internal DlssQuality enum to the engine DLSSQuality enum; throws an Exception for unsupported values.

  • private void ApplyDLSSAutoSettings(Camera camera)
    Configures m_DlssQuality based on detection and dlssQuality setting:

  • If DLSS detected and dlssQuality == Auto, chooses an effective quality depending on pixel count of current resolution.
  • Sets m_DlssQuality numeric index or -1 if disabled.
  • Updates HDAdditionalCameraData.allowDeepLearningSuperSampling, deepLearningSuperSamplingUseCustomQualitySettings and deepLearningSuperSamplingQuality accordingly.

  • private void CreateVolumeOverride()
    Creates the HDRP volume used for runtime overrides if not already created (VolumeHelper.CreateVolume).

  • private void CleanupVolumeOverride()
    Destroys the override volume (VolumeHelper.DestroyVolume).

  • public T GetVolumeOverride<T>() where T : VolumeComponent
    Returns the requested VolumeComponent from the settings override volume profile if present, otherwise null.

  • public override void SetDefaults()
    Sets defaults for the graphics settings (showAllResolutions=false, displayIndex=-1, resolution/displayMode = current, depthOfFieldMode=Physical, vSync=false, tilt-shift defaults, maxFrameLatency from QualitySettings, cursorMode=ConfinedToWindow, dlssQuality = Auto if detected else Off) and calls base.SetDefaults() to initialize quality settings.

  • public void OnSetResolution(ScreenResolution resolution)
    UI setter hook called when user changes resolution from UI. If switching to Fullscreen, shows display confirmation dialog via OptionsUISystem.

  • public void OnSetDisplayMode(DisplayMode mode)
    UI setter hook called when display mode changes. If about to change to Fullscreen, shows confirmation.

  • public void OnSetDisplayIndex(int index)
    UI setter hook called for display index changes. If fullscreen, shows confirmation.

  • public bool IsTiltShiftDisabled()
    Returns true when depthOfFieldMode is not TiltShift (used to disable tilt-shift sliders in UI).

  • public void OnResolutionItemsNeedRebuild(bool value)
    UI hook that increments m_resolutionItemsVersion to notify UI of changes in the resolution list.

  • public int GetResolutionItemsVersion()
    Returns m_resolutionItemsVersion (used by Settings UI to know when to refresh options).

  • [Preserve] public static DropdownItem<int>[] GetDisplayIndexValues()
    Builds and returns dropdown items for the available displays (index and localized display name).

  • [Preserve] public static DropdownItem<ScreenResolution>[] GetScreenResolutionValues()
    Returns a localized list of available ScreenResolution entries (uses SharedSettings.instance.graphics.showAllResolutions to decide which set to return) for the resolution dropdown.

  • private bool IsDLSSDectected()
    Returns true when HDDynamicResolutionPlatformCapabilities.DLSSDetected is true (runtime DLSS detection). Used by DLSS enable/disable logic.

Usage Example

// Example: change resolution, set fullscreen, enable v-sync and apply.
var graphics = SharedSettings.instance.graphics; // or create new GraphicsSettings() in tests
graphics.showAllResolutions = false;
graphics.displayIndex = -1; // use active display
graphics.resolution = ScreenHelper.currentResolution; // or a ScreenResolution you obtained from ScreenHelper.GetAvailableResolutions(...)
graphics.displayMode = DisplayMode.Fullscreen;
graphics.vSync = true;
graphics.maxFrameLatency = 2;
graphics.dlssQuality = GraphicsSettings.DlssQuality.Auto;

// Apply to the running game (this will handle moving windows, setting resolution, toggling DLSS on the gameplay camera, etc.)
graphics.Apply();

Notes for modders: - The settings class integrates tightly with the game's ScreenHelper and OptionsUISystem. If you programmatically change resolution/display, OptionsUISystem may show a confirmation UI when switching to fullscreen. - DLSS configuration is applied to the gameplay Camera via HDAdditionalCameraData. Ensure you call Apply() after changing settings, or directly manipulate HDAdditionalCameraData if you need immediate effect. - Volume overrides are created in the constructor and can be accessed via GetVolumeOverride() to read or modify HDRP Volume components used by the various quality setting objects.