Revision 1: The Mirror


Hello there, good people of the itch!

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. 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. It renders 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 and wish you a merry Christmas or otherwise a happy last couple days of december.

Cheers!

Leave a comment

Log in with itch.io to leave a comment.