-
Notifications
You must be signed in to change notification settings - Fork 840
[9.x.x] Fix computation of inverseVP matrix. #374
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
Merged
Merged
Conversation
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
phi-lira
commented
May 6, 2020
Matrix4x4 inverseViewProjection = Matrix4x4.Inverse(viewAndProjectionMatrix); | ||
cmd.SetGlobalMatrix(ShaderPropertyId.inverseViewAndProjectionMatrix, inverseViewProjection); | ||
|
||
cmd.SetGlobalMatrix(ShaderPropertyId.worldToCameraMatrix, viewMatrix); |
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.
Note: This removal is intentional. We already set worldToCameraMatrix in the cmd.SetViewProjectionMatrices above, this is duplicated for now. We plan to remove cmd.SetViewProjectionMatrices and set all matrices explicitly in the future.
ellioman
approved these changes
May 8, 2020
phi-lira
added a commit
that referenced
this pull request
May 12, 2020
* Fixed issue that caused wrong computation of unity inverse view and projection matrix. * Added graphics tests. * filtered test 130 from android due to trunk issues. # Conflicts: # TestProjects/UniversalGraphicsTest/ProjectSettings/EditorBuildSettings.asset # com.unity.render-pipelines.universal/CHANGELOG.md
Merged
phi-lira
added a commit
that referenced
this pull request
May 14, 2020
* Fixed issue that caused wrong computation of unity inverse view and projection matrix. * Added graphics tests. * filtered test 130 from android due to trunk issues. # Conflicts: # TestProjects/UniversalGraphicsTest/ProjectSettings/EditorBuildSettings.asset # com.unity.render-pipelines.universal/CHANGELOG.md # Conflicts: # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/OpenGLES3/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/OpenGLES3/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/Metal/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/Metal/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/Test/TestFilters/TestCaseFilters.asset # com.unity.render-pipelines.universal/CHANGELOG.md
Merged
phi-lira
added a commit
that referenced
this pull request
May 15, 2020
* Fixed quality settings v2. (#181) * Universal Bugfixes (#6109) * Fixed shader pass name issue (case 1201696) * Fixed typo in encodedIrradiance. * Fixed viewport rect not working with render textures. * Added changelog * Enabled Allocations tests when rendering. * Forward Renderer is not sealed anymore. Now developers can subclass it. * Added Test Scene * Excluded post-processing tests from build. * Enabled playmode tests for all assemblies * Removed unnecessary new shader. UnlitTexture is used instead. * Updated reference images. * Updated scene to fix tests. # Conflicts: # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/OpenGLES3/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/OpenGLES3/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/Vulkan/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/Vulkan/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/LinuxEditor/OpenGLCore/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/LinuxEditor/OpenGLCore/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/Metal/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/Metal/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/127_ClearRenderTexture.png.meta # com.unity.render-pipelines.universal/CHANGELOG.md # Conflicts: # TestProjects/UniversalGraphicsTest/ProjectSettings/ProjectSettings.asset # com.unity.render-pipelines.universal/CHANGELOG.md # com.unity.render-pipelines.universal/Runtime/ForwardRenderer.cs # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md * Post-processing is not causing GC alloc anymore. (#192) * [9.x.x] Fix allocation caused when sorting cameras in URP. (#268) * Fixed allocation caused by camera sort. * Added changelog. # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md # com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs * [9.x.x] Fix computation of inverseVP matrix. (#374) * Fixed issue that caused wrong computation of unity inverse view and projection matrix. * Added graphics tests. * filtered test 130 from android due to trunk issues. # Conflicts: # TestProjects/UniversalGraphicsTest/ProjectSettings/EditorBuildSettings.asset # com.unity.render-pipelines.universal/CHANGELOG.md # Conflicts: # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/OpenGLES3/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/OpenGLES3/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/Metal/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/Metal/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/130_UnityMatrixIVP.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/130_UnityMatrixIVP.png.meta # TestProjects/UniversalGraphicsTest/Assets/Test/TestFilters/TestCaseFilters.asset # com.unity.render-pipelines.universal/CHANGELOG.md * fixed merge conflict * GC fix (#1227490) (#6228) * Fixed GC pressure in volume component's GetHashCode * Changelog update * Update com.unity.render-pipelines.core/CHANGELOG.md Co-Authored-By: Felipe Lira <felipedrl@gmail.com> Co-authored-by: Felipe Lira <felipedrl@gmail.com> * Added CopyImagesToReferenceFolder file. * merged and updated reference images Co-authored-by: Thomas <Chman@users.noreply.github.com>
phi-lira
added a commit
that referenced
this pull request
May 27, 2020
* Fixed quality settings v2. (#181) * Universal Bugfixes (#6109) * Fixed shader pass name issue (case 1201696) * Fixed typo in encodedIrradiance. * Fixed viewport rect not working with render textures. * Added changelog * Enabled Allocations tests when rendering. * Forward Renderer is not sealed anymore. Now developers can subclass it. * Added Test Scene * Excluded post-processing tests from build. * Enabled playmode tests for all assemblies * Removed unnecessary new shader. UnlitTexture is used instead. * Updated reference images. * Updated scene to fix tests. # Conflicts: # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/OpenGLES3/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/OpenGLES3/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/Vulkan/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/Android/Vulkan/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/LinuxEditor/OpenGLCore/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/LinuxEditor/OpenGLCore/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/LinuxEditor/Vulkan/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/OpenGLCore/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/Metal/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/Metal/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXPlayer/OpenGLCore/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/127_ClearRenderTexture.png.meta # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/127_ClearRenderTexture.png # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/127_ClearRenderTexture.png.meta # com.unity.render-pipelines.universal/CHANGELOG.md # Conflicts: # TestProjects/UniversalGraphicsTest/ProjectSettings/ProjectSettings.asset # com.unity.render-pipelines.universal/CHANGELOG.md # com.unity.render-pipelines.universal/Runtime/ForwardRenderer.cs * Post-processing is not causing GC alloc anymore. (#192) * [9.x.x] Fix allocation caused when sorting cameras in URP. (#268) * Fixed allocation caused by camera sort. * Added changelog. # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md * [9.x.x] Fix computation of inverseVP matrix. (#374) * Fixed issue that caused wrong computation of unity inverse view and projection matrix. * Added graphics tests. * filtered test 130 from android due to trunk issues. # Conflicts: # TestProjects/UniversalGraphicsTest/ProjectSettings/EditorBuildSettings.asset # com.unity.render-pipelines.universal/CHANGELOG.md * fixed merge conflict * added missing reference images * GC fix (#1227490) (#6228) * Fixed GC pressure in volume component's GetHashCode * Changelog update * Update com.unity.render-pipelines.core/CHANGELOG.md Co-Authored-By: Felipe Lira <felipedrl@gmail.com> Co-authored-by: Felipe Lira <felipedrl@gmail.com> * [9.x.x] updated terrain scene and reference images. (#460) * updated terrain scene and reference images. * Reverted non OSX Metal images This reverts commit 1cba18b. # Conflicts: # TestProjects/UniversalGraphicsTest/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/035_Shader_TerrainShaders.png.meta Co-authored-by: Thomas <Chman@users.noreply.github.com>
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.
Guide : https://github.com/Unity-Technologies/Graphics/blob/pr-template-correction/.github/pr-read.png.md
Display Addon : https://userstyles.org/styles/182991/unity-graphics-pr-readme
Purpose of this PR
Testing status
Manual Tests
Verified using the user provided scene that the issue is now fixed.
Automated Tests
Added test 130 that contains a shader that uses unity_MatrixIVP to reconstruct world space position

I investigated testing all matrices combinations are generated correctly, however given that some are setup in c++ and some are in C# this is difficult to do until we convert to "pure" c# data setup.
Links
Yamato: https://yamato.prd.cds.internal.unity3d.com/jobs/902-Graphics/tree/universal%252Ffix-matrix-ivp/.yamato%252Fupm-ci-abv.yml%2523all_project_ci_fast-2020.1/2107163/job
Comments to reviewers
URP is not yet fully settings matrices in C# side, some of these still are still set in C++ by using cmd.SetViewAndProjectionMatrices and some in C# (inverse matrices not fully setup in C++).
This code fixes the code that setup the inverse VP, as we need an explicit GL.GetGPUProjection matrix before setting it to account for platform specific differences in projection matrix (y and z direction)