VR Mirror in Vive Stereo Rendering Toolkit

Hi!

I’m desperately looking for a mirror effect that works in VR.

So far I’ve been using Mirror Effect from the Unity Asset Store (which renders the mirror directly into the back buffer instead of using a render target), but native VR integration in Unity broke this because any camera rendering to the HMD is subject to head tracking (even if I reset the camera position in OnPreRender()).

After getting nowhere with several other assets, I tried the Vive Stereo Rendering toolkit. This didn’t compile in Unity 5.6.2 at first, but I changed the native SteamVR calls into their Unity VR integration equivalents as best I could and came up with a mostly working mirror (see attached .zip file).

However, there’s one quirk I couldn’t solve: I’m querying the eyes via GetLocalPosition() and GetLocalRotation(). The left eye is perfect, but the right eye only is at the correct position when I’m looking straight ahead but will get an offset as I rotate my head.

Anyone willing to take a look? Or is there a mirror that just works in VR somewhere?

3140124–238198–ViveStereoRenderingMirror.zip (65.7 KB)

Well, I think I found it.

Line 490 of StereoRenderer.cs offsets the right eye’s position by the configured stereo separation - in world coordinates. That can’t ever have worked right.

Simply removing that line makes the mirror work the way it probably was intended.

Which is to say, the mirror image appears further away than it should be, but at least it has the right angle and eye positions.

1 Like