Jump to content

Unity issue while rendering a camera


Recommended Posts

Hi, 

I'm trying to create a portal, and the user should see what's on the other side.

To do that, I'm rendering two cameras (one for each eye) at the "destination", and the RenderTexture is projected with a simple custom shader to a surface (two actually, but it doesn't matter).

My issue is that while on the simulator works (both on the editor and on direct preview), on the device the camera is rendered on a different time than the surrounding,  giving the impression of a delayed render and breaking the effect of a continuous area.

Right now this is the lateupdate code I'm using, anyone has clues on why this doesn't render correctly?

private void LateUpdate()
    {
        var localToWorldMatrixLeftEye = playerCameraLeftEye.transform.localToWorldMatrix;
        var localToWorldMatrixRightEye = playerCameraRightEye.transform.localToWorldMatrix;
        fakePlayerCameraLeftEye.projectionMatrix = playerCameraLeftEye.projectionMatrix;
        fakePlayerCameraRightEye.projectionMatrix = playerCameraRightEye.projectionMatrix;

        localToWorldMatrixLeftEye = otherPortal.transform.localToWorldMatrix * transform.worldToLocalMatrix *
                                    localToWorldMatrixLeftEye;
        localToWorldMatrixRightEye = otherPortal.transform.localToWorldMatrix * transform.worldToLocalMatrix *
                                     localToWorldMatrixRightEye;
        
        fakePlayerCameraLeftEye.transform.SetPositionAndRotation(localToWorldMatrixLeftEye.GetColumn(3),
            localToWorldMatrixLeftEye.rotation);
        fakePlayerCameraRightEye.transform.SetPositionAndRotation(localToWorldMatrixRightEye.GetColumn(3),
            localToWorldMatrixRightEye.rotation);
    }

I'm copying on the start method the right and left eye cameras settings, just to be sure to get the same fov, position, etc.

Any idea?

Thanks,

Francesco

Link to comment
Share on other sites

Update: I got a slightly better result with the beforeRenderEye callback:

 private void BeforeRenderEye(WaveVR_Render render, WVR_Eye eye, WaveVR_Camera wvrcamera)
    {
        var fakePlayerCamera = eye == WVR_Eye.WVR_Eye_Left ? fakePlayerCameraLeftEye : fakePlayerCameraRightEye;
        var playerCamera = eye == WVR_Eye.WVR_Eye_Left ? playerCameraLeftEye : playerCameraRightEye;
        var localToWorldMatrix = playerCamera.transform.localToWorldMatrix;
        fakePlayerCamera.projectionMatrix = playerCamera.projectionMatrix;
        localToWorldMatrix =
            otherPortal.transform.localToWorldMatrix * transform.worldToLocalMatrix * localToWorldMatrix;
        fakePlayerCamera.transform.SetPositionAndRotation(localToWorldMatrix.GetColumn(3), localToWorldMatrix.rotation);
        fakePlayerCamera.Render();
    }

 

But there's a slightly delay between the right and the left eye, causing an annoying asymmetric delay.

Any suggestion is welcome 🙂

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...