- Home /
Mirror reflections and stereoscopy
Hello everyone !
I am having an issue with stereoscopy and mirrors. This is happening with a HTC Vive and the steamVR asset, but it does not seem to be related to the hardware.
I am using shaders to render mirrors (as someone explained in the video https://www.youtube.com/watch?v=AvxGw_sZisk&t=91s). It works, but not perfectly well as the images of right and left eyes are very different and the brain cannot merge it.
Any idea where the issue would be ?
Thank you :)
Answer by Bodhid · Oct 06, 2017 at 09:16 AM
I did this once for the Vive, What worked for me was creating 2 mirror camera's, each following an eye.
Both camera's follow the eyes on the other side of the mirror, and with a reflect you can calculate the rotation. Then send the RenderTexture of both eyes to a shader variable. Finally you could use layers to render 2 mirrors, one for each eye. And each mirror should render (in screen space) the corresponding rendertexture.
I found this beautifull example on google:
To get the rotation and position of each eye, use UnityEngine.VR.InputTracking.GetLocalPosition(LEFT OR RIGHT)
and UnityEngine.VR.InputTracking.GetLocalRotation(LEFT OR RIGHT)
I'm Curious I'm Trying To Implement The Same Technique you suggested But For GoogleCardboardVR Is there a way to access the left and right eye positions for Gvr that is equivalent to the UnityEngine.VR.InputTracking.GetLocalPosition(LEFT OR RIGHT) and UnityEngine.VR.InputTracking.GetLocalRotation(LEFT OR RIGHT) code you mentioned?
Yes. Cardboards prefab has a $$anonymous$$ain Camera, it's children are the transforms for Left and Right eye. "$$anonymous$$ain Camera Left" and "$$anonymous$$ain Camera Right"
Yeah the latest GVR for Unity Plugin No Longer Has Those Prefabs, And From What I Can Gather GvrEditorEmulator Has Replaced the old GvrViewer$$anonymous$$ain So This Is Where I'm Having Trouble Figuring Out how to access the left and right eye cameras
i did find this code however at the bottom of the GvrEditorEmulator .cs script
private IEnumerator<Camera> ValidCameras() {
for (int i = 0; i < Camera.allCameras.Length; i++) {
Camera cam = Camera.allCameras[i];
if (cam.stereoTargetEye == StereoTargetEye$$anonymous$$ask.None) {
continue;
}
yield return cam;
}
}
i'm thinking if i create the a similar function in a custom script i should be able to acces the left and right eye cameras via something like this
private Camera GetLeftEye(){
Camera leye;
for (int i = 0; i < Camera.allCameras.Length; i++) {
Camera cam = Camera.allCameras[i];
if (cam.stereoTargetEye == StereoTargetEye$$anonymous$$ask.Left) {
leye = cam;
break;
}
}
return leye;
}
private Camera GetRightEye(){
Camera reye;
for (int i = 0; i < Camera.allCameras.Length; i++) {
Camera cam = Camera.allCameras[i];
if (cam.stereoTargetEye == StereoTargetEye$$anonymous$$ask.Right) {
reye = cam;
break;
}
}
return reye;
}
am i correct in this assumption?
Your answer
Follow this Question
Related Questions
Complete Flat Mirror Reflection shader 0 Answers
Render Texture2D mirrored horizontally 1 Answer
Can't change Camera.stereoSeparation 3 Answers