-
Notifications
You must be signed in to change notification settings - Fork 860
[11.x.x] Soft Particle bugfixes. Cases 1162556, 1256953& 1226288 + 1268079 #1922
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
[11.x.x] Soft Particle bugfixes. Cases 1162556, 1256953& 1226288 + 1268079 #1922
Conversation
|
|
||
| cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, m_CopyDepthMaterial); | ||
|
|
||
| cmd.SetGlobalVector(ShaderPropertyId.availableTexturesParams, new Vector4(0f, 0f, 0f, 1f)); |
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 is probably not a good enough solution if/when we want to add other texture types to this parameter, such as the opaque texture. Could we add the data to RenderingData? Other ideas welcome.
phi-lira
left a comment
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. We should ask for cross pipeline team / HDRP on what is the design regarding checking if a texture is available in the shader.
com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl
Outdated
Show resolved
Hide resolved
com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl
Outdated
Show resolved
Hide resolved
| #ifndef UNIVERSAL_PARTICLES_INPUT_INCLUDED | ||
| #define UNIVERSAL_PARTICLES_INPUT_INCLUDED | ||
|
|
||
| #if PARTICLES_EDITOR |
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.
Why is it that we need different attributes/varyings for editor?
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 don't know. We need to put that in our task list to look at that.
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 smells very strange :)
If i'm reading it correctly, you are saying lighting is totally disabled/broken in the Editor (because you disregard the normal + tangent inputs)
I don't think you want to ship this as-is unless it's already in this broken state in master.
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 could fix this in this PR as well but this how Editor Particles are currently on Master. I'm just moving the code into one separate file.
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.
No this file you linked isn't for rendering of particles in the editor, it's for rendering the editor specific passes, namely the selection outline and the picking buffer passes.
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.
It seems like I should have added a comment in this file explaining this :)
(I added it when I added instanced particle rendering support, which needs custom passes for picking+selection outlines)
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.
Ahh!! My bad!
Wondering what's the best solution here. Would we be fine with moving the define into the relevant passes and keep my change of having all the Particle attributes/varyings in the same file?
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.
Perhaps add a define to the editor passes, then use it to exclude normal + tangents from the inputs?
You can find the passes by looking at any pass that uses the vertParticleEditor vertex program.
I was also thinking you could just wrap it in #if !UNITY_PASS_META but i think we use META passes for other stuff that may need those inputs. But im not sure about that. I don't know exactly what qualifies as a meta pass.
|
When testing, please compile shaders in editor to see if there are no error / warnings in any platform. |
…epth texture to black/white if we're not doing a prepass or copydepth
erikabar
left a comment
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.
Verified bug reports (1162556, 1256953, 1226288, 1268079)
Verified that a message is thrown when Soft Particles are enabled but Depth Texture is disabled
smoke tested Particles FTP project on Mac, Android (Vulkan, OpenGLES3, OpenGLES2) and iOS (Metal)
commit ab21837 Author: Elvar Örn Unnþórsson <[email protected]> Date: Thu Oct 22 16:39:33 2020 +0200 changelog commit de2cb9f Merge: 129a26a 8bc58a4 Author: Elvar Örn Unnþórsson <[email protected]> Date: Thu Oct 22 16:36:24 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit 129a26a Merge: 08aa34b ef305e5 Author: Elvar Örn Unnþórsson <[email protected]> Date: Tue Oct 20 20:37:30 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit 08aa34b Author: Elvar Örn Unnþórsson <[email protected]> Date: Mon Oct 19 20:59:53 2020 +0200 Changelog commit 8ef7ea2 Merge: 2ca7a38 74151b2 Author: Elvar Örn Unnþórsson <[email protected]> Date: Mon Oct 19 20:48:24 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit 2ca7a38 Author: Elvar Örn Unnþórsson <[email protected]> Date: Mon Oct 19 09:57:52 2020 +0200 Changing the message from info to warning commit 7e116bc Merge: 17c7e8a 2e401c6 Author: Elvar Örn Unnþórsson <[email protected]> Date: Mon Oct 19 09:23:33 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit 17c7e8a Merge: f0cc212 08aecf9 Author: Elvar Örn Unnþórsson <[email protected]> Date: Wed Oct 7 14:46:24 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit f0cc212 Merge: 66a1f75 9c25c9f Author: Elvar Örn Unnþórsson <[email protected]> Date: Mon Oct 5 15:38:28 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit 66a1f75 Merge: b3dc096 168109e Author: Elvar Örn Unnþórsson <[email protected]> Date: Fri Sep 25 14:42:28 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit b3dc096 Author: Elvar Örn Unnþórsson <[email protected]> Date: Thu Sep 24 15:46:20 2020 +0200 Renaming PARTICLES_EDITOR define to PARTICLES_EDITOR_META_PASS commit 9ac74d1 Author: Elvar Örn Unnþórsson <[email protected]> Date: Thu Sep 24 14:08:58 2020 +0200 Fixing things based on reviews commit 4c3dc37 Merge: 5a15af0 b9696e6 Author: Elvar Örn Unnþórsson <[email protected]> Date: Wed Sep 23 10:31:23 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit 5a15af0 Author: Elvar Örn Unnþórsson <[email protected]> Date: Wed Sep 23 10:30:56 2020 +0200 Fixing an copy/paste error commit 0fcaad0 Author: Elvar Örn Unnþórsson <[email protected]> Date: Tue Sep 22 15:45:03 2020 +0200 Fixes based on review commit 03d0a2e Merge: 63af228 e35abbc Author: Elvar Örn Unnþórsson <[email protected]> Date: Tue Sep 22 15:36:17 2020 +0200 Merge branch 'master' into universal/soft-particle-fixes commit 63af228 Author: Elvar Örn Unnþórsson <[email protected]> Date: Tue Sep 22 15:35:50 2020 +0200 Fixing compile errors commit 776f167 Author: Elvar Örn Unnþórsson <[email protected]> Date: Tue Sep 22 13:34:41 2020 +0200 Removing HasDepthTexture() from the shaders and instead setting the depth texture to black/white if we're not doing a prepass or copydepth commit 739160a Author: Elvar Örn Unnþórsson <[email protected]> Date: Fri Sep 18 15:42:15 2020 +0200 Minor fix to ParticlesEditorPass commit ca416b1 Author: Elvar Örn Unnþórsson <[email protected]> Date: Fri Sep 18 15:41:37 2020 +0200 Fixing issue 1226288 commit 77d80bf Author: Elvar Örn Unnþórsson <[email protected]> Date: Thu Sep 17 15:45:47 2020 +0200 Bugfix 1162556
…, which is incorrect.
|
merging to stage branch |
* [11.x.x] Fixing NullReferenceException with Lift Gamma Gain & upgrading URP Package (#2386) * Fixing issue 1283588 * Similar fix to ShadowsMidtonesHighlightsEditor.cs * Minor fixes * More minor fixes * [11.x.x] Soft Particle bugfixes. Cases 1162556, 1256953& 1226288 + 1268079 (#1922) * Bugfix 1162556 * Fixing issue 1226288 * Minor fix to ParticlesEditorPass * Removing HasDepthTexture() from the shaders and instead setting the depth texture to black/white if we're not doing a prepass or copydepth * Fixing compile errors * Fixes based on review * Fixing an copy/paste error * Fixing things based on reviews * Renaming PARTICLES_EDITOR define to PARTICLES_EDITOR_META_PASS * Changing the message from info to warning * Changelog * changelog * Bugfix: The code was overriding the depth texture for overlay cameras, which is incorrect. * [11.x.x] MSAA fix for Metal MacOS/Editor (#2391) * Metal MacOS/Editor MSAA fix. Require an explicit MSAA resolve pass unless the platform is mobile * Added changelog entry * [11.x.x] Fixed per camera MSAA regression (#2293) * Default to XR off when creating the camera and no XR provider is installed. Added runtime XR on/off check for XR camera. * Updated CHANGELOG.md and small format fixes. * Reverted changes in URPCameraEditor and URPCameraData. * [11.x.x] Early camera color target assignment (#2377) * Assign the camera color target early in case it is needed during AddRenderPasses * Update to reflect PR feedback * Get rid of warnings from accessing cameraColorTarget during AddRenderPasses * Update CHANGELOG.md * Removed tile shaders are currently unused. (#2383) Co-authored-by: Elvar Örn Unnþórsson <[email protected]> Co-authored-by: manuele-bonanno <[email protected]> Co-authored-by: thomas-zeng <[email protected]> Co-authored-by: Peter Bay Bastian <[email protected]> Co-authored-by: Kay Chang <[email protected]>
…68079 (#1922) * Bugfix 1162556 * Fixing issue 1226288 * Minor fix to ParticlesEditorPass * Removing HasDepthTexture() from the shaders and instead setting the depth texture to black/white if we're not doing a prepass or copydepth * Fixing compile errors * Fixes based on review * Fixing an copy/paste error * Fixing things based on reviews * Renaming PARTICLES_EDITOR define to PARTICLES_EDITOR_META_PASS * Changing the message from info to warning * Changelog * changelog * Bugfix: The code was overriding the depth texture for overlay cameras, which is incorrect. # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md
* [11.x.x] Fixing NullReferenceException with Lift Gamma Gain & upgrading URP Package (#2386) * Fixing issue 1283588 * Similar fix to ShadowsMidtonesHighlightsEditor.cs * Minor fixes * More minor fixes # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md * [11.x.x] Soft Particle bugfixes. Cases 1162556, 1256953& 1226288 + 1268079 (#1922) * Bugfix 1162556 * Fixing issue 1226288 * Minor fix to ParticlesEditorPass * Removing HasDepthTexture() from the shaders and instead setting the depth texture to black/white if we're not doing a prepass or copydepth * Fixing compile errors * Fixes based on review * Fixing an copy/paste error * Fixing things based on reviews * Renaming PARTICLES_EDITOR define to PARTICLES_EDITOR_META_PASS * Changing the message from info to warning * Changelog * changelog * Bugfix: The code was overriding the depth texture for overlay cameras, which is incorrect. # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md * [11.x.x] MSAA fix for Metal MacOS/Editor (#2391) * Metal MacOS/Editor MSAA fix. Require an explicit MSAA resolve pass unless the platform is mobile * Added changelog entry # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md * [11.x.x] Fixed per camera MSAA regression (#2293) * Default to XR off when creating the camera and no XR provider is installed. Added runtime XR on/off check for XR camera. * Updated CHANGELOG.md and small format fixes. * Reverted changes in URPCameraEditor and URPCameraData. # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md * [11.x.x] Early camera color target assignment (#2377) * Assign the camera color target early in case it is needed during AddRenderPasses * Update to reflect PR feedback * Get rid of warnings from accessing cameraColorTarget during AddRenderPasses * Update CHANGELOG.md # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md Co-authored-by: Elvar Örn Unnþórsson <[email protected]> Co-authored-by: manuele-bonanno <[email protected]> Co-authored-by: thomas-zeng <[email protected]> Co-authored-by: Peter Bay Bastian <[email protected]>
Purpose of this PR
This PR fixes these three issues:
How?
Issue 1, 2 & 3
The solution is to assign a black or white texture as the depth texture, depending on whether we're on a platform with reverse-z or not, if the frame doesn't have a prepass or copydepth pass.
We now also display a warning message in the material inspector when soft particles are enabled but depth texture is not in the asset.
Issue 4
The fix is to use a different
LinearEyeDepth()method insideParticles.hlsl. Instead of using the one that uses_ZBufferParamsit now uses the one that requires world position and view matrix, which is recommended if we've already computed the world space position.This ended up being a larger fix as I needed to get access to the world position and instead of simply adding that parameter to the SoftParticles function, I decided to refactor some of the code, create a new struct (
ParticleParams) with the common variables used in our particle shaders and create new functions using that struct. That allows us to modify the functions implementations in the future without having to change the API hopefully again.As all of the particle shaders used the same attributes and varyings, except the editor ones, I decided to move those in to a separate hlsl file to reduce duplicate code.
QA
What has been tested
What needs testing
Yamato
master: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/universal%252Fsoft-particle-fixes
2020.2: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/universal%252Fsoft-particle-fixes/.yamato%252F_abv.yml%2523all_project_ci_CUSTOM-REVISION/3977446/job