- Home /
Multiple Cameras with Steam VR, Unity 5.4
I am having an issue with Steam VR and multiple cameras. I have the default SteamVR [CameraRig] in my scene along with an additional camera. I need to have a separate camera so I can selectively apply the appropriate graphics FX to only a single layer of my scene. My set up is as follows-
The Camera(eye) in the default steam vr rig is set to: Clear Flags- Depth Only Culling Mask - Everything is checked except for one layer called "neon" Depth - Set to 0
My second Camera is set to: Clear Flags- Skybox Culling Mask - The only layer checked is "neon" Depth - Set to -1
Now for my problem: The items that are in the layer neon are visible and they show up just fine, but they are not in displayed in the correct positions in game. This is an issue with the camera, the game objects are in the right location in scene view, but in the incorrect space in the camera view. I have no idea what is causing this. Both cameras are in the exact same location and share world position and rotation.
How do I fix this?
Answer by DoctorLucky · Oct 19, 2016 at 02:32 AM
I'm doing a similar thing in my game - when hovering over a selectable object, a wireframe of that object is created that is visible through objects.
It's actually pretty simple, as long as you aren't creating the second camera via script (which introduces problems I haven't been able to solve). Create a copy of your Camera (head) object, also childed to the [CameraRig] object. On this copy, delete the Camera (ears) object - can't have two AudioListeners. On the copied Camera (eye), set Clear Flags to Depth Only and your culling mask to whatever you want to show through. Uncheck those layers on your original Camera (eye) object to avoid coplanar face rendering bugs.
That should be it! Let me know if anything is unclear and I'll elucidate.
@DoctorLucky, thanks SO much! I've been struggling with this problem for a while and your method works great, you've saved me many hours.
I'm glad it worked for you! I searched the forums for an answer myself for a while, but it only ended up taking me a couple hours to think of this solution. I'm still toying around with a script to automatically add the child camera and set up its flags, but so far it's run into some issues at runtime. If I find a solution and make a working script, I'll post it here.
Answer by phwater · Jul 18, 2017 at 09:18 AM
Same problem in Unity 5.6.
I found that after add steamVR plugin to unity, component Camera have a new option named Target Eye. when you change your second camera's Target Eye to None (Main Display), it will get right postion in scene. BUT also cause the Gameobjects it seen twisted. so, it seem like camera position changed just before Unity Rendering Frame.
Answer by VisionPunk · Aug 30, 2016 at 11:21 AM
If you haven't already, try adding a "Steam VR_Camera" script to the gameobject of your additional camera.
Also, Steam VR modifies each camera hierarchy at runtime and it may be necessary to make a script that sets your custom camera's root transform position to the same position as the main camera's root transform position, every LateUpdate.
Your answer
Follow this Question
Related Questions
SplitScreen shooter with Viewmodels and PlayerModels without so many layers? 1 Answer
Setting Vive ipd without using hmd knobs 1 Answer
Camera layering : UI shader is cleared by second camera with Depth Only flag 1 Answer
Help I cant use multiple cameras with layers. [Solved] 1 Answer
SteamVR: Eye camera does not seem to support depth only; 3D skybox implementation impossible 1 Answer