RED Portals and Rooms: Difference between revisions

From Red Faction Wiki
m (Goober moved page RED Portals to RED Rooms and Portals)
(No difference)

Revision as of 21:19, 15 November 2020

Template:RF1Editing

Portal Rendering Basics

Red Faction uses portal rendering to determine what geometry and objects will be visible at any given time and therefore avoid instances where level assets that can't be seen by the player are still being rendered. By determining which geometry and objects are not currently visible, and not rendering those assets, significant performance improvements are achieved.

As a concept, this approach involves separating levels into zones/sectors (referred to as rooms in Red Faction), which are connected to one another by small openings that the engine has been instructed to consider as portals. When the engine determines that a room behind a portal needs to be rendered (based on the player's current camera position and view direction), only the parts of that room that are visible through the portal are rendered, rather than the entire space. As a general practice, portals should be configured in any confined areas (doors, tunnels, windows, etc.) that connect two otherwise separate areas of a level. The use of portals in this way greatly simplifies the engine's task of determining visible areas and objects from any given point of view.

At a technical level, portals allow the engine to use each portal as a viewing frustrum for the area behind the portal.

Visualization

To better understand how portal rendering works in Red Faction, you can use several debug options in the level editor (RED) and the game client itself to visualize both rooms and portals.

Useful options for visualizing portal rendering concepts in RED's view menu:

  • Show Rooms in Different Colors
  • Show Everything See-through
  • Draw Non-see-thru Portal Faces

The same options are accessible via console commands in the RF game client (Dash Faction 1.5.0+):

  • debug room
  • debug trans
  • debug portal

Rooms

Every Red Faction level is separated into rooms - even a 4x4x4 hollow cube map will have 1 room. Adjacent rooms are joined together with portals, and nonadjacent rooms are separated by world geometry. You can see an illustration of this concept below - a portal is separating room 1 from room 2, while solid world geometry is separating room 2 from room 3.

Portalrooms1.png

If the engine determines that a room is visible to the player, and that visibility is through a portal, only the geometry and objects within that room that are visible through that portal are rendered.

In addition, room definition also determines the boundaries of Room Effects, EAX Effects, and airlocks.

Door Rooms

Any room that contains a gold keyframe object with the Is Door flag set is considered a Door Room. Door Rooms have the status "Blocked" whenever the door mover is closed. When looking through the Door Room into an adjacent room, the adjacent room will only be rendered if the Door Room is not currently "Blocked". The theory behind this concept makes a lot of sense - adjacent rooms will not be visible when the door is closed (since the door is blocking visibility), so they don't need to be rendered. In practice, this can cause visibility issues if the boundaries of the Door Room are not tightly constrained to just the door/doorframe by the level designer. The images below illustrate this concept. In each, the camera is in Room 1.

Bad Design

In the diagram below, the door is not contained within a small room dedicated to just the door/doorframe. As a result, the entirety of Room 2 is the Door Room.

Doorrooms bad.png

  • Bad Design - Door Open
    • Room 1 contains the camera, so is rendered.
    • Room 2 (the Door Room) is visible through a portal, so all geometry in Room 2 visible through that portal is rendered.
    • Room 3 is visible through two portals, so all geometry in Room 3 visible through those portals is rendered.
    • The door mover is opened, so the Door Room (Room 2) is not blocked. Because of this, Room 4 is visible through two portals, so all geometry in Room 4 visible through those portals is rendered.
  • Bad Design - Door Closed
    • Room 1 contains the camera, so is rendered.
    • Room 2 (the Door Room) is visible through a portal, so all geometry in Room 2 visible through that portal is rendered.
    • The door mover is closed, so the Door Room (Room 2) is blocked. Because of this, both Room 4 and Room 3 are not rendered as they are both adjacent rooms to the blocked Door Room (Room 2).

Good Design

In the diagram below, the door is contained by use of portals to a small room dedicated to just the door/doorframe. As a result, a new room (Room 5) is created, and is the Door Room.

Doorrooms good.png

  • Good Design - Door Open
    • Room 1 contains the camera, so is rendered.
    • Room 2 is visible through a portal, so all geometry in Room 2 visible through that portal is rendered.
    • Room 3 is visible through two portals, so all geometry in Room 3 visible through those portals is rendered.
    • Room 5 (the Door Room) is visible through two portals, so all geometry in Room 5 visible through those portals is rendered.
    • The door mover is opened, so the Door Room (Room 5) is not blocked. Because of this, Room 4 is visible through three portals, so all geometry in Room 4 visible through those portals is rendered.
  • Good Design - Door Closed
    • Room 1 contains the camera, so is rendered.
    • Room 2 is visible through a portal, so all geometry in Room 2 visible through that portal is rendered.
    • Room 3 is visible through two portals, so all geometry in Room 3 visible through those portals is rendered.
    • Room 5 (the Door Room) is visible through two portals, so all geometry in Room 5 visible through those portals is rendered.
    • The door mover is closed, so the Door Room (Room 5) is blocked. Because of this, Room 4 is not rendered as it is an adjacent room to the blocked Door Room (Room 4).

Portals

Air Brush Portals

Solid Brush Portals