I got the idea to make impossible space from this.
I still don’t know how its made exactly.
I’ve made my own impossible space while trying to make Marathon game maps in Unity.
The game Marathon uses portal occlusion culling and the impossible space effect from the game is called 5-D space.
How my way works is there is a box collider around the portal.
The portal is a quad that has a mathematical plane in the direction of the quads normal.
When the player walks into the box collider the next sector is rendered normally.
While still in the box collider, the player camera is a point that gets its distance checked to the portal plane.
if the player exits while on the positive side of the plane then the next sector is rendered by the portal.
if the player exits while on the negative side of the plane then the next sector is rendered normally.
The quad has a shader on it that is a stencil mask and the sector has a shader attached that is read by the stencil mask.
The portal and sector use the same ref number.
The sector switches from equal to always.
The portal is rendered before the sector in the render queue.
The collision is separate meshes that are different layers and anything that enters the portal changes its layer to the sectors layer.
Items or enemies can be rendered by the portal or rendered normally while the player is in the same sector.
I’m searching for ways to do portal occlusion culling with Unity.
Impossible space is a side effect of portal based occlusion culling.