Mutiple camera masking issue.( need someone thinking with portals)

Hello everyone.

I’m doing a tech test for the fun of it and try to reproduce Portal in VR.
I’m facing an issue maybe you guys can help me with.
For the moment, each portal’s shader is a Depth mask showing the Camera that is behind.


This works but only to some extent. From time to time, i have one of my shader showing the wrong camera.
(I can explain why but it’s quite long and maybe I need to create a video for it)
So my question is this :

Does anyone know if there is a shader that can take the pixels of a camera of my choosing and replace the object’s pixels with the pixels from that camera ? But ONLY that camera, not other ones who may be at different places in the renderqueue.

I can’t really use rendertextures because of asynchronous timewarp and because of the fact it’s VR => 3D.
Let me know if it’s unclear. otherwise I can always do a video for you guys.

Thanks.

Yoirgl.

I’d recommend using the stencil buffer for this. That should also work fine for VR and single pass stereo. The other way would be RenderTextures, but those are not supported for VR camera’s, so you’d have to split into separate camera’s.