Game Development Community

Portals: How they work?

by Chris "DiGi" Timberlake · in Torque Game Engine · 10/07/2005 (9:53 am) · 5 replies

I'm interested in knowing how portals work. I hear it stops rendering the terrain and such but when you look out windows and such you can see out of it? How does it not render it? But you see it?

#1
10/07/2005 (10:35 am)
Build a debug build, go inside a portalized interior, and hit F9. Should be very instructive of what's going on.
#2
10/07/2005 (11:14 am)
@Ben, i'm sorry, i don't see? I get wireframe then it shows the portal? But whats the portal do take a picture of what the portal can see and project it to the interior? Or what?
#3
10/07/2005 (11:59 am)
If an object resides outside of a visible portal, it will not be rendered. Think of a portal as an "area which the engine will bother to render things"
Check This out.

Edit: Put down wrong url *doh*
#4
10/07/2005 (2:01 pm)
But then how do you see it when you look through the portal?
#5
10/07/2005 (2:43 pm)
Interiors are grouped into zones. When you create the interior, you help define these zones by making walls and portals. When you're in the game, the render engine only renders what's in the current zone. I think you've got that much so far.

Then, if a portal is in your viewport, it renders the zone on the other side of the portal, but instead of rendering it to your screen it creates a texture out of it and places it on the portal, then it renders the portal.

This limits the number of objects that have to be rendered which results in an increased frame rate.

You may be asking yourself "How does that limit it? It still has to render both zones." The answer is pretty simple... first, the portal is only rendered if it's in view, so it's not always rendered. Second, if your interior consists of multiple zones, then it's possible that the render engine might have to render two or three zones (depending on how many portals are in view), but it can completely ignore the other zones. It also means that if you're not viewing a portal that's between your current zone and outdoors then it doesn't have to render anything outside, which could be significant savings. Just think of "outside" as another zone.

You can think of zones as rooms to make things simpler. It doesn't necessarily have to be set up that way, and as you get more experience in creating interiors and working with BSP's and zones you'll begin to understand how you can split things up into zones in ways that will improve frame rate.

I hope that helps a little.