Hello, guys! I am making a portal effect and planing to place a cube map at the bottom of the “can”, and side walls would be of panning material with distortion. The problem is I don’t know how to get rid of outer walls that should not be visible.
On screenshot below marked these with X. In other words I would love to have sort of a pocket, that that you can look into only from particular side and should be invisible from other directions. Sort of Harry Potter Invisibility Cloak
Not super straightforward with how rendering works.
The fragments in the back don’t really have context to figure out if they are obscured or not.
One option would be to draw into the depth buffer, then when drawing the shape, check if it is obscured by the depth buffer or not, you could then also use that same depth buffer to figure out if other elements behind the portal should draw in font, inside, or behind it
Thank you for the hint. Watched few videos about stencil buffer, looks like it could help. But did not manage to do it so far, I can only paint the whole thing even it is obscured by other meshes.
Looks like I need depth but not stencil buffer, will investigate further.
maybe you can fake it with a camera on the other side of the wall, capture this camera to render target and just place it masked into the middle of the portal.
Yeah, render target could work, but its performance heavy.
I continued experimenting with stencil buffer and understood that post process material can not help me. Because the picture is already rendered when it is input in post process, so it can not know what is below the surface we would like to discard. May be I am wrong?
Another way is trying to make sort of opacity mask for black hole material, and somehow it should be dependent on cap position.
Hey there,
I know you already solved it with a custom stencil, but another option could be to just use a TwoSidedSign and then a one minus depending on the direction your normals are facing.
Thank you! I tried your method but nothing happened.
I wanted to get the following result: red shaded part should not be visible at all, only its internal part and only when looked from the “hatch”, and the one in blue circle should be visible.