Search Unity

Hide anything outside cube HoloLens

Discussion in 'VR' started by brianwill76, Apr 14, 2018.

  1. brianwill76

    brianwill76

    Joined:
    Feb 12, 2017
    Posts:
    12
    hello

    I am building a simple hololens project in Unity and within my scene I have a simple semi transparent cube.

    for the purpose of building for hololens, how can i tell unity to show any object as it moves inside of the cube, and then to disappear as it exist the cube.

    if the object is animating half in and out of the cube, then it would just display the part that is within the cube

    i tried surrounding the cube with black cubes, which kind of worked, but it seemed a messy way, and the cubes ended up being huge to ensure no part of an object was being shown

    thanks for any advice
     
  2. blueCubed

    blueCubed

    Joined:
    Oct 22, 2016
    Posts:
    2
    You need to work with a custom shader, Vertex shader will give you the transition effect. Pass in a position of the cube & size and then within the shader Fragment function, check to see if the worldposition is within you cube position plus size. If not, discard.

    This took me an age to work out for a scrollable holographic map, so best of luck!