Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

What's wrong with my rear view mirror?

Discussion in 'Editor & General Support' started by arashi256, Aug 30, 2013.

  1. arashi256

    arashi256

    Joined:
    Oct 11, 2012
    Posts:
    9
    I tried posting this on Reddit under the Unity3D subreddit, but haven't had much luck finding an answer, so I'm hoping somebody here can help.

    I have a rear view mirror for my car game which is a camera facing backwards writing to a render texture which is display upon OnGUI(). The main camera is on layer -1, the rear view camera is on layer 1. It writes the data from the rear camera to the texture for the road and other cars but the skybox and terrain are missing from the view. In fact the sky is totally transparent and shows the view ahead instead.

    Here is a example of my issue

    Everything above the road is transparent and doesn't show the terrain in the rear view mirror, nor the rear view of the skybox.
    I have attached a skybox material to the rear view camera, but this makes no difference. I can vaguely see a very faint ghost image of the terrain contours in the rear view mirror but it's not actually showing.

    I've tried all the Clear Flags settings available with the following results: -

    Don't clear - clears everything so that the rear view mirror is essentially just a clear frame showing everything in front.
    Depth only - no effect, same as using Skybox.
    Solid color - Skybox is blank as solid colour as expected. But the terrain contours between the road and the sky are transparent but the transparency follows the contours of the terrain as though it's being masked out somehow.

    Does anyone have any idea what I'm doing wrong?
     
  2. arashi256

    arashi256

    Joined:
    Oct 11, 2012
    Posts:
    9
    Okay, if I use this: -

    rearViewMirrorTexture = new RenderTexture(256, 128, 32, RenderTextureFormat.RGB565);

    Everything appears as it should - apart from the skybox....which appears inverted. This might be because my rear view camera is using the script from here: -

    http://wiki.unity3d.com/index.php?title=InvertCamera

    ...to invert the view so that cars pass me on the correct side of the mirror (otherwise cars appearing on the left in the mirror actually pass on the right). Any idea how I fix this so that the skybox is right way up?

    Almost there!