Hi,
the DynamicResolutionHandler.SetDynamicResScaler for custom DLSS scaling values doesn’t work as advertised in the docs:
I had it working before we recently updated to newer version of 2022 LTS, in the early versions of 22 LTS it worked. I am not exactly sure what update broke it.
The issue is that the DynamicResolutionHandler is not properly loading the settings and always runs with default values when not using the “Use Optimal Settings” flag in the inspector of a HDRP Camera.
I have filed a bug report with CASE IN-87236.
Here is code that demonstrates the issue or if somebody else is looking for a solution:
public class Scaler : MonoBehaviour
{
/// <summary>
/// This should work and has worked in the past based off the documentation https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/Dynamic-Resolution.html
/// </summary>
public void Awake()
{
DynamicResolutionHandler.SetDynamicResScaler(SetDynamicResolutionScale, DynamicResScalePolicyType.ReturnsPercentage);
}
public float SetDynamicResolutionScale()
{
//With this reflection code it starts working due to forcint the min screen fraction. Likely other values are not working as advertised as well.
//ReflectionHack();
return Random.Range(25f, 100f);
}
private static void ReflectionHack()
{
var instance = DynamicResolutionHandler.instance;
var minScreenFractionField = typeof(DynamicResolutionHandler).GetField("m_MinScreenFraction", BindingFlags.NonPublic | BindingFlags.Instance);
if (minScreenFractionField != null && instance != null)
{
minScreenFractionField.SetValue(instance, 0.25f);
}
}
}
When using the reflection code in here, it overwrites the min scaling value of the settings and the scaling works again. But this should be fixed as all the other settings values in there don’t work either.