Search Unity

Impossible space with Unity

Discussion in 'General Discussion' started by Meaningless-Trinket, Mar 19, 2021.

  1. Meaningless-Trinket

    Meaningless-Trinket

    Joined:
    Apr 25, 2020
    Posts:
    83
    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.
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    Ludum Dare had a game called "non-euclidian Room".
    You should check it out.
    http://ludumdare.com/compo/2016/12/23/non-euclidean-room-postmortem/


    To do portal culling, you'd need to use a shader with clipplane support for EVERYTHING. Or several shaders.

    Originally (up to DX9), graphic api would expose six clip planes to the user, but apparently starting since DirectX 10 they got deprecated:
    https://docs.microsoft.com/en-us/wi...ics-programming-guide-api-features-deprecated

    And instead we've got this:
    https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/user-clip-planes-on-10level9
    https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics

    On top of that you can clip stuff manually by hand using combination of pixel shaders and I think geometry shaders:
    https://www.ronja-tutorials.com/post/021-plane-clipping/

    Which means you'll need to use clip-plane capable shader for your scene, and setup the planes per object using SetPropertyBlock or something similar. And use that to clip things against portals.