- Home /
How to mask a camera using the render from another
I have 2 cameras, one which renders at a DESTINATION position, and the other which renders next to the player for a simple portal effect. The DESTINATION camera renders under the PLAYER camera, and I use a shader to clip the PLAYER camera, revealing the screen buffer from the DESTINATION camera.
The only problem is that if the portal appears in an open air area, then the skybox renders as the destination camera.
The way I see it I need to somehow restrict the rendered area of the DESTINATION camera using the portal's geometry. The only problem is that I have no idea how I would go about doing such a thing.
The process I've been thinking about is like this, but I wouldn't know how to convert it to code.
Render only the portal geometry using a third camera, store this information somehow.
Render the player camera.
Render the destination camera masking it somehow with the stored mask.
Any thoughts and preferably example code on how to do this. I think it has something todo with the stencil or depth buffer, but the shaderlab docs on how to manipulate those weren't terribly helpful.
As you can see in the video, the cylinder appears in the background.
Render the "destination" to a texture and apply that texture to the portal object.
Your answer
Follow this Question
Related Questions
Implement texture masking into simple existing shader 1 Answer
How to apply refraction at marked texture pixels while the rest is being rendered normal? 1 Answer
Shader: Cutout behavior mixed with masking behavior 0 Answers
Losing image effects in build process 1 Answer
Shader based camera compositing. 2 Answers