Creating a realtime mirror

Hi :slight_smile:
I’m working on a realtime mirror, using a camera and render texture. I can get quite far, but something seems off on device compared to what I’m seeing in the Unity editor. Has anyone else managed to create a working mirror?

I’m thinking that the FOV plays a role here. Is it possible to get the FOV of the device camera? Also, I notice a lot of banding on the render texture. What would be the right color format to use for this?

Thanks for sharing :slight_smile:
There are a couple of issues with what he’s doing in that video. First of all, the camera is static, so when you move around, there’s no depth to the reflection. Also, his fix for inverting the mirror by giving it a negative scale on the x-axis is not allowed on Vision Pro (we even get a warning in the editor). I fixed that by mirroring the UV coordinates on the mirror mesh in Blender instead of using a negative scale.
However, the issues I mentioned above with the FOV and color format are not addressed in the video.

Hi, @pcah81 , is this a realtime mirror of the “real surrounding environment” or a realtime mirror of the virtual content?

I recently came across an app, and I tried it. It did show the “real surrounding environment” in the virtual mirror. Really scared me, this is crazy!

If it’s using a RenderTexture, then it’s a mirror of the virtual content in the Unity scene.

You can reflect the real-world environment in MR either by using a material with maximum smoothness/metalness (i.e., one that simulates polished metal) or by using a shader graph with the Environment Radiance node (which allows you to sample the image based lighting and process it further). In either case, the reflection map used is obtained from the device cameras. There are some limitations; the device doesn’t have complete 360 degree camera coverage, so the environment map is partially estimated.

Hi, @AndrzejUnity , thanks for the info.

Yes, I tried the simple approach of maximum smoothness/metalness material, and it did work!

I thought developers do not have access to device camera? But if the material can reflect the eivronment, does it mean it is possible to build some hacky workaround to extract partial data of the device camera?

No, because that data is only accessible in the shader. There’s no way to get the camera feed out of the shader; RealityKit doesn’t allow you to render it to a texture, for example.

Thanks, @AndrzejUnity !

This is kind of what I was expecting. Thanks for the clarification