I mean, a real mirror in a first person game, like how a mirror works in real life.
First, when you look at yourself in the mirror, your mirror image should move with you on the mirror. When you move left, it moves left; when you moves closer, it moves closer and becomes bigger.
Second, when you look at other things reflected by the mirror, the mirror image should be the same with a view from a camera in the other side of the camera. Like in the picture below:
The second requirement is easy to do. But it conflicts with the first one.
Anyone has an idea?
Thank you very much!
However this new version targeting Unity 5 is giving me a ‘could not find entry point’ error. It used to work fine in Unity 4 so it’s either a bug or may be I’m missing something. Right now my workaround is to use the ‘Fx/Water’ shader instead from the standard assets.
Just take the unity example reflective water asset and trim out what you don’t need. Start with simplifying the shader, remove all the wave distortions etc.
Basically you need to render the mirrored camera to the texture, but clip whatever’s in front (or behind, from the reflection’s point of view) of the mirror. The cheapest way is to hack the camera’s clipping frustum, just like in the example water, take a look at the script.
Then you need to apply the camera to your mirror mesh in a screen space, not in model space (but again, that’s covered by the unity water)
Additional tip, to make the mirror extra cool, you could duplicate and mirror all the lights that would normally affect the mirror mesh, and generate an inverted mirror mesh (something like a big plane with a hole instead of mirror) to use as shadow caster. This will create an effect of the light being actually reflected, lighting different parts of the world
I don’t have specific knowledge to offer, but a general theory/suggestion.
have you tried a reflective material? There’s a Reflective section in the material presets with many options, one of them might give the realtime reflections you desire, and you could just apply it to a flat panel. if you’ve not tried, it can’t hurt to give it a test, won’t take you a few minutes =) i’d be curious how it goes for you too
Probes are now viable but still a bit meh in some conceptual ways. to get it to work as a mirror I used this script: var plane : GameObject; var character : GameObject;
With the variable “plane” being the mirror surface and the “character” being the player’s camera. There’s a few other things I had to do to make this actually work and I go into step by step detail in the video here.