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. Dismiss Notice

Mirrors/Portals/etc.

Discussion in 'General Discussion' started by yoonitee, Mar 9, 2015.

  1. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    So with all these new features in Unity 5, I hear everyone talking about mirrors and portals, etc.

    Is there a tutorial on how to do these things?

    For example how do you do a simple mirror on a quad. Presumably a portal is pretty similar except the camera is pointing somewhere else.

    Edit: Forget that. It's pretty easy. Just apply it to a render texture.

    For the mirror material I just used an unlit material is that right?

    It seems pretty fast. Updating in real time. Is there a way to make reflection probes go this fast too? For example I want a shiny sphere but the reflections update every few frames. Is it because it is having to calculate a spherical projection? Is it doing that on the CPU?

    Could I instead use a render texture(s) and a special shader to do mirrored spheres? I'm looking for performance more than accuracy.
     
    Last edited: Mar 9, 2015
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,064
  3. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    mirror.png Thanks Ryiah.

    I think this is still a bit slow though since it has to render 6 views.

    For a mirrored cube or quad it could be done with less cameras I'm sure. It's just a case or working out where to put the "mirror" camera.

    Actually do you need RenderToTexture for this? What you want is to render the scene from a different angle but use a stencil or something to just show the mirror bit. I'm sure that's how I used to do it in OpenGL.

    Like this:


    and this:
     
    Last edited: Mar 9, 2015
  4. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    OK. Made a simple mirror using a render texture. Not too difficult. Just got to position the camera where it would appear in a reflection each frame. Guess it's easier than messing around with stencils.

    Next I'm going to try combine 6 of these mirrors into a mirror-cube.

    Is there a better way of making a mirror-cube? Let me know. Thanks.
    reflection.png

    My mirror with a couple of shiny spheres with reflection probes inside them. You can also see the reflection of the mirror in the shiny sphere in the mirror! That blows my mind!

    Are there any good shaders for doing a refracted sphere? Such as a crystal ball or a water drop?

    I guess you could use a single rendertexture with a wide field of view and a displacement map to fake a cubemap if you really needed to speed things up.

    This is fun.

    Next. Is there any real time hair or water mechanics in Unity 5 or do we have to wait until Unity 6?
     
    Last edited: Mar 9, 2015
  5. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    Two mirrors:

    two_mirros.png
     
  6. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    For some reason your scenes remind me of Amiga computer demos. Add a large bouncing ball and you'll have it!
     
    Ryiah and Ostwind like this.
  7. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    Yeah. You could do all this stuff in Photon Paint on the Amiga 600 20 years ago.

    Now you can do the same thing, you need a 2GB game engine and 5 years practice of C#.

     
    Ryiah and GarBenjamin like this.
  8. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    @yoonitee speaking of camera and rendering tricks, could you take a look at this? I'm being a little impatient about it, but I can't find anything about it lol.
     
  9. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    Infinite reflections with two mirrors in real time:

    infinite.png

    I'm not sure how to use render textures yet to make a mirrored floor. There appears to be too much distortion when projecting at a high angle.

    Really these mirrors are just TV screens, but they look OK for mirrors if the angle is not too high.

    Are there any tutorials for doing mirrors with stencilling?
     
    Last edited: Mar 10, 2015