I have two cameras. The second was made by duplicating the first. Then I changed both cameras' viewport rects:

  • First Camera X = 0 Y = 0.25 W = 0.5 H = 0.5
  • Second Camera X = 0.5 Y = 0.25 W = 0.5 H = 0.5

Then I created two Post Process profiles for each camera, CC and CC1 in the Inspector.

The result:

Eyes

But it seems to me a bit odd. Since the view through both eyes looks the same.

Shouldn't the right eye be rotated or something, so it's completing the view from the right side? That is, I don't want both cameras (eyes) see the same (right-hand) view.

  • 1
    you could also just use one camera, with a mask texture on it that has two holes to represent the player's eyes :) that would solve a lot of problems, since you are simulating how you'd see through the mask – Gabriele Vierti Nov 30 at 8:31
  • 3
    Did you try offsetting the positions or orientations of the cameras in space to get the effect you want? Changing the viewport rect just changes where the output image gets drawn — it doesn't change the camera's perspective. You need to manipulate the camera's transform in the world (or its projection matrix) to do that. – DMGregory Nov 30 at 12:25
  • 1
    Why are you doing this? Are you trying to create some simple stereoscopic effect like with Google Cardboard? If you want to create a VR game, then Unity does that out-of-the-box. – Philipp Nov 30 at 14:30

You see, Cameras in Unity are designed to behave like a human eye:

camera

As you can see from the image above, notional cameras have what's called a View Frustum; To put it simply, it simulates what the human eye would see in real life between a near and far plane (you can always read more here).

Now let's see how I would solve this:

First of all create a Canvas:

  • Go to the hierarchy window, Create -> UI -> Canvas and set UI Scale Mode to Scale With Screen Size;
  • Create an Image object as a child of the newly created Canvas by going (right-click on Canvas) UI -> Image;
  • Stretch the image to cover the size of the canvas ( remember to hold down alt in order to do so) : gif

Now that you have done that, you could have a "mask" image like these ones for instance (yes, they are both 4k res and you can use them however you want :D):

1

2

Remember that when making a mask, the white portion of the image should have an alpha of 0.

  • Now that we also have a mask, we can just apply that to the Image we created (when importing the image, remember to set Texture Type to Sprite (2D and UI):

5

And that's it! To improve even more the effect, you could try making the "lenses" with a gradient, adding multiple layers of textures with different drawing orders to create dirt, or waterdrops, animate the mask to act as an helmet that is being put on / took off ecc..

You can really go crazy with post processing effects too; have fun! :D

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.