- Home /
How does Occlusion Culling work with a Occlusion Portal on a door between two areas?
I'm trying to do a rather simple thing, close off two areas from one another with a door that is bound to a Trigger which opens it when getting close so I can save some draw calls.
The Trigger on the ground calls an animation "Open Door" (which opens the door) while the player collides with it and "Close Door" when he gets out of it.
Closed Door: 
Unfortunately the Occlusion Bake takes place while the door is closed and I have no idea how exactly Occlusion Portals work and can't find a guide anywhere.
What I want to do is make Unity show the room on the other side of the door when I step on the trigger and the door starts opening, not only when I step into the next room, at the moment it looks like this when opening the door and the rest of the room starts loading after I've stepped through:

Same with the other way around, nothing loads till I step through:

Answer by Dex7er · Aug 04, 2014 at 03:51 PM
I had managed to find out how this seems to work by the way by not turning the doors into Occluders and putting a cube somewhat larger than the doors right behind them with the Box Collider and Mesh Renderer disabled, but an "Occlusion Portal" added to it as a Component. (Default being "Open" not ticked)
In my Door Trigger Script I added:
public Animator DoorAnim;
public OcclusionPortal OccluBox;
void OnTriggerEnter (Collider obj){
DoorAnim.SetBool ("Open", true);
OccluBox.open = true;
}
void OnTriggerExit (Collider obj){
DoorAnim.SetBool ("Open", false);
OccluBox.open = false;
}
Bound them to the right GameObjects and this worked, but not exactly to my satisfaction since upon exiting the Trigger area the Occlusion Portal would close and things would start disappearing on the other side, so I added:
void OpenOcclusionPortal() {
OccluBox.open = true;
}
void CloseOcclusionPortal() {
OccluBox.open = false;
}
to the Beginning of my DoorOpenAnimation and the End of my DoorCloseAnimation as Event functions.
It might seem trivial, but since it doesn't seem to be explained anywhere how it works I thought this might help someone. 
Interesting. I was under the impression that the "open" boolean value only meant it was exposed to scripting, not literally whether or not it was actively occluding at the time (similar to Source engine Area Portals). Thats what I was HOPING they do, and now I must try this. I'm surprised there's not more documentation in Unity for such a useful optimization tool...
Your answer
Follow this Question
Related Questions
Occlusion Portal: Invalid Portal index 1 Answer
How do Occlusion Portals work in Unity 4.3 1 Answer
How to pick up battery to open door? 2 Answers
Calculating Door Hinge Pivots 2 Answers
Script for a door that requires (9 papers) to open 0 Answers