Different geometry rendered to each eye — Oculus
Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Different geometry rendered to each eye

FioreFiore Posts: 13
edited December 2015 in Unity Development
Is it possible to have 2 pieces of geometry in Unity, and have each one only viewable from a single eye?
I do not have a rift to test, but am looking at ways to use one billboard for each eye, each with offset pre-rendered image that would represent a single 3D object when viewed through the rift.
«1

Comments

  • HappyHimitsuHappyHimitsu Posts: 990
    Art3mis
    Dang that's an interesting idea Fiore. I'm not sure though, it sounds somewhat 'headachy' to me, but perhaps I just don't grasp the concept in it's entirety.
    I'm curious to know how it works out!
    “If you are willing to look at another person’s behavior toward you as a reflection of the state of their relationship with themselves rather than a statement about your value as a person, then you will, over a period of time cease to react at all.”
    (~I really gotta remember this shiz~)
    ― Yogi Bhajan
  • owenwpowenwp Posts: 681 Oculus Start Member
    Easy to do, just put a call in OnPreRender on each eye that sets a global shader constant for the eye number, and use it as a branch condition or texture offset. Check the docs for the shader class.
    Sanzaru - Programmer
  • ScsiOverdriveScsiOverdrive Posts: 88
    Brain Burst
    Another solution:

    - Create two new layers named "left eye" and "right eye"
    - Adjust what layers each camera has visibility to (left camera cant see right eye, etc.)
    - Assign the special billboarded textures to each eye
  • cyberealitycybereality Posts: 26,156 Oculus Staff
    I had the idea of stereoscopic billboards for a while now, but I haven't seen them used yet.

    Would be awesome if you got this working.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i
    Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
  • sh0v0rsh0v0r Posts: 498 Oculus Start Member
    Another solution:

    - Create two new layers named "left eye" and "right eye"
    - Adjust what layers each camera has visibility to (left camera cant see right eye, etc.)
    - Assign the special billboarded textures to each eye

    Yeah this is the simplest way to control what a camera renders.
  • judivajudiva Posts: 11 Oculus Start Member
    I tried to "OnPreRender" approach without success.

    I am using Unity 5.1.1f1 with a pre 0.6.0.1 SDK (the one just before, can't remember the number). I'm not using the latest SDK because I can't get it to display the dual view inside the Unity editor.

    Anyway, I'm seeing that the onPreRender callbacks are called, but they have no effect on the rendering.
    I have set it up so that the geometry is rendered in red on left eye and blue on right eye (using a material shader parameter).
    Anyway, what I am seeing in the GearVR is that both cameras render the scene in blue (meaning that only the shader settings from the right eye are taken into account). Since right eye is rendered after left eye, I'm guessing my callback is overwriting the shader's value, so both eyes get the same value.

    Has anyone been successful with this approach?
    I'm considering trying this out with sdk 0.6.0.1, but the fact that I can't get OVR initialized in the editor and get no dual view is a real pain...
  • judivajudiva Posts: 11 Oculus Start Member
    Ok I did run a test with SDK 0.6.0.1 / Unity 5.1.1 and it works :)
  • How did you access to the sdk directly from unity???
  • cyberealitycybereality Posts: 26,156 Oculus Staff
    You can't use the SDK directly in Unity. You'd use the integration or (preferably) the utilities.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i
    Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
  • TomGTomG Posts: 15
    NerveGear
    judiva wrote:
    Ok I did run a test with SDK 0.6.0.1 / Unity 5.1.1 and it works :)

    Could you share some example code on how to accomplish this? i went ahead and added a new camera on to each eye anchor and removed some code in OVRCameraRig so they would not get disabled in the 6.0.1 tools.

    This works and stereoscopic bilboards are great to look at, but i would like to avoid the 2 extra cameras.
    Also for some reason, movement seems a bit wonky, where the default OVRPlayerController would not walk perfectly in the direction you're looking. when i disable my 2 new cams and just enable the center one, the movement is as expected.

    a movieMaterial where the offset can be controlled acording to the eye that is rendering at that time would be great. I'm just starting unity (coming from the flash world) but if you want to go Oculus.... (and have a comunity that is still arround :-) ) go Unity :-)

    Thanks in advance for any more detailed pointers on how to accomplish this.
  • cyberealitycybereality Posts: 26,156 Oculus Staff
    Please use Unity 5.1.2p2 or higher and add a second Camera to the centerEyeAnchor GameObject. Then set the stereo eyes on the 2 cameras to Left and Right and set their culling flags so the textures only appear to one camera at a time. It's all in the editor GUI, no scripts. Hope that helps.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i
    Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
  • TomGTomG Posts: 15
    NerveGear
    Had to position the extra cam next to the centerEyeAnchor, when attached as a child, the rotation went pretty wrong. it's working fine now, Nice!

    Thanks!

    So if i understand correctly i'm throwing away some performance in doing it that way. Is the stuff below possible and would it have an beneficial effect on performance?
    • Have a central camera set to Target Eye: Both, have it render everything except for left and right culling masks.
    • Have a left camera for left, set culling mask to ONLY render left
    • Have a right camera for right, set culling mask to ONLY render right
    play with the depth of the cameras so the central one would render everything needed and then layer the left and right on top of that.

    I've tried the above, but can either only get everything to render (except the stereo layers) or only the left right cameras, according to the depth i put the cameras in. is there any trick to "merge" the 2 layers? or am i going totally off board with this and would it not really help performance anyway?

    Again thanks for the support!
  • ahtramahtram Posts: 2
    Please use Unity 5.1.2p2 or higher and add a second Camera to the centerEyeAnchor GameObject. Then set the stereo eyes on the 2 cameras to Left and Right and set their culling flags so the textures only appear to one camera at a time. It's all in the editor GUI, no scripts. Hope that helps.

    Hi, I'm using 5.1.2 with the Oculus Utilities for Unity 5 V0.1.0-beta
    But I found there's no way to use separate cameras for different eyes.

    In Unity's document: http://docs.unity3d.com/Manual/VROverview.html
    They state:
    Automatic stereo display
    It is not required to have two Cameras for stereoscopic displays. Any camera that has no render texture is automatically rendered in stereo to your device. View and projection matrices are adjusted to account for field of view and head tracking.
    Optimizations automatically occur to make it less expensive to draw frames twice (once for each eye).

    Is that means I have to use the mobile SDK 0.6 for the rendering two different textures each eye trick?
  • TomGTomG Posts: 15
    NerveGear
    as stated in the posts above you can add a second camera and set it's rendering to only left eye, and the original one you can set to render only the right for example, it is perfectly possible with 5.1.2p3 as i'm doing right now.
  • ahtramahtram Posts: 2
    TomG wrote:
    as stated in the posts above you can add a second camera and set it's rendering to only left eye, and the original one you can set to render only the right for example, it is perfectly possible with 5.1.2p3 as i'm doing right now.

    How do you make a camera only render one eye?
    What version of SDK you're using?
  • Bump,
    How do you make a camera only render one eye?
    Is it possible with Unity 5.1.3f1 and Oculus Utilities for Unity 5 V0.1.0-beta ?
  • cyberealitycybereality Posts: 26,156 Oculus Staff
    Yes, you can do it in Unity 5 with the Oculus Utilities. Here are the steps:

    - Import Oculus Utilities into your project (I'd start with a new project just for testing).
    - Comment out the foreach block (around line 179 - 189) in OVRCameraRig.cs.
    - Inside the Heirarchy, duplicate CenterEyeAnchor and name it CenterEyeAnchorLeft. Leave the original one alone.
    - Go in the CameraEyeAnchorLeft and set "Target Eye" to "left". Make the original "right"
    - Create two new layers "Camera Left" and "Camera Right".
    - Go in the culling mask for the camera component on CenterEyeAnchorLeft and deselect the "Camera Right" layer. Do the same for the original CenterEye (but with "Camera Left").
    - Make sure any stereo geometry is set to the proper layer. Meaning objects only visible in the left eye should have the layer of "Left Camera" or similar for the right.

    This will allow things like stereo textures, or displaying completely different objects in each eye.

    Hope that helps.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i
    Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
  • - Go in the CameraEyeAnchorLeft and set "Target Eye" to "left". Make the original "right"

    Hi,
    i'm trying follow your steps - but i can't find any setting or component in the CenterEyeAnchor or anywhere else which says "Target Eye" - what am i doing wrong ? Or do i get it wrong ?

    I'm using DK 1, Unity 5.2 and Utilities for U5 v0.1.0-beta - and start with the cubes scene. On none of these game objects i can find that "Target Eye" setting:
    - LeftEyeAnchor
    - CenterEyeAnchor
    - RightEyeAnchor
    greetings from bavaria
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    To do this you need to be using 5.1.3p2.
  • Ok, thanks! Now there is a Target Eye setting available :-)
    But it seems to be removed again with the 5.2 release ... is this method a dead horse i'm betting ?
    greetings from bavaria
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    The feature hasn't been merged to 5.2 yet. You can probably expect it to appear in 5.2 within the next 1-2 weeks.
  • Ah, ok thanks :)
    greetings from bavaria
  • andrewtekandrewtek Posts: 971
    Art3mis
    I had the idea of stereoscopic billboards for a while now, but I haven't seen them used yet.

    Would be awesome if you got this working.
    OPamp and I were playing around with this concept in Unreal Engine. Here is a link to a Material BluePrint that can be used to do it. Having different geometry (or textures) in each eye can get headache inducing fast though. In my most uncomfortable scenario, I applied a stone texture to a cube in one eye, and a color-inverted version of that texture in the other. In some simple examples, the brain will add things together (so you can get some interesting mechanics); but using completely different textures != comfortable.
  • crevvercrevver Posts: 93
    Hiro Protagonist
    Did this get blown out of the water with V0.7?

    Currently Using Unity 5.2 and Oculus 0.7, and no options for target eye exist. I can do the double rig thing, but how does it know to do the IPD thing...
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    No, the Target Eye option should still be on the way. To change the IPD, please adjust the local scale of your OVRCameraRig GameObject.
  • YamroZYamroZ Posts: 12
    NerveGear
    Wow this works like a charm. Thank you!

    Unity 5.2 and OVR utilities 0.1.0 DK2
  • Yes, you can do it in Unity 5 with the Oculus Utilities. Here are the steps:

    - Import Oculus Utilities into your project (I'd start with a new project just for testing).
    - Comment out the foreach block (around line 179 - 189) in OVRCameraRig.cs.
    - Inside the Heirarchy, duplicate CenterEyeAnchor and name it CenterEyeAnchorLeft. Leave the original one alone.
    - Go in the CameraEyeAnchorLeft and set "Target Eye" to "left". Make the original "right"
    - Create two new layers "Camera Left" and "Camera Right".
    - Go in the culling mask for the camera component on CenterEyeAnchorLeft and deselect the "Camera Right" layer. Do the same for the original CenterEye (but with "Camera Left").
    - Make sure any stereo geometry is set to the proper layer. Meaning objects only visible in the left eye should have the layer of "Left Camera" or similar for the right.

    This will allow things like stereo textures, or displaying completely different objects in each eye.

    Hope that helps.

    Works brilliantly!
  • Yes, you can do it in Unity 5 with the Oculus Utilities. Here are the steps:

    - Import Oculus Utilities into your project (I'd start with a new project just for testing).
    - Comment out the foreach block (around line 179 - 189) in OVRCameraRig.cs.
    - Inside the Heirarchy, duplicate CenterEyeAnchor and name it CenterEyeAnchorLeft. Leave the original one alone.
    - Go in the CameraEyeAnchorLeft and set "Target Eye" to "left". Make the original "right"
    - Create two new layers "Camera Left" and "Camera Right".
    - Go in the culling mask for the camera component on CenterEyeAnchorLeft and deselect the "Camera Right" layer. Do the same for the original CenterEye (but with "Camera Left").
    - Make sure any stereo geometry is set to the proper layer. Meaning objects only visible in the left eye should have the layer of "Left Camera" or similar for the right.

    This will allow things like stereo textures, or displaying completely different objects in each eye.

    Hope that helps.

    Thank you for that. However, in order to make things more usable, I added cameras to the LeftEyeAnchor and RightEyeAnchor and refactored the OVRCameraRig.cs script so that the OVRCameraRig.leftEyeCamera and OVRCameraRig.rightEyeCamera return the actual left and right cameras.

    I let the camera on the CenterEyeAnchor with rendering disabled just for Unity UI picking purpose.
  • scottsquiresscottsquires Posts: 331
    NerveGear
    Using 5.2 I've just duplicated the main camera. Named one left camera and other right camera.
    Set Left and Right Target Eye in Camera inspector to match.
    Then add Left and Right layers.
    Then set Culling to match in Camera inspector of each camera.

    Seems to be working fine but wondering if I need to go through the other steps outlines above.

    >> Comment out the foreach block (around line 179 - 189) in OVRCameraRig.cs.
    >> Inside the Heirarchy, duplicate CenterEyeAnchor and name it CenterEyeAnchorLeft. Leave the original one alone.
  • motorsepmotorsep Posts: 1,364 Oculus Start Member
    Is it possible to apply this approach with duplicating cameras to Unity's native VR (without using Oculus Utils) and player's controller from Unity's VR samples?
Sign In or Register to comment.