Hello there, good people of the jolt!
Today, lets talk about the single-most important thing in the game: The mirror.
Perhaps you've gathered by now that it shows you things, the human eye can't see. If not - well, now you know.
In the picture above that will be two magic sources (More on those on another day).
But not only can it show you things that are not there but it also shows things that should be.
Here, among other things, you see that the "real world" has that sphere distorted out of proportion. But in the mirror it looks to be correct. It's behind a yellow box which is also not there in the real world.
The question that will be answered today is: How do we do it?
The simple answer is: Camera trickery.
We have 2 cameras that each render the scene in their own way.
The yellow camera is rendering the image in the mirror (weird property for a mirror, isn't it? But it's magic!).
It renders the basic world and things that are only visible through a mirror. We let it render into a render texture and slap that texture on the mirror mesh. There's a distortion map applied to it as well so it looks like the mirror surface is uneven and somewhat broken or used.
Here you see the camera rendering directly on screen rather than into a render texture. It's the little picture inside the picture. It's a lot smaller than the player view resolution. Mostly for performance reasons. Currently the texture is 512x512 pixels small. We might make it an option to change the size. A good PC should handle 1024 or higher easily.
The purple camera is rendering the view of the player.
That's the simple part. It renders the player view on screen directly and shows the basic world and things that are only visible outside of the mirror.
With that kind of setup it's easy to do some magic tricks.
Lets see here.
The distorted ball again.
In the mirror camera we see a normal ball with a purple aura. Or whatever it is.
In the player camera we see the distorted ball and it wobbles.
If we were to pull it apart we can see this in the the editor:
It's simply 2 balls, each on a separate layer but at the same position. Doesn't get any simpler than that, I suppose. But there are more fancy things that can be done.
Like magicking a thing back into position by interacting with the object in the ghost world.
And there you've seen the mirror in action as well. With that, I'll sign off. Until the next time!
Cheers!
0 comments