Flafla2 / Generic-Raymarch-Unity

An experiment in distance field raymarching that interacts with standard mesh-based objects. Made in Unity.
MIT License
201 stars 37 forks source link

VR Support #4

Open andybak opened 6 years ago

andybak commented 6 years ago

I'll try and take a look myself but I'm trying to find a raymarcher that blits directly to the camera that does work in VR to use as an example. Most tend to use a quad parented to the camera.

hakanai commented 6 years ago

The alternative being a quad in any position where the vertex shader repositions it at the camera?

phest commented 5 years ago

I think the alternative being the solution used here, which is elegant as hell - blit within OnRenderImage, passing the camera matrix, works perfectly with the scene camera. Thank you for making and tutorial-izing this @Flafla2 <3

Any idea what's missing to make this work in VR? It breaks Single Pass, which may be a complicated fix, but Multi Pass should be easy in theory. In Multi Pass the matrix is slightly off, but symmetrically for each eye, the camera does pass a separate matrix for each.

I wasn't able to find a correct matrix in the APIs. I tested it on a Vive, with Camera.stereoActiveEye, and Camera.GetStereoViewMatrix(StereoscopicEye eye). I wonder if the SteamVR_Camera is doing something different on render. But I'm a bit out of my depth with these SteamVR / open XR APIs. For instance I was able to get a projection matrix from SteamVR (with HMDMatrix4x4ToMatrix4x4(SteamVR.instance.hmd.GetProjectionMatrix(evrEye ...)), but not a view matrix. Any ideas?