TomorrowTodayLabs / NewtonVR

A virtual reality interaction system for unity based on physics.
MIT License
788 stars 196 forks source link

Vive Mixed reality bug (due to new oculus friendly camera rig?) #122

Open tompainter opened 7 years ago

tompainter commented 7 years ago

Newton 1.12 (or maybe earlier but this is the one I tested) breaks the steamVR_externalCamera thing that makes mixed reality videos possible, Ive found the newton dated from October 5th doesnt do this (different camera rig) but it has its own bugs like the shakyness of the objects you pick up

This is the link to the mixed reality guide, I think a lot of devs need this functionality these days. https://steamcommunity.com/app/358720/discussions/0/405694031549662100/

zite commented 7 years ago

Sorry I don't really understand. What is broken?

mlesauvage commented 7 years ago

Verified the bug this evening. Enabling a third camera turns on the quad view as expected. However, the camera view for third-person video is not positioned correctly. It does move with the third controller, but aiming is not in the forward direction of the controller. I didn't do detailed testing, but it may be off 90 degrees vertically (meaning you have to aim the controller down to look straight ahead).

I also had an instance where the third person camera was being aimed by the headset; unsure if that was an unrelated issue or not.

tompainter commented 7 years ago

Hi sorry I hadn't replied to previous reply.

basically if you use an october build, the steam external camera (the 3rd controller) works as normal, but if you use a newer build its as theElTea describes.

The camera rig has changed to support oculus so I think that might have something to do with it?

thanks Tom

SmartCarrion commented 7 years ago

I ran into a version of this today, I think there is a conflict with the UI camera that gets added to the hands. When the mixed reality third controller camera was turned on, the laser pointer no longer works.

SmartCarrion commented 7 years ago

I found a fix for this, as far as I can tell. There are two pieces I found broken...you need to fix how the camera is 'copied' from the head by removing any unnecessary components that screw with tracking, then you need to not change the viewport rect on any UI laser pointers you are using. I fixed these bugs with changes to SteamVR_ExternalCamera, but you might be able to do them with changes to Newton code if you tried hard.

when camera is copied from head, remove tracked components and anything that could conflict. This will be different depending on your project:


// Make a copy of the eye camera to pick up any camera fx.  
 vrcam.enabled = false;
 var go = Instantiate(vrcam.gameObject);
 vrcam.enabled = true;
 go.name = "camera";
 //START NEW CODE ADDED
 DestroyImmediate(go.GetComponent<GUILayer>());
 DestroyImmediate(go.GetComponent<FlareLayer>());
 DestroyImmediate(go.GetComponent<SteamVR_Ears>());
 DestroyImmediate(go.GetComponent<AudioListener>());
 DestroyImmediate(go.GetComponent<ValveCamera>());
 DestroyImmediate(go.GetComponent<AudioSource>());
 DestroyImmediate(go.GetComponent<NewtonVR.NVRHead>());
 DestroyImmediate(go.GetComponent<SteamVR_UpdatePoses>());
 DestroyImmediate(go.GetComponent<SteamVR_TrackedObject>());
 //END NEW CODE ADDED
 DestroyImmediate(go.GetComponent<SteamVR_Camera>());

Then when controller camera that does raycasting is processed, make sure its viewport does not get modified


if (cameras != null)
{
    var numCameras = cameras.Length;
    cameraRects = new Rect[numCameras];
    for (int i = 0; i < numCameras; i++)
    {
        var cam = cameras[i];
        cameraRects[i] = cam.rect;
        if (cam == this.cam)
            continue;
        if (cam.targetTexture != null)
            continue;
        if (cam.GetComponent<SteamVR_Camera>() != null)
            continue;
        if (cam.name != "Controller UI Camera") //ADD a line like this to not process any UI raycasting cams
            cam.rect = new Rect(0.5f, 0.0f, 0.5f, 0.5f);
    }
}