How can I make live reflection?

I would like to make a mirror material that will reflect all objects in the scene. Is this possible in PlayCanvas? If so how do I go about doing this?


There are two ways to do it, and as mirror is flat surface, you probably should go with single texture for reflection instead of cubemap (6 textures).

So you would need to reflect the camera position and angle using mirrors plane, then render scene into texture, but making sure everything between back of the mirror and camera - is not rendered. Currently it is only possibly by extending material to add discard based on plane clipping, which is annoying. But @Mr_F is working on WebGL 2.0 branch currently, and part of it is Camera Oblique Near Clip Plane - which allows to use near plane of frustum matrix to define clipping which can be “rotated” plane, that would do clipping even more efficiently and much easier to deal with.

Then once you’ve got that texture, you simply apply it back on that plane, flipping it in advance.
Another thing you can do to avoid even a texture, you could use scissors test to identify the area of mirror for main camera, and render scene with second camera but not into texture, but in back buffer. So it would render reflection directly in back buffer.

It is a custom thing you want to do, so there will be not a little amount of discovering and experimentation.

We do want to make that specific case easier to achieve in the future.
Perhaps once WebGL 2.0 branch is out, we can make an tutorial project with a mirror.