Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Wrong stereo rendering in Unity 5.6 game viewer #451

Closed
GordeyChernyy opened this issue Feb 1, 2017 · 16 comments
Closed

Wrong stereo rendering in Unity 5.6 game viewer #451

GordeyChernyy opened this issue Feb 1, 2017 · 16 comments

Comments

@GordeyChernyy
Copy link

After importing package I tried to open a demo and stereo preview in Unity 5.6.0b5 viewer looks wrong.

screen shot 2017-01-31 at 8 18 36 pm

Console sometimes gives me this error: Rendering camera 'Main Camera Right', but calling code does not set it up as current camera (current camera: 'PreRender')

Phone build looks normal. I don't have these issues in Unity 5.4.

@miraleung
Copy link
Contributor

Thanks @GordeyChernyy, Unity is looking into a fix.

@joejo-unity
Copy link

joejo-unity commented Feb 4, 2017

This looks to be an issue introduced in 5.6. I'm not sure if this was an intended change in Unity or a regression. Until we have a resolution the following changes will correct this for users of the SDK.


diff --git a/GoogleVR/Legacy/Scripts/Internal/GvrEye.cs b/GoogleVR/Legacy/Scripts/Internal/GvrEye.cs
index 06e3692..8ce0021 100644
--- a/GoogleVR/Legacy/Scripts/Internal/GvrEye.cs
+++ b/GoogleVR/Legacy/Scripts/Internal/GvrEye.cs
@@ -210,6 +210,7 @@ public class GvrEye : MonoBehaviour {
       stereoEffect = GetComponent<StereoRenderEffect>();
       if (stereoEffect == null) {
         stereoEffect = gameObject.AddComponent<StereoRenderEffect>();
+        stereoEffect.eye = eye;
       }
       stereoEffect.enabled = true;
     } else if (stereoEffect != null) {
diff --git a/GoogleVR/Legacy/Scripts/Internal/StereoRenderEffect.cs b/GoogleVR/Legacy/Scripts/Internal/StereoRenderEffect.cs
index d7020b1..cb18c00 100644
--- a/GoogleVR/Legacy/Scripts/Internal/StereoRenderEffect.cs
+++ b/GoogleVR/Legacy/Scripts/Internal/StereoRenderEffect.cs
@@ -26,7 +26,9 @@ public class StereoRenderEffect : MonoBehaviour {
 
   private Camera cam;
 
-  private static readonly Rect fullRect = new Rect(0, 0, 1, 1);
+  private Rect fullRect;
+
+  public GvrViewer.Eye eye;
 
   void Awake() {
     cam = GetComponent<Camera>();
@@ -34,6 +36,7 @@ public class StereoRenderEffect : MonoBehaviour {
 
   void Start() {
     material = new Material(Shader.Find("GoogleVR/UnlitTexture"));
+    fullRect = (eye == GvrViewer.Eye.Left ? new Rect (0, 0, 0.5f, 1) : new Rect (0.5f, 0, 0.5f, 1));
   }
 
   void OnRenderImage(RenderTexture source, RenderTexture dest) {

@ghost
Copy link

ghost commented Feb 4, 2017

I tested the changes @joejo-unity posted, and it works. There's no more visual glitch! Thanks!

Tested on Unity 5.6.0b6 64-bit
GoogleVR SDK v1.20
Linux Mint 18.1 64-bit (Ubuntu 16.04 base), Cinnamon 3.2.7 desktop environment, Nvidia GTX 980Ti & Nvidia 367.57 proprietary graphics drivers.

@frolicks
Copy link

beginner question: How can I apply those changes in my version control?
I'm using a GIT repository with Sourcetree. thanks

@skaale
Copy link

skaale commented Feb 18, 2017

Thanks this fixed the Rendering camera 'Main Camera Right' . I have another strange issus and it is very hard to debug, My Main Camera Right is darker and recive no light
image

@scorpeeon
Copy link

skaale: I have very similar issues after applying the fix: on the left eye everything looks good, but on the right, many things don't appear as they should or don't appear at all. (this only happens in the editor's play mode, not on the phone)
Strange thing is this is also not happening when not applying the fix (but the picture is in pieces then), and also not happening on some scenes like the default google vr sample scenes.

@skaale
Copy link

skaale commented Feb 24, 2017 via email

@joejo-unity
Copy link

joejo-unity commented Feb 24, 2017 via email

@scorpeeon
Copy link

I'm using latest beta (5.6.0b9) - it was like this in the few previous betas too I was using.
The issue seems like on the right eye, the lights of the scene have no effect or are ignored.

@zx-sd
Copy link

zx-sd commented Feb 26, 2017

The solution from @joejo-unity works for me.

Unity 5.6.0b9
GoogleVR SDK v1.20

@skaale
Copy link

skaale commented Feb 26, 2017 via email

@FiniStrini
Copy link

FiniStrini commented Mar 6, 2017

@joejo-unity thanks forever.

@frolicks the script @joejo-unity has attached is meant to be applied in the terminal with the patch command. A newbie myself, I have no clue how you do that. I just opened the scripts it involves in Unity (GvrEye and StereoRenderEffect) and removed/ added the lines as described. Good luck!

e.g. look at the script below: 210,6 is the line numbers in the script, from 210 to 216, and what comes after "+" is what you need to add there (just the stereoEffect.eye = eye; in this case).
"-" means that you erase a line. Read the script letter by letter, it's not such a tricky task after all and you'll feel like a superhero after.

@@ -210,6 +210,7 @@ public class GvrEye : MonoBehaviour {
stereoEffect = GetComponent();
if (stereoEffect == null) {
stereoEffect = gameObject.AddComponent();
++ stereoEffect.eye = eye;
}
stereoEffect.enabled = true;
} else if (stereoEffect != null) {
diff --git a/GoogleVR/Legacy/Scripts/Internal/StereoRenderEffect.cs b/GoogleVR/Legacy/Scripts/Internal/StereoRenderEffect.cs
index d7020b1..cb18c00 100644
--- a/GoogleVR/Legacy/Scripts/Internal/StereoRenderEffect.cs

@ghost
Copy link

ghost commented Mar 19, 2017

Just tested GoogleVR SDK 1.30 with Unity 5.6.0xb10 on Ubuntu 16.10, and it works great! There's no distortion in the stereo viewer at all. Thanks to the team for fixing this bug! See their release announcements, too - https://developers.google.com/vr/unity/release-notes.

@GordeyChernyy
Copy link
Author

Tested with Unity 5.6.0f3, the issue is gone. Thanks!

@tejusk06
Copy link

Using Unity 5.6.1f1. Issue resolved! Thanks :)

@Nabeelhitec
Copy link

Follow this tutorial. You can get google VR SDK package in the link of video. Just import it and run on your android . Hope it will help

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants