Game Development Community

What exactly is a portal?

by Lee Latham · in Torque Game Engine · 05/12/2007 (11:55 pm) · 9 replies

I hate to ask a "stupid" question, but everyone talks about them and everyone else but me knows what it is. What is it? How does it work? When do you want to use them?

#1
05/13/2007 (1:04 am)
Put simply, a portal is a device used to determine visibility. It is a performance optimization that helps developers only render what's needed rather than rendering the entire scene. This is of extreme importance in situations where parts of the scene are not in view. Why render something if it's not visible to the player.

Portals are used with interior objects in Torque. Think of it as a boundary that encompasses the interior and lets the engine know not to render anything outside that boundary. Useful for situations where the player enters a structure from an outdoor environment and it is no longer necessary to render the outdoor environment, because the player is indoors and can't see outdoors anyhow.

Portals are also useful as graphical effects. If you've played Prey you will know exactly what I'm talking about. Portals can also be used to teleport the player to different locations. This doesn't really apply to Torque as it has a very limited and simple portal system.

Torque also doesn't have occlusion culling which is typically used in combination with a decent portal system to further improve visibility determination. In Torque, an object that is blocked by another object will still render. Actually, pretty much all interior objects will cause rendering overhead even if they're not in view.
#2
05/13/2007 (12:59 pm)
So, in the case where your player goes inside a building, you might make a portal brush that encompasses the whole interior? Or a door-shaped brush on a doorway?
#3
05/13/2007 (1:46 pm)
I wish portals had been named "windows" instead.
in TGE, i think "portal" is a bit misleading.

Lee -
the simplest case is a room with no windows.
since you're in a room with no windows, TGE knows that there's no way for you to see anything outside of the room, so it doesn't bother rendering it.

now say you put a window in the room.
since the engine now knows it's possible for you to see out of the window,
it would ordinarily have to go ahead and render everything outside the room, too.

this is where portals come in.

when you place a portal around the window,
you've told the engine that there's no way to see out of the room except thru this portal.

so instead of rendering everything that's outside the room,
the engine only renders exactly what's visible thru the portal.

for this reason, you want to make your portals as small as possible while still bracketing your window.
#4
05/13/2007 (11:47 pm)
So it defines an area that _does_ get rendered?
#5
05/14/2007 (12:46 am)
Anything that's in the same room (aka "zone") as you is rendered,
plus anything which is visible thru any portals in that zone.

a zone is defined by any completely enclosed space.

a room w/ no windows makes a zone.
a room w/ a window but no portal does not make a zone, because the window is a hole.
a room w/ a window which has a portal covering it is a zone again, because the portal seals the hole.
#6
05/14/2007 (11:30 am)
Ooooooookay. I've been wondering about zones as well.

It doesn't seem to me that it could be explained any better than that, thanks!

So let me ask you a question, in Torque terms. How do holes in interiors affect rendering? I mean, since we can bring in multiple interiors, hook them together, etc.
#7
05/14/2007 (11:55 am)
Ummm someone else might have a better take on that than i.

i'm not sure what you're referring to by hooking interiors together.

afaik, you can place interiors near each other (but not overlapping),
but there's no way to explicitely link them together.

in general holes in interiors (ie a doorway) will slow down rendering unless you plug them w/ a portal.
#8
05/14/2007 (1:05 pm)
I just meant it figuratively, how the mission editor lets you use multiple interiors. I think you've answered my question, though.
#9
05/14/2007 (2:32 pm)
Cheers!