Motion Vector generation for Application SpaceWarp

Avatar
  • updated
  • Answered

I'm trying to support ASW on Oculus Quest by following this guide, and this requires adding a MotionVectors pass to every shader. The pass can be applied to standard URP shaders in this way
```
Pass  

Name "MotionVectors" Tags{ "LightMode" = "MotionVectors"} Tags { "RenderType" = "Opaque" }
ZWrite[_ZWrite]
Cull[_Cull]
HLSLPROGRAM 

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/OculusMotionVectorCore.hlsl"
#pragma vertex vert 

#pragma fragment frag
ENDHLSL 

}
```
 and generating the motion vectors using the vert and fragment from here

I have applied this to other shaders I use and confirmed that the ASW implementation is working. Next, I added this pass on all Shapes shaders by modifying ShaderBuilder and regenerating, but the resulting shaders had extreme warping. 


I'm looking for some guidance on if this is possible/easy to generate the motion vectors if I know where to look, or if there is some code altering the required buffers that prevents the vectors from being used in the anticipated way (see the section under "Custom Shaders" in the guide link above)




Reporting a bug? please specify Unity version:
2020.3.29f1
Reporting a bug? please specify Shapes version:
4.1.3
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator
  • Answered

this is pretty complicated, since Shapes is heavily GPU based, and alters its vertices in the vertex shader itself. the only Shape that doesn't do this is the polygon.

anyhow, I don't have the time to look into implementing third party plugins I'm afraid! I suspect you'll have to replicate the vertex shaders in Shapes in the motion vectors pass, to ensure the geometry remains the same. But I also don't know how it handles transparency and masking, that might need to carry over too, which, again, gets complicated