Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

What do I need for occlusion ?

Discussion in 'AR' started by football928, Mar 28, 2018.

  1. football928

    football928

    Joined:
    Sep 24, 2015
    Posts:
    17
    I was attempting to write a script that would turn the mesh renderers off if they are behind a vertical surface with AR kit 1.5. I tried to do this by taking all the game objects in the scene that didn't have a tag "Plane". Then got the direction from the camera to the object, I would cast a ray from the camera towards the current object. If it hit anything other than the current object, in this case vertical planes, it would disable the mesh renderer. Didn't work as expected so after looking into it and looking for other people that has successfully done this, I found some videos about geometric occlusion and that unity has a example scene of it. Works perfectly, I just can't figure out how to do it on my own objects. I finally found a occlusion slot in the material that is on the doll. I also found a occlusion material and a shader. So my question is what components do I need to make my objects work like the doll?
     
  2. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    You just make the plane prefabs use the occlusion material (e.g use the occlusionPrefab) and then virtual objects on the other side of it will not be rendered.
     
  3. football928

    football928

    Joined:
    Sep 24, 2015
    Posts:
    17
    The actual planes or the objects that need occlusion?
     
  4. football928

    football928

    Joined:
    Sep 24, 2015
    Posts:
    17
    Oh I understand now I didn’t realize it was a gameobject
     
  5. mlnczk

    mlnczk

    Joined:
    May 12, 2017
    Posts:
    10
    And? Did you get it? Im trying to make my virtual walls hide between real objects but can't get it. I only found occlusionPlanePrefab. And material but it doesn't seem to work. I tried OcclusionArea to be places where my wall is. Also making object static but you can't bake them in real time while running application, any help please?
     
  6. football928

    football928

    Joined:
    Sep 24, 2015
    Posts:
    17
    On the script that places debug planes onto surfaces you change the debug plane to the occlusion plane prefab.
     
  7. mlnczk

    mlnczk

    Joined:
    May 12, 2017
    Posts:
    10
    And thats it? Now i will be able to put it behind real world objects? Nothing about setting some occlusion culling, camera settings and stuff? You mean changing the blue box generated on walls into the occlusion one? Will check in a moment
     
  8. football928

    football928

    Joined:
    Sep 24, 2015
    Posts:
    17
    Yep the kinda annoying thing is you can’t see where it picks up a surface it’s invisible. Maybe make a button to change all surfaces to debug planes and vice versa.
     
  9. mlnczk

    mlnczk

    Joined:
    May 12, 2017
    Posts:
    10
    Well now it just created big pink box as you said then i place on it my own virtual object and still it goes front all of real objects. Chairs, sofas, tv's everything is in front and no occlusion there is. Am i missing something?
     
  10. football928

    football928

    Joined:
    Sep 24, 2015
    Posts:
    17
    On your “Unity AR Generate Plane” script change the Plane Prefab to occlusionPlanePrefab. Not on the object just in the script.... now if you find a table and let it find a surface on the floor under the table then put your object on that surface so that it’s under the table. Then find a surface on top of the table. Now when you look down at the object through the table it should disappear.