-
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
Conversation
It appears that you made a non-draft PR! |
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.
LGTM
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.
Some minor changes to the upgrader, seems like a merge issue, we really need to update this upgrader, a bunch of 'ifs' is not the way :(
k_AssetVersion = 7; | ||
} | ||
|
||
if (k_AssetVersion < 8) |
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.
Seems there was a merge issue at some point and we have ended up with 2 version 8 upgraders, this one needs to be 9 and moved after the version 8 below it
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.
and further down in static void UpgradeAsset(UniversalRenderPipelineAsset asset) we need to bump the last check to be version 9 not 8 too
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.
Thanks for noticing this.
I fixed it in 1b2caec, can you please check the change?
Should I also bump the version numbers in UpgradeAsset in the 2021.1 backport PR?
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.
Fix looks good, for now we have to hold off back porting to 21.1 since it seems there is another upgrader that hasn't been back ported, this would cause some severe issues with users so I'm looking to get answers on what to do here.
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.
Thanks for the info about 21.1.
It seems that it would be better if both 2021.2 (this PR) and 2021.1 (backport PR) landed together at the same time?
Please notify when you know what more we should do for 21.1.
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.
@lukaschod
Will #3089 be back-ported to branch https://github.com/Unity-Technologies/Graphics/tree/2021.1/staging ?
It seems that UniversalRenderPipelineAsset.k_AssetVersion = 8
means "UniversalRenderPipelineAsset version containing improved shadow fade settings".
(With the current PR, we would have UniversalRenderPipelineAsset.k_AssetVersion = 9
meaning "UniversalRenderPipelineAsset version containing auto-upgraded spot light shadow resolutions".)
Having "auto-upgraded spot light shadow resolutions" available in 2021.2 but not in 2021.1 might be surprising for users ("when upgrading project to 2021.1 nothing happened, but it changed when upgrading again to 2021.2!?"). Therefore I would like to land both pull requests #3831 and #3832 together.
@lukaschod
If you plan to back-port #3089 to 2021.1, then #3832 has to wait (because asset update must happen in increasing version order).
If you don't plan to back-port #3089 to 2021.1, then on 2021.1 we can directly skip UniversalRenderPipelineAsset.k_AssetVersion
from 7 to 9, and we will be able to land #3831 and #3832.
Please tell us, so that we can decide which path to take.
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.
Nop I do not plan to backport #3089. It has some core changes and I do not want to introduce that risk.
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.
Thanks a lot for the info Lukas.
I updated UniversalRenderPipelineAsset.k_AssetVersion
in my 2021.1 backport pull request to match with this pull request (2021.2).
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.
Appears to be working.
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.
LGTM
var fieldSlot = new Rect(contentRect.x + pixelShift, contentRect.y, num - labelWidth, contentRect.height); // Define the rectangle for the field | ||
int value = EditorGUI.DelayedIntField(fieldSlot, values[index].intValue); | ||
values[index].intValue = Mathf.Max(128, Mathf.NextPowerOfTwo(value)); | ||
values[index].intValue = Mathf.Max(UniversalAdditionalLightData.AdditionalLightsShadowMinimumResolution, Mathf.NextPowerOfTwo(value)); |
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.
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 comment
The 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.
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.
LGTM
…dditionalLightData.AdditionalLightsShadowMinimumResolution
…e Spot Light shadow resolutions (internal ticket https://fogbugz.unity3d.com/f/cases/1316540 )
…lues if it seems that they have never been customized (@Verasl suggestion)
…ltShadowResolutionTier... constant definitions outside of #if UNITY_EDITOR block
…nsparentReceiveShadow spot light shadow resolution to higher tier to match previous settings
c92f728
to
43ed67d
Compare
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 comment
The 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.
This is not a deal breaker though.
|
||
if (k_AssetVersion < 9) | ||
{ | ||
if (m_AdditionalLightsShadowResolutionTierHigh == AdditionalLightsDefaultShadowResolutionTierHigh && |
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.
Maybe add a function "isCustomShadowResolution" or a local boolean at least.
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.
Thanks for the suggestion, I added an intermediate variable in 82f939d
… (comment)) (cherry picked from commit 82f939d)
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.
looks good
Lots of failed tests. Master should be failing only Hybrid Tests, maybe if you merge master and rerun it will give a better idea. |
…ith the one in 2021.2 pull request - see conversation #3831 (comment)
Thanks for the info @phi-lira, I merged main branch and now there are no more failures, apart from Hybrid Tests (or Bokken test infrastructure issues not related to this pull request). What about branch 2021.1/staging, are there some failures expected on that branch? |
Everything looks OK on both 2021.2 and 2021.1, I'm merging the pull requests. |
…1 does not change Spot Light shadow resolutions (#3832) * [UniversalRP] Replace some magic numbers by named variable UniversalAdditionalLightData.AdditionalLightsShadowMinimumResolution * [UniversalRP] Make sure upgrading to Universal RP 2021 does not change Spot Light shadow resolutions (internal ticket https://fogbugz.unity3d.com/f/cases/1316540 ) * [UniversalRP] Only upgrade Additional Light Shadow Resolution Tier values if it seems that they have never been customized (@Verasl suggestion) * [UniversalRP] Move UniversalRenderPipelineAsset.AdditionalLightsDefaultShadowResolutionTier... constant definitions outside of #if UNITY_EDITOR block * [UniversalRP] Increase UniversalGraphicsTest_Foundation scene 105_TransparentReceiveShadow spot light shadow resolution to higher tier to match previous settings * Fix asset that was incorrectly edited in e82aa3d * Add local variable to make code easier to read (as suggested in #3831 (comment)) (cherry picked from commit 82f939d) * Update UniversalRenderPipelineAsset.k_AssetPreviousVersion to match with the one in 2021.2 pull request - see conversation #3831 (comment) * [UniversalRP] Increase UniversalGraphicsTest scene 105_TransparentReceiveShadow spot light shadow resolution to higher tier to match previous settings
Purpose of this PR
#2126 added to Universal RP support for custom shadow resolution for additional lights.
When a Universal RP project is upgraded to a Universal RP package containing those changes, its UniversalRenderPipeline Assets get new "Shadow Resolution Tiers" fields added with default values 256/512/1024 ; and its spot light shadows get assigned the lowest tier resolution.
The lower resolution might cause the visual quality of spot light shadows in a project to look worse after the upgrade.
This pull request ensures that after upgrade, spot light shadows will keep using the same resolution.
This is done by using the highest tier resolution as default.
Taking inspiration from@Verasl suggestion, during upgrade the 3 tier resolutions are also modified according to the additional light shadow atlas resolution set in the asset (respectively: full-res, half-res, quarter res if possible).
Testing status
In a test scene based on UniversalRP template scene added with shadowed spot lights, I locally checked that the changes in this pull request effectively conserve spot light shadow resolutions after the upgrade to Unity 2021.
Comments to reviewers
Effort tracked by internal ticket https://fogbugz.unity3d.com/f/cases/1316540
2021.1 backport pull-request: #3832