I was working an implementing portals (as in the eponymous game), but nerd-sniped myself when it occurred to me that a similar method might work for a mirror (I also thought it might be easier to implement. Hah! ) Soā¦
Portal
Two portals, two cameras. Each portal has a camera pointing outwards and each portal surface is rendered by the other camera. Then some serious fiddling about.
Mirror
One mirror, one camera. A single camera points outwards from the surface of the mirror and what it sees is rendered to the surface of the mirror.
Iāve given it the old college try and you can see the results here (https://playcanvas.com/project/872435/overview/portallike-mirror-public)
Itās vaguely in the right area, I get an image but itās the wrong size, and seems to be from the wrong angle (two other issues are the sky box not rendering and the āreflectionā is reversed without me even trying, but neither is really pertinent at this point).
The camera position mirrors* the player position, but Iām unsure where the camera should point. Should it point at the mirror, the player, or should it, too, mirror the player orientation?
Additionally, I suspect that I need to scale and clip the image before itās rendered to the mirror surface, but I have no idea how to do so.
How do I scale an image before rendering?
How do I clip the image from the camera? Can clipping planes be applied? Do I need to clip the image before rendering or is it possible to set clipping planes on the camera?
Do I need to write a custom shader to do this?
Any help or useful suggestions gratefully received.
TIA