/GraphicsConfigurator

API for managing URP asset parameters, including hacking of parameters that are forbidden to change

Primary LanguageC#MIT LicenseMIT

GraphicsConfigurator

openupm Codacy Badge

API for managing URP asset parameters, including hacking of parameters that are forbidden to change.

Table of Contents

Problem

Unity closed access to change important parameters such as shadows casting, shadow resolution, lighting modes, etc.

If you want to give the user the ability to customize the resolution of shadows, then the suggestion from unit sounds like this: "create multiple assets and rearrange them"

If you follow this way, you will have to create hundreds of pipeline assets to give users the ability to customize the graphics settings.

At the moment the Unity dev team does not disclose the reasons why they closed the ability to change many important parameters.

Solution

Create a wrapper to bypass the restrictions to modify private parameters.

Download

URP LINK
11.0.0 ⬇️
10.3.1, 10.3.2 ⬇️

How to use

  1. Add wrapper to your project (installation)
  2. Include wrapper library in code (how)
  3. Change any parameters of the URP Asset in one line. In the bag 👏

Installation

Install via OpenUPM

The package is available on the openupm registry. It's recommended to install it via openupm-cli.

openupm add com.inc8877.graphicsconfigurator

Install via Git URL

Open Packages/manifest.json with your favorite text editor. Add the following line to the dependencies block.

{
  "dependencies": {
    "com.inc8877.graphicsconfigurator": "https://github.com/inc8877/GraphicsConfigurator.git",
   }
}

Include GraphicsConfigurator .dll into the project

Add .dll to your project, you can find it in every release. You can find a suitable version here

Examples

First, plugin necessary libraries

using GraphicsConfigurator.API.URP;
using UnityEngine.Rendering.Universal;
using ShadowResolution = UnityEngine.Rendering.Universal.ShadowResolution;


To change the active URP Asset, you need to do the following:

// ...
// code somewhere
Configuring.CurrentURPA.OpaqueDownsampling(Downsampling._4xBox);
Configuring.CurrentURPA.AntiAliasing(MsaaQuality._4x);

Configuring.CurrentURPA.MainLightMode(LightRenderingMode.PerPixel);
Configuring.CurrentURPA.MainLightShadowsCasting(true);
Configuring.CurrentURPA.MainLightShadowResolution(ShadowResolution._1024);
// ...


If you want to work with a specific URP Asset, do it like this:

private URPAssetConfiguring URPA = new URPAssetConfiguring(target);

// ...
// code somewhere
URPA.MainLightShadowsCasting(true);
URPA.Cascade3Split(new Vector2(0.1f, 0.3f));
// ...

Tested devices

CPU GPU OS Graphics API Backend .Net
SD 855 Adreno 640 Android 10.3.8 Vulkan IL2CPP 4.x
SD 845 Adreno 630 Android 10.3.7 Vulkan IL2CPP 4.x
i7 6700HQ AMD Randeon Pro 450 macOS 11.2.1 Metal IL2CPP 4.x

Known issues

  • When there is a change in the additional light rendering mode with the display of the target asset in the inspector, then the mode changes briefly, after which it has the parameters that were set before the change was attempted. This happens only in editor mode, it is not observed in assemblies. If, in editor mode, you try to change the rendering mode of the additional light and do not display the target asset in the inspector, then everything is successful. Presumably the problem lies in the way the asset editor works.