Hi
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
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.
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.
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.