Oculus-VR / Unity-Graphics

Unity Graphics - Including Scriptable Render Pipeline
Other
66 stars 51 forks source link

Rip and tear moving lit materials #3

Closed nukadelic closed 2 years ago

nukadelic commented 2 years ago

I tried cloning the 2020.3/oculus-app-spacewarp branch and the shader-graph-spacewarp one but in both case the URP\Lit & URP\SimpleLit & Custom Lit shader made in shader graph causes tearing when SpaceWrap is activated , image:

https://raw.githubusercontent.com/nukadelic/unity-application-spacewarp/master/Img/cube.gif

This is only true when the object is in rapid motion ( it gets much crazier when attached to the hands ) - stationary objects in the scene seem to be just fine even when I move the headset furiously around

Not sure if i did something wrong , would appreciate any help , here is my complete project with nearly bare minimal setup required for asw - https://github.com/nukadelic/unity-application-spacewarp

note i have split your repo into 4 and converted them into upm packages ( listed in the link above )

tsaileo1 commented 2 years ago

Thanks for bring thing up. So this is a known issue when using SpaceWarp with fast rotating objects. Check Very Fast Object Rotation here under best practices: https://developer.oculus.com/documentation/unity/unity-asw/#best-practices

We are looking into adding the solution to turn off SpaceWarp specifically for fast rotating objects in the scene by detecting the motion in the shader, but for now try looking into slowing down the rotation of the object.

nukadelic commented 2 years ago

Does this means if the object isn't resulting in visible tearing there is no space wrap implementation in the shader ? Tried the recent update ( 50a6799 ) and from what I can see the URP/Lit , URP/SimpleLit and custom shader graph Lit material all show visible tearing on the screen.

However the following shaders won't :

P.S. Oculus shaders will render only on one eye when testing with openxr in play mode inside the editor

nukadelic commented 2 years ago

Also the same materials that cause tearing will go wild when attached to the hand tracking transform

urp-tear

In these screen-shots I'm not even moving the controllers

Here is a video : https://i.imgur.com/gCBVkEQ.mp4

tsaileo1 commented 2 years ago

I took a look at your project and the issue seems to be that you have enabled/disabled space warp with a direct call to OculusXRPlugin.SetSpaceWarp instead of using OVRManager.SetSpaceWarp. If you are unable to use OVRManager, then you'll have to see how OVRManager sets space warp and use that code in your project. The most important line is setting the depth texture mode of the camera:

mainCamera.depthTextureMode |= (DepthTextureMode.MotionVectors | DepthTextureMode.Depth);

This is an important step for enabling motion vectors.

Space warp should work for Lit/Unlit in URP and shader graph for now. Since we can't cover use cases for all developers, if you need motion vectors in other types of shaders or your own custom shaders, you can take a look at how the motion vector pass is setup in the URP lit shader and use that in the shaders that best fit your projects needs.

nukadelic commented 2 years ago

Thanks totally missed that one , the tear is gone. I noticed when creating a transparent unlit shader graph , there wasn't any tear , does it mean that currently transparency isn't supported ?

tsaileo1 commented 2 years ago

You can take a look at our best practices guide again where we talk about handling transparency: https://developer.oculus.com/documentation/unity/unity-asw/#best-practices

It basically depends on how you're going to be using transparency in your project. If it's something far away, the object is more opaque, etc. If you need space warp to work on transparent objects, you can look into adding those transparent objects to your motion vector pass and see how it looks in your project.