-
Notifications
You must be signed in to change notification settings - Fork 839
[14.x.x] LOD Cross Fade #6754
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
base: master
Are you sure you want to change the base?
[14.x.x] LOD Cross Fade #6754
Conversation
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. |
@@ -1234,6 +1255,18 @@ static void UpgradeAsset(int assetInstanceID) | |||
asset.k_AssetPreviousVersion = 10; | |||
} | |||
|
|||
if(asset.k_AssetPreviousVersion < 11) | |||
{ |
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.
Is this a correct way to Reload PostProcessingData asset that now has to have links to blue noise and bayer matrix texture?
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.
Is this a correct way to Reload PostProcessingData asset that now has to have links to blue noise and bayer matrix texture?
Moved textures to the asset itself as post processing data might not be assigned at all.
@@ -59,6 +58,8 @@ float4 DepthNormalsFragment(Varyings input) : SV_TARGET | |||
half alpha = texColor.a * _BaseColor.a; | |||
AlphaDiscard(alpha, _Cutoff); | |||
|
|||
LODFadeCrossFade(input.positionCS); |
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.
For some reason I have to put this always after alpha discard otherwise there is a weird behavior on iOS for AlphaTest shaders.
This comment has been minimized.
This comment has been minimized.
com.unity.render-pipelines.universal/Runtime/Data/PostProcessData.asset.meta
Outdated
Show resolved
Hide resolved
# Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md # com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineAsset/UniversalRenderPipelineAssetUI.Drawers.cs # com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineAsset/UniversalRenderPipelineAssetUI.Skin.cs # com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs
Just a comment mainly for Universal team.
in HDRP LOD_FADE is a build time killer as it affect all our passes (both deferred adn forward, shadow, depth prepass etc...). So it is the worse thing that we can do for build time and sadly with current fading algorithm use in unity we have no choice. in HDRP we have added a supportDitheringCrossFade to allow to discard all those extra variant AND on ShaderGraph we have added an option to generate or not this multicompile (sadly we can't do this with non shader graph shader). So for reviewer of this PR, be really consicous about the build time involve by this change! :) |
Yeah I think adding shader variant strip makes sense. Will add it. |
…ow can disable cross fade completely.
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.
Looking good PR doc: https://docs.google.com/document/d/1nVoioD996jynbWwN4ZCXjNPquMvkd6wZrkdUouVR6DY
Purpose of this PR
Currently in URP Mesh LOD switch inside LODGroup occurs immediately which frustrates the users as this ‘immediate’ switch looks like a sharp pop of a new object.
To improve that we need a mechanism to smooth transition or crossfade from one mesh to another. This could be achieved by using alpha test dithering mask crossfade https://en.wikipedia.org/wiki/Dither. Dithering mask, by using clip() or discard() function in a Pixel Shader, decreases total number of visible pixels of one Mesh LOD and increases total number of visible pixels of another Mesh LOD and smoothly crossfades two Meshes.
I propose to make 3 types of LOD Cross Fade dithering and allow user to choose the type in UniversalRenderPipelineAsset.
LOD Cross Fade types are:
This is used in Built In renderer and very cheap but has quite repetitive pattern.
This uses precomputed blue noise texture and provides best looking option but a bit more expensive than Bayer Matrix.
Test Scene Video: No Cross Fade - https://drive.google.com/file/d/1McO6CH33eNrBj3sCBtoOQHEUdXAuTdgf/view?usp=sharing
Test Scene Video: With Cross Fade - https://drive.google.com/file/d/1GNEjY3xh3DgzCslKawmfWGcwG3IDIHdp/view?usp=sharing
Testing status
Tested on PC, Mac, Android, iOS and PS5 using my own synthetic scene with lots of objects.
Performance results are here. https://docs.google.com/spreadsheets/d/1r4EmXtUQMD3EYhFsDjfA2AE1tcx-MzzC110StR_guII/edit?usp=sharing
Comments to reviewers
Additional Alpha To Coverage improvement
When MSAA is enabled in forward renderer. We can additionally use Alpha To Coverage to improve transition between LOD even more by writing dithering value to alpha. In that case transition looks a bit like alpha blended.
We can integrate that later as soon as #6312 will be merged.