-
Notifications
You must be signed in to change notification settings - Fork 855
[Universal] Make sure upgrading to Universal RP 2021 does not change Spot Light shadow resolutions #3831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Universal] Make sure upgrading to Universal RP 2021 does not change Spot Light shadow resolutions #3831
Changes from all commits
94393c1
204a9e1
1f7e953
cd1b5e8
aac184c
43ed67d
82f939d
e6b8db2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,8 +104,8 @@ public partial class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerial | |
ScriptableRenderer[] m_Renderers = new ScriptableRenderer[1]; | ||
|
||
// Default values set when a new UniversalRenderPipeline asset is created | ||
[SerializeField] int k_AssetVersion = 8; | ||
[SerializeField] int k_AssetPreviousVersion = 8; | ||
[SerializeField] int k_AssetVersion = 9; | ||
[SerializeField] int k_AssetPreviousVersion = 9; | ||
|
||
// Deprecated settings for upgrading sakes | ||
[SerializeField] RendererType m_RendererType = RendererType.UniversalRenderer; | ||
|
@@ -139,9 +139,9 @@ public partial class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerial | |
[SerializeField] bool m_AdditionalLightShadowsSupported = false; | ||
[SerializeField] ShadowResolution m_AdditionalLightsShadowmapResolution = ShadowResolution._2048; | ||
|
||
[SerializeField] int m_AdditionalLightsShadowResolutionTierLow = 256; | ||
[SerializeField] int m_AdditionalLightsShadowResolutionTierMedium = 512; | ||
[SerializeField] int m_AdditionalLightsShadowResolutionTierHigh = 1024; | ||
[SerializeField] int m_AdditionalLightsShadowResolutionTierLow = AdditionalLightsDefaultShadowResolutionTierLow; | ||
[SerializeField] int m_AdditionalLightsShadowResolutionTierMedium = AdditionalLightsDefaultShadowResolutionTierMedium; | ||
[SerializeField] int m_AdditionalLightsShadowResolutionTierHigh = AdditionalLightsDefaultShadowResolutionTierHigh; | ||
|
||
// Shadows Settings | ||
[SerializeField] float m_ShadowDistance = 50.0f; | ||
|
@@ -186,6 +186,10 @@ public partial class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerial | |
internal const int k_ShadowCascadeMinCount = 1; | ||
internal const int k_ShadowCascadeMaxCount = 4; | ||
|
||
public static readonly int AdditionalLightsDefaultShadowResolutionTierLow = 256; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if I like constant tiers. It doesn't scale very well. IMO user should just be able to put a number or 2^N for pot. It' depends on the platform and content what's suitable. |
||
public static readonly int AdditionalLightsDefaultShadowResolutionTierMedium = 512; | ||
public static readonly int AdditionalLightsDefaultShadowResolutionTierHigh = 1024; | ||
|
||
#if UNITY_EDITOR | ||
[NonSerialized] | ||
internal UniversalRenderPipelineEditorResources m_EditorResourcesAsset; | ||
|
@@ -934,6 +938,25 @@ public void OnAfterDeserialize() | |
k_AssetVersion = 8; | ||
} | ||
|
||
if (k_AssetVersion < 9) | ||
{ | ||
bool assetContainsCustomAdditionalLightShadowResolutions = | ||
m_AdditionalLightsShadowResolutionTierHigh != AdditionalLightsDefaultShadowResolutionTierHigh || | ||
m_AdditionalLightsShadowResolutionTierMedium != AdditionalLightsDefaultShadowResolutionTierMedium || | ||
m_AdditionalLightsShadowResolutionTierLow != AdditionalLightsDefaultShadowResolutionTierLow; | ||
|
||
if (!assetContainsCustomAdditionalLightShadowResolutions) | ||
{ | ||
// if all resolutions are still the default values, we assume that they have never been customized and that it is safe to upgrade them to fit better the Additional Lights Shadow Atlas size | ||
m_AdditionalLightsShadowResolutionTierHigh = (int)m_AdditionalLightsShadowmapResolution; | ||
m_AdditionalLightsShadowResolutionTierMedium = Mathf.Max(m_AdditionalLightsShadowResolutionTierHigh / 2, UniversalAdditionalLightData.AdditionalLightsShadowMinimumResolution); | ||
m_AdditionalLightsShadowResolutionTierLow = Mathf.Max(m_AdditionalLightsShadowResolutionTierMedium / 2, UniversalAdditionalLightData.AdditionalLightsShadowMinimumResolution); | ||
} | ||
|
||
k_AssetPreviousVersion = k_AssetVersion; | ||
k_AssetVersion = 9; | ||
} | ||
|
||
#if UNITY_EDITOR | ||
if (k_AssetPreviousVersion != k_AssetVersion) | ||
{ | ||
|
@@ -964,10 +987,10 @@ static void UpgradeAsset(UniversalRenderPipelineAsset asset) | |
asset.k_AssetPreviousVersion = 5; | ||
} | ||
|
||
if (asset.k_AssetPreviousVersion < 8) | ||
if (asset.k_AssetPreviousVersion < 9) | ||
{ | ||
// The added feature was reverted, we keep this version to avoid breakage in case somebody already has version 7 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Comment needs updating. Should the comment be generic to say previous version instead of explicitly saying 7 or 8, etc. |
||
asset.k_AssetPreviousVersion = 8; | ||
asset.k_AssetPreviousVersion = 9; | ||
} | ||
|
||
EditorUtility.SetDirty(asset); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't from this change, but we really need to get away from defaulting to power of two sizes. Most modern GPU architectures support non power of two sizes, and it is only really relevant for mipmaps and compressed formats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is a atlas fitting limitation, then it is a bit more understandable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in the case of Additional Light shadows, it is a limitation of the current (simple) atlas fitting.