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
[Feature] Motion Vectors for Universal MVP #4408
Conversation
| @@ -62,6 +62,13 @@ public sealed class ShaderResources | |||
| public Shader coreBlitPS; | |||
| [Reload("Shaders/Utils/CoreBlitColorAndDepth.shader")] | |||
| public Shader coreBlitColorAndDepthPS; | |||
|
|
|||
|
|
|||
| [Reload("Shaders/CameraMotionVectors.shader")] | |||
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 there a better place to keep these shaders?
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 think it is fine for them to be in this folder, since motion vectors are not specific to only post process.
com.unity.render-pipelines.universal/Runtime/Passes/MotionVectorRenderPass.cs
Outdated
Show resolved
Hide resolved
com.unity.render-pipelines.universal/Shaders/ObjectMotionVectors.shader
Outdated
Show resolved
Hide resolved
...phicsTest_Foundation/Assets/Scenes/206_Motion_Vectors/CaptureMotionVectorsRendererFeature.cs
Outdated
Show resolved
Hide resolved
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
Would be nice to have more effects to validate but we can do any fixes to this once we look at adding Per Object Motion Blur and TAA etc
| // If the flag hasn't been set yet on this camera, motion vectors will skip a frame. | ||
| camera.depthTextureMode |= DepthTextureMode.MotionVectors | DepthTextureMode.Depth; | ||
|
|
||
| // TODO: add option to only draw either one? |
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 would be a nice option to have.
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.
Did some smoke testing on mobiles. Looks good. Visually scene was rendered as expected. No errors in the logcat (Android) nor in the Xcode(iOS).
Android Gles3 and Vulkan:

Unity used for testing:
Version: 2021.2.0a17.2411.graphics/srp/motion-vectors-fallback-material.10
Revision: graphics/srp/motion-vectors-fallback-material 439ecc0b6d35
Built: Mon, 10 May 2021 12:43:49 GMT
Devices under testing:
iPad Air4, SoC: A14, iOS: 14.0
iPhone 12Pro, SoC: A14, iOS: 14.1
VLNQA00217, Razer Phone 2, 9.0.0, Snapdragon 845 SDM845, Adreno 630
VLNQA00268, Samsung Galaxy S10+, 10.0.0, Exynos 9 9820, Mali-G76
OnePlus Nord, 10, Snapdragon 765G SM7250-AB, Adreno 620
com.unity.render-pipelines.universal/Runtime/MotionVectorRendering.cs
Outdated
Show resolved
Hide resolved
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 issues found. Tested custom project with moving objects, moving camera, camera stacking with renderer feature dev provided in automated scene

Checklist for PR maker
CHANGELOG.mdfile.Purpose of this PR
Adding Motion Vector pass to Universal Render Pipeline. This is needed for URP to support features like Motion Blur and TAA. This is a MVP and has some restrictions.
Does not support custom shaders that modify vertex positions.
Only supports R16G16_SFloat for render target.
Only supports per object motion vectors for objects that are moving.
For 3.0 target and above.
Disabled for xr.
Testing status
Motion Vector pass is disabled by default and need to be enabled thorough script. Test scene contains a script that does this and then renders Motion Vectors on top of the regular scene.
Added test scene in _Foundation project: 206_Motion_Vectors

Test displays motion vectors target rendered to the game view. It displays both per object and camera motion vectors, but since the camera is not moving it only shows per object motion vectors right now.
Link to yamato for c++ branch testing against Graphics master:
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252F_abv.yml%2523all_project_ci_CUSTOM-REVISION/6733935/job/full-pipeline
Testing this PR against same trunk revision.
Comments to reviewers
Technical Design Document: https://docs.google.com/document/d/1P3HstSS7MFpMW9qT5ty8fC8_c15nTIqgIJxEnomNRS8/edit?usp=sharing
Relies on trunk change: https://ono.unity3d.com/unity/unity/pull-request/125001/_/graphics/srp/motion-vectors-fallback-material