Forum Discussion
aurelm
10 years agoHonored Guest
Lag when using render texture camera
Hello.
I am having this problem with Gear VR on Unity. I am rendering some objects in the scene into a render texture to be used inside a scene shader as reflection. Everything works fine except that the camera that renders the objects has a very big lag and the objects seem always to be 1 -2 frames behind.
At first I had the texture camera attached to the CenterEyeAnchor in the camera setup provided with Unity example. Since the lag was huge I searched the forums for an answer so I ended up attaching a script to the camera on either PreRender or PreCull. None of them solve the issue and the reflection lags a lot behind. For debugging I attached a sphere to the camera and the sphere also seems to lag 1 frame behind but is not as noticable as the reflection (I can see it if I tap the headset with the finger).
This would be the code however it does not work and the reflection is useless at this point. Also the reflection does not seem to be stereo but a single perspective. Is there a proper way to do stereo render textures ?
Here is a video of the problem filmed on the headset. The flicker part should be a reflection.
https://www.youtube.com/watch?v=scTQWIJ ... e=youtu.be
Thanks
-Aurel
I am having this problem with Gear VR on Unity. I am rendering some objects in the scene into a render texture to be used inside a scene shader as reflection. Everything works fine except that the camera that renders the objects has a very big lag and the objects seem always to be 1 -2 frames behind.
At first I had the texture camera attached to the CenterEyeAnchor in the camera setup provided with Unity example. Since the lag was huge I searched the forums for an answer so I ended up attaching a script to the camera on either PreRender or PreCull. None of them solve the issue and the reflection lags a lot behind. For debugging I attached a sphere to the camera and the sphere also seems to lag 1 frame behind but is not as noticable as the reflection (I can see it if I tap the headset with the finger).
Vector3 VRRotation = UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.RightEye).eulerAngles;
camera.transform.rotation = Quaternion.Euler(new Vector3(VRRotation.x, 180 + VRRotation.y, VRRotation.z));
This would be the code however it does not work and the reflection is useless at this point. Also the reflection does not seem to be stereo but a single perspective. Is there a proper way to do stereo render textures ?
Here is a video of the problem filmed on the headset. The flicker part should be a reflection.
https://www.youtube.com/watch?v=scTQWIJ ... e=youtu.be
Thanks
-Aurel
3 Replies
Replies have been turned off for this discussion
- vrdavebOculus Staff
"aurelm" wrote:
This is unfortunately a known issue with Unity 5. Unity performs a late update to grab the head pose just before it actually starts rendering each eye buffer. This makes the image significantly more stable, but the same late-update is not performed for RenderTexture rendering. To avoid the drift, we probably need to expose an option to disable the late update. In the meantime, you would have to use Unity 4.7 to make the two cameras line up perfectly. Another option is to render a cubemap or use reflection probes and use a reflection shader or the standard shader, both of which the late update will play nicely with.
the camera that renders the objects has a very big lag and the objects seem always to be 1 -2 frames behind."aurelm" wrote:
You are going to need two separate Cameras with targetTexture set to two different RenderTextures. In OnPreRender, set each Camera's pose using VR.InputTracking.GetLocalPosition/Rotation(..) for that Camera's eye. To sample the stereo textures, you will need to split your VR cameras up with Target Eye = Left/Right instead of Both (the default). Each eye camera's reflection material should bind only the RenderTexture that was rendered for that eye. That should at least render the reflections in stereo.
Also the reflection does not seem to be stereo but a single perspective. - aurelmHonored GuestThank.
Unfortunately cubemaps are not an option for me as I need realtime update of the geometry position in the reflection. Realtime cubemaps are very very slow on the phone.
Is there any way I could work around it without switching to unity 4.7 ?
Thanks - vrdavebOculus StaffYou could try hacking the Unity 4 integration to work with Unity 5, but we can't really support that.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 months ago
- 2 years ago
- 10 months ago