-
Notifications
You must be signed in to change notification settings - Fork 855
[VFX] Additional Sorting Keys [22.1] #5125
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
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. HDRP VFX 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. |
Hi, dropping the WIP Test Doc with a few items already that can be looked at. |
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.
In progress
// Select left or right: Must handle special case for equality | ||
bool select0 = (key0 == key1 && (id & 1)) || (CompareKeys(key0,key1) != reverse); | ||
uint value = inputSequence[(select0 ? index0 : index1)].value; | ||
bool select0 = (kvp0.key == kvp1.key && kvp0.value == kvp1.value && (id & 1)) || (CompareKVP(kvp0, kvp1) != reverse); |
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.
The first condition does not seem relevant anymore. CompareKVP test seems enough
C++ side of the PR is currently being reviewed |
I've made some changes to the new sections. Please double-check for accuracy.
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 approve my own changes :D
return; | ||
|
||
|
||
#if VFX_FEATURE_SORT |
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.
Couldnt all this be factorized in some way with what's in GlobalSortKey.template?
var sortKeyExp = m_Output.inputSlots.First(s => s.name == "sortKey").GetExpression(); | ||
expressionMapper.AddExpression(sortKeyExp, "sortKey", -1); | ||
} | ||
catch (Exception e) |
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.
Isnt this try catch just a temp debug things?
var implicitContext = new List<VFXContext>(); | ||
if (NeedsGlobalSort()) | ||
bool needsGlobalSort = NeedsGlobalSort(); | ||
//Issues a global sort, when it affects at least one output. |
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.
Shouldnt the global sort be used when it affects at least 2 outputs, for 1 output using UpdateOutput pass seems better if any as it potentially removes 1 dispatch (+ takes into account attribute modification in output if any)
# Conflicts: # com.unity.visualeffectgraph/Shaders/VFXCameraSort.template
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.
Approving but only because I'm following the landing of this PR (see #6172)
...rojects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/16_MeshParticles.unity
Show resolved
Hide resolved
Needed after merge of #5125
* renaming/shader code for built-in sort keys * New task types + sorting logic + sort with value * Vote to choose the global sorting (wip) * Also compare the custom slot if needs be * Fix binding buffer issues * Fix needsOwnSort Condition * use needsOwnSort for MeshOutputs * Reformatting * Sort order consistent with other sortings * Warnings for changes in output * New graphics test * Always add isPerCameraSort mapping * sort mode instead of criterion + tooltips * small renaming * remove useless condition + cleaner ternary op * restore ternary operator (error on user defined types) * local reformatting * fix bad merge * Fix naming in filteredSettings + strips case * change feedback text to workaround layout issue * Wrongly public method * Error feedback only when block is enabled * Fix Output ParticleStrip having sort available when created * Update VFX to correct criterion * Criteria renaming (explicit "ToCamera") * Cleanup voting mechanism * more cleanup * fix missing comparer * expose the option (does nothing) * little cleaning * moved helper function * EqualityComparer instead of the interface * Unify sorting criteria * Simplify logic * keep SortKeySlotComparer internal * Reuse SortingCriteriaComparer for needOwnSort * Activate inversion in shader * Activate inversion in shader (bis) * reformat file * Remove OldestInFront * Forces Per Output update when there is no Update but Sorting is on * Shut down intermediate return (buggy) warning * Warning when age is not set * Add reference images * Add reference image + update affected tests * Attributes -> VFXAttributes * Correct cast * Update docs * update changelog * Docs review. I've made some changes to the new sections. Please double-check for accuracy. * Fixed *Sort* definition * Same amount of mappings for global/peroutput * Fix merge * Remove try/catch * Two similar criterion for global sort * Return global sorting criterion only when needed * FeedSortingKeys factorized * Fix needsOwnSort condition * add the graphics test * Fix test failure * Fix metal refs * exclude 16_MeshParticles in XR Co-authored-by: Vic-Cooper <vic.cooper@unity3d.com>
This PR backports some changes from the [Additional sorting keys PR](#5125) that fixes the flickering that happens for systems with capacity >4096. It also includes some optimizations introduced in this [fix](https://ono.unity3d.com/unity/unity/pull-request/139471/_/graphics/vfx/1300251-bitonic-sort-low-end). Please note that it is **not** a full backport of the Additional Sorting keys feature.
[VFX] Additional Sorting Keys
Checklist for PR maker
need-backport-*
label. After you backport the PR, the label changes tobackported-*
.CHANGELOG.md
file.Purpose of this PR
This PR introduces new criteria to sort the particles of an output context. Prior to this PR, if sorting was enabled, particles were sorted by their distance to the camera. We now propose a total of 5 sorting criteria :
The sorting criterion can be chosen in the inspector if the Sort is set to On or Auto.


Notes:
JIRA story
This PR required modification of the C++ code.
Link to C++ PR : https://ono.unity3d.com/unity/unity/pull-request/130921/_/graphics/vfx/feature/new-sortkeys
Testing status
What has been tested :
What hasn't been tested :
I plan to add a graphics test for this feature too.
Comments to reviewers