- Home /
Blit 2D Texture into both eyes in Single Pass Stereo
I would like to blit a 2D Texture into both eyes in Single Pass Stereo mode, but I can't seem to find the right shader algorithm to get the texture centered in the right eye. The left eye works but the right needs to be a little bit offset - with a value around 0.056.
In my Image Effect shader I do something like:
uv.x += 0.056 * unity_StereoEyeIndex;
The 0.056-offset I've manually figured out after trying everything from measuring distance between the VRNode.LeftEye and VRNode.RightEye and the same projected in screen space. It gets close but no cigar. I've also tried to extract what is stored in unity_StereoScaleOffset but the values doesn't seem to have any correlation to 0.056. I've tried ComputeNonStereoScreenPos and ComputeGrabScreenPos in all ways I can think of, but no result.
It should be noted that 0.056 works independent of the distance between my lenses. The 0.056 translates to about 84 pixels (VRSettings.eyeTextureWidth * 0.056).
Anyone understand this value?
Adding to the mystery: the 0.056 is for Vive. Oculus has a value around 0.135. So it depends on the hardware. I've also tried to put a plane at the camera's far clip plane with the texture and that sort of works but gives a distortion I don't fully grasp. I've also tried all the tricks described here... https://docs.unity3d.com/$$anonymous$$anual/SinglePassStereoRendering.html ...but without any luck. Anyone?
Turns out the problem is related to skewed frustrums and really hard to solve "the right way". What I ended up doing, was putting the image on a huge plane at the camera far plane. Unfortunately I cannot share the code as it's part of a closed-source project.
Your answer