-
Notifications
You must be signed in to change notification settings - Fork 855
Minimal enclosing sphere fix #4436
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
Conversation
…universal/debug-cull-features
…universal/debug-cull-features
…universal/debug-cull-features
It appears that you made a non-draft PR! |
This comment has been minimized.
This comment has been minimized.
…universal/tight_enclosing_sphere
@Unity-Technologies/gfx-qa-urp could I get a performance analysis of this change? I am curious if this potentially improves the rendering time of shadows due to the cascade culling sphere overlap removal. |
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.
URP QA got re-added again, approving
Adding the test results doc: |
Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed. URP Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure. |
@simon-engelbrecht-soerensen @erikabar would either of you be able to do a quick sanity test of this latest PR? None of the logic changed so no need to test in depth, but there was a big merge conflict that I had to resolve. Could you also verify that creating a new project has this enabled, and when upgrading old project, this is disabled? |
instance.m_EditorResourcesAsset = instance.editorResources; | ||
|
||
// Only enable for new URP assets by default | ||
instance.m_ConservativeEnclosingSphere = true; |
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.
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.
public static GUIContent shadowDepthBias = EditorGUIUtility.TrTextContent("Depth Bias", "Controls the distance at which the shadows will be pushed away from the light. Useful for avoiding false self-shadowing artifacts."); | ||
public static GUIContent shadowNormalBias = EditorGUIUtility.TrTextContent("Normal Bias", "Controls distance at which the shadow casting surfaces will be shrunk along the surface normal. Useful for avoiding false self-shadowing artifacts."); | ||
public static GUIContent supportsSoftShadows = EditorGUIUtility.TrTextContent("Soft Shadows", "If enabled pipeline will perform shadow filtering. Otherwise all lights that cast shadows will fallback to perform a single shadow sample."); | ||
public static GUIContent conservativeEnclosingSphere = EditorGUIUtility.TrTextContent("Conservative Enclosing Sphere", "If enabled, a conservative enclosing sphere is used. If disabled, the sphere will be smaller than the cascade size, and shadows will be culled in the corners of the cascades."); |
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.
My suggestion:
EditorGUIUtility.TrTextContent("Conservative Enclosing Sphere", "Enable this option to improve shadow frustum culling. Enabling this option prevents Unity from excessively culling shadows in the corners of the shadow cascades. Disable this option only for compatibility purposes of projects created in previous Unity versions.");
…universal/tight_enclosing_sphere
…echnologies/Graphics into universal/tight_enclosing_sphere
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!
Backport of minimal enclosing sphere solution for shadow frustum culling. #4436 Co-authored-by: Erik Hakala <erik.hakala@unity3d.com> Co-authored-by: Oleksandr Kokoshyn <oleksandr.kokoshyn@unity3d.com>
set { m_ConservativeEnclosingSphere = value; } | ||
} | ||
|
||
public int numItertionsEnclosingSphere |
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.
A bit late to the party but there's a small spelling mistake here:
numItertionsEnclosingSphere -> numIterationsEnclosingSphere
Chicken bit for the minimal enclosing sphere frustum cascade culling stabilization fix, and also user control over the number of iterations for the iterative method for finding the minimal enclosing sphere from the 8 frustum cascade points. This fix makes it so that the culling spheres appropriately fully enclose the cascade. Since this is an iterative method, it is conservative. This fixes URP so there are not false positives when culling shadows.
https://jira.unity3d.com/browse/URP-782
Checklist for PR maker
need-backport-*
label. After you backport the PR, the label changes tobackported-*
.CHANGELOG.md
file.Purpose of this PR
Fixes bug where shadows disappear in the frustum corners from false positives in the shadow culling.
https://fogbugz.unity3d.com/f/cases/1153151
Also fixes inherent bug with shadow fade where the shadows will be culled with a hard line across the fade which is due to the same problem.
Testing status
Tested with URP default template and custom cascade positioning.
Comments to reviewers
This PR is dependent on the following change to trunk:
https://github.cds.internal.unity3d.com/unity/unity/pull/2418
Design doc:
https://docs.google.com/document/d/10YxFKdA8YFS7QS8Owg2dvnYaM-t9tsLXWQLtiEXZQvQ