{{ message }}
[HDRP] Improve decal performances when they use different material and the same draw order.#6303
Merged
Merged
Conversation
kecho
approved these changes
Nov 16, 2021
Contributor
|
Good change! |
sebastienlagarde
approved these changes
Nov 16, 2021
Contributor
|
Please, add changelog |
Contributor
There was a problem hiding this comment.
please fix changelog
sebastienlagarde
pushed a commit
that referenced
this pull request
Dec 8, 2021
…d the same draw order. #6303
sebastienlagarde
added a commit
that referenced
this pull request
Dec 9, 2021
* - Fixed edges and ghosting appearing on shadow matte due to the shadow being black outside the range of the light (case 1371441). #6279 * Fixed interpolation issue with wind orientation (case 1379841). #6284 * Fixed range fields for depth of field #6285 * [Core] Fix XR support in CoreUtils.Drawfullscreen #6287 * ** Fixing DLSS failing when MV are disabled ** (#6292) * Using texture types instead of RenderTexture types for DLSSPass * Changelog * Formatting Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [Fix] Lens Flare visible when being behind a camera with Panini Projection on (case 1370214) (#6293) * Fix panini for LensFlare * Add changelog * Update CHANGELOG.md * Fixed the ray tracing acceleration structure build marker not being included in the ray tracing stats (case 1379383). #6277 * [HDRP] Remove alpha from local volumetric fog color field #6310 * [HDRP] Changed default numbder of physically based sky bounce from 8 to 3 #6304 * [HDRP] Improve decal performances when they use different material and the same draw order. #6303 * [HDRP] Update reference screenshots #6404 * Fixed Nans happening due to volumetric clouds when the pixel color is perfectly black (case 1379185). #6311 * Fixed missing information in the tooltip of affects smooth surfaces of the ray traced reflections denoiser (case 1376918). #6321 * Physically Based Sky documentation now mentions the warmup cost explicitly (#6323) * Physically Based Sky documentation now mentions the warmup cost explicitly. * Update CHANGELOG.md Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Reviewed PR #6031 (#6340) * Reviewed PR #6031 Also generally improved this doc, fixed typos and added screenshots. * Apply formatting changes Co-authored-by: noreply@unity3d.com <noreply@unity3d.com> * Fix preview scene objects marked dirty by migration #6361 * [HDRP][Path Tracing] Fixed PS5 build compilation warnings #6362 * Fix compil issue * Apply formatting changes * Update VisualEnvironment.cs * Fix HDRP warning (#6396) * [HDRP][Metal] * Update reference screenshots sky Co-authored-by: anisunity <42026998+anisunity@users.noreply.github.com> Co-authored-by: Adrien de Tocqueville <adrien.tocqueville@unity3d.com> Co-authored-by: Antoine Lelievre <antoinel@unity3d.com> Co-authored-by: Kleber Garcia <kleber.garcia@unity3d.com> Co-authored-by: skhiat <55133890+skhiat@users.noreply.github.com> Co-authored-by: JulienIgnace-Unity <julien@unity3d.com> Co-authored-by: Vic Cooper <63712500+Vic-Cooper@users.noreply.github.com> Co-authored-by: noreply@unity3d.com <noreply@unity3d.com> Co-authored-by: Arttu Peltonen <77337829+arttu-peltonen@users.noreply.github.com> Co-authored-by: Emmanuel Turquin <emmanuel@turquin.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Purpose of this PR
Optimize decals for this use case: https://forum.unity.com/threads/decal-projector-performance.965822/
Note that this PR changes the behavior of the order in which decals are rendered when they have the same draw order. This is fine because two decals with the same draw order are not guaranteed to be rendered in a specific order (but the sort is still stable between frames).
Testing status
Initial profiling with 500 decals in an empty scene. Decals are all using a unique material spawned with this script:
Decal projector settings are identical for every decal:

The decal shader is a ShaderGraph with a simple gradient noise animated based on time.
This is without the fix in CPU profiling:

With the fix:

As you can see on the CPU side there is a 5x improvement. GPU side is identical since the decal list is the same, only order changes.
Notes for the future
We may benefit from a proper instancing system for decals, meaning that our decals sets will be stored per shader and not per material. This would remove the cost of having to go through the initialization of jobs for every decal material in a scene (this is currently the next big bottleneck on decals). Though that would involve a lot of work since all the ShaderGraph / decal properties would need to be instanced in the shader.
Yamato
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/hd%252Fimprove-decal-material-perfs/.yamato%252Fall-hdrp.yml%2523PR_HDRP_trunk/9969232/job