Portal and PVS visibility culling
Partition an indoor level into cells joined by portals and either clip the view frustum through portals at runtime or look up a precomputed set of cells visible from the current one.
Also known as portal culling, potentially visible set, PVS
In the family Performance, LOD & compression, occlusion culling
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | Rooms/portals were removed in 4.0; use OccluderInstance3D and VisibleOnScreenNotifier3D. |
| Unity | Built in | Window > Rendering > Occlusion Culling (Umbra PVS bake) with OcclusionArea and OcclusionPortal components docs |
| Unreal 5.7 | Built in | Place a Precomputed Visibility Volume in the level docs |
| Blender 5.2 | Not applicable | DCC tool; no runtime visibility culling. |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The level is divided into convex cells (rooms) connected by portals, the openings between them. Two flavors exist.
Portal rendering walks from the camera's cell: for each portal in view, the frustum is narrowed to the portal's screen-space polygon and recursion continues into the neighbor cell, drawing only what falls inside the narrowed frustum. Mirrors and distant windows can reuse the same traversal.
A potentially visible set (PVS) moves that work offline: for each cell, a conservative computation (portal sight-line tests or sampling) produces a bitset of cells that could be seen from anywhere inside it. At runtime, find the camera's cell, read its bitset, draw those cells' contents, then apply normal frustum culling.
Dynamic objects are tagged by the cells they overlap and are drawn if any of those cells is visible.
When to choose it
Reach for it when
- indoor level renders rooms the player cannot see
- precomputed visibility for corridors and rooms
- walls hide most geometry but everything is drawn
- need zero runtime cost occlusion culling
- culling for building interiors with doors
Choose it for indoor, corridor or building-interior scenes with clear cell structure and static architecture: runtime cost is nearly zero with a PVS, and it never has GPU latency. Prefer Masked software occlusion culling or Hierarchical-Z occlusion culling for open or dynamic scenes where occluders cannot be authored as cells. Combine with GPU-driven rendering to cull per-cell batches.
Field marks
- Conservative PVS over-includes cells, so large open rooms see little gain
- Misplaced or missing portals cause objects to vanish when they should be visible
- Doors and moving walls need runtime portal open/close handling or the PVS goes stale
- Bake time and memory for PVS bitsets grow quickly with cell count
- Poor fit to outdoor scenes where there are no natural cells
Presets
Portal & PVS visibility culling — recursive frustum clipping through architectural doorways
{
"P_FOV_ANGLE": 0.78,
"P_PORTAL_WIDTH": 0.14,
"P_CAM_SWEEP": 1,
"P_SHOW_FRUSTUM": 1
}Show GLSL (173 lines)
const float P_FOV_ANGLE = 0.78; // P Camera FOV [0.35, 1.35, 0.03]
const float P_PORTAL_WIDTH = 0.14; // P Portal Width [0.06, 0.26, 0.01]
const float P_CAM_SWEEP = 1.0; // P Sweep Speed [0.0, 2.5, 0.05]
const float P_SHOW_FRUSTUM = 1.0; // P Frustum Beams [0.0, 1.5, 0.05]
float sdSegment(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a, ba = b - a;
float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
return length(pa - ba * h);
}
float wrapPi(float a) {
return mod(a + 3.14159265, 6.2831853) - 3.14159265;
}
// Clip angular interval [aMin, aMax] to the sightline span of a portal segment (pA -> pB) seen from cam
vec2 clipInterval(vec2 iv, vec2 cam, vec2 pA, vec2 pB, float refAng) {
float a1 = wrapPi(atan(pA.y - cam.y, pA.x - cam.x) - refAng);
float a2 = wrapPi(atan(pB.y - cam.y, pB.x - cam.x) - refAng);
float lo = min(a1, a2);
float hi = max(a1, a2);
return vec2(max(iv.x, lo), min(iv.y, hi));
}
bool inWedge(vec2 p, vec2 cam, vec2 iv, float refAng) {
if (iv.x >= iv.y) return false;
float a = wrapPi(atan(p.y - cam.y, p.x - cam.x) - refAng);
return a >= iv.x && a <= iv.y;
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float px = 1.0 / max(iResolution.y, 1.0);
float tAnim = iTime * max(P_CAM_SWEEP, 0.0);
float halfFov = clamp(P_FOV_ANGLE, 0.3, 1.45) * 0.5;
float pHalf = clamp(P_PORTAL_WIDTH, 0.04, 0.28) * 0.5;
float beamVis = clamp(P_SHOW_FRUSTUM, 0.0, 1.6);
// Architectural floorplan: 3 vertical zones (Left Room x<-0.22, Central Hall [-0.22,0.22], Right Rooms x>0.22)
// Right side split horizontally at y = 0.0 into Upper-Right Room and Lower-Right Room
vec2 cam = vec2(-0.56 + 0.08 * cos(tAnim * 0.7), 0.16 * sin(tAnim * 0.55));
float camAng = 0.42 * sin(tAnim * 0.62);
// Portal 1: doorway from Left Room into Central Hall at x = -0.22, y = 0.04
vec2 p1A = vec2(-0.22, 0.04 - pHalf);
vec2 p1B = vec2(-0.22, 0.04 + pHalf);
// Portal 2: doorway from Central Hall into Upper-Right Room at x = 0.22, y = 0.22
vec2 p2A = vec2(0.22, 0.22 - pHalf);
vec2 p2B = vec2(0.22, 0.22 + pHalf);
// Portal 3: doorway from Central Hall into Lower-Right Room at x = 0.22, y = -0.22
vec2 p3A = vec2(0.22, -0.22 - pHalf);
vec2 p3B = vec2(0.22, -0.22 + pHalf);
// Recursive portal frustum clipping!
vec2 ivRoot = vec2(-halfFov, halfFov);
vec2 ivHall = clipInterval(ivRoot, cam, p1A, p1B, camAng);
vec2 ivUpRight = clipInterval(ivHall, cam, p2A, p2B, camAng);
vec2 ivLoRight = clipInterval(ivHall, cam, p3A, p3B, camAng);
// Determine which room the pixel belongs to (bounds: x in [-0.80, 0.80], y in [-0.44, 0.44])
bool inBuilding = abs(uv.x) < 0.80 && abs(uv.y) < 0.44;
int roomId = -1;
if (inBuilding) {
if (uv.x < -0.22) roomId = 0; // Starting Room
else if (uv.x < 0.22) roomId = 1; // Central Hall
else if (uv.y >= 0.0) roomId = 2; // Upper-Right Chamber
else roomId = 3; // Lower-Right Chamber
}
// Visibility classification per pixel
bool inRawFov = inWedge(uv, cam, ivRoot, camAng);
bool visPixel = false;
bool roomActive = false;
if (roomId == 0) {
roomActive = true;
visPixel = inRawFov;
} else if (roomId == 1) {
roomActive = ivHall.x < ivHall.y;
visPixel = inWedge(uv, cam, ivHall, camAng);
} else if (roomId == 2) {
roomActive = ivUpRight.x < ivUpRight.y;
visPixel = inWedge(uv, cam, ivUpRight, camAng);
} else if (roomId == 3) {
roomActive = ivLoRight.x < ivLoRight.y;
visPixel = inWedge(uv, cam, ivLoRight, camAng);
}
// Blueprint background
vec3 col = vec3(0.028, 0.036, 0.055);
vec2 g = abs(fract(uv * 14.0 - 0.5) - 0.5);
col += vec3(0.018, 0.028, 0.042) * smoothstep(0.035, 0.005, min(g.x, g.y));
if (inBuilding) {
float hatch = smoothstep(0.45, 0.85, sin((uv.x - uv.y) * 95.0));
vec3 culledFloor = vec3(0.055, 0.062, 0.088) + vec3(0.05, 0.02, 0.04) * hatch;
vec3 activeFloor = vec3(0.09, 0.14, 0.19);
col = roomActive ? activeFloor : culledFloor;
// Highlight frustum-culled area that WAS inside the naive camera cone but eliminated by Portal clipping!
if (inRawFov && !visPixel) {
col = mix(col, vec3(0.32, 0.08, 0.16), 0.45 * min(beamVis, 1.2));
}
// Highlight true portal-clipped visible region
if (visPixel) {
float falloff = exp(-length(uv - cam) * 0.7);
col += vec3(0.14, 0.62, 0.46) * (0.28 + 0.42 * falloff) * min(beamVis, 1.3);
}
// Place room prop markers (colored pillars/crates) that light up ONLY when their room survives PVS culling
vec2 props[4];
props[0] = vec2(-0.42, -0.26);
props[1] = vec2(0.00, 0.24);
props[2] = vec2(0.54, 0.24);
props[3] = vec2(0.54, -0.24);
for (int k = 0; k < 4; k++) {
float dp = length(uv - props[k]) - 0.042;
bool pVis = (k == 0 && inRawFov) || (k == 1 && ivHall.x < ivHall.y) || (k == 2 && ivUpRight.x < ivUpRight.y) || (k == 3 && ivLoRight.x < ivLoRight.y);
vec3 pCol = pVis ? vec3(0.98, 0.82, 0.28) : vec3(0.42, 0.18, 0.26);
col = mix(col, pCol, smoothstep(px * 2.0, -px * 1.5, dp));
}
}
// Draw solid walls (excluding portal gaps)
float dWall = 1e5;
dWall = min(dWall, sdSegment(uv, vec2(-0.80, -0.44), vec2(0.80, -0.44)));
dWall = min(dWall, sdSegment(uv, vec2(-0.80, 0.44), vec2(0.80, 0.44)));
dWall = min(dWall, sdSegment(uv, vec2(-0.80, -0.44), vec2(-0.80, 0.44)));
dWall = min(dWall, sdSegment(uv, vec2(0.80, -0.44), vec2(0.80, 0.44)));
// Wall 1 (with Portal 1 gap)
dWall = min(dWall, sdSegment(uv, vec2(-0.22, -0.44), p1A));
dWall = min(dWall, sdSegment(uv, p1B, vec2(-0.22, 0.44)));
// Wall 2 (with Portal 2 & Portal 3 gaps)
dWall = min(dWall, sdSegment(uv, vec2(0.22, -0.44), p3A));
dWall = min(dWall, sdSegment(uv, p3B, p2A));
dWall = min(dWall, sdSegment(uv, p2B, vec2(0.22, 0.44)));
// Horizontal divider between right rooms
dWall = min(dWall, sdSegment(uv, vec2(0.22, 0.0), vec2(0.80, 0.0)));
col = mix(col, vec3(0.76, 0.84, 0.94), smoothstep(0.014, 0.004, dWall));
// Draw glowing doorway portals
float dP1 = sdSegment(uv, p1A, p1B);
float dP2 = sdSegment(uv, p2A, p2B);
float dP3 = sdSegment(uv, p3A, p3B);
col = mix(col, (ivHall.x < ivHall.y) ? vec3(0.18, 0.98, 0.72) : vec3(0.35, 0.42, 0.55), smoothstep(0.012, 0.003, dP1));
col = mix(col, (ivUpRight.x < ivUpRight.y) ? vec3(0.98, 0.78, 0.22) : vec3(0.35, 0.42, 0.55), smoothstep(0.012, 0.003, dP2));
col = mix(col, (ivLoRight.x < ivLoRight.y) ? vec3(0.98, 0.78, 0.22) : vec3(0.35, 0.42, 0.55), smoothstep(0.012, 0.003, dP3));
// Draw clipped frustum edge sightlines from camera
if (beamVis > 0.01) {
vec2 dirL = vec2(cos(camAng + ivRoot.x), sin(camAng + ivRoot.x));
vec2 dirR = vec2(cos(camAng + ivRoot.y), sin(camAng + ivRoot.y));
float dFr = min(sdSegment(uv, cam, cam + dirL * 1.5), sdSegment(uv, cam, cam + dirR * 1.5));
col += vec3(0.45, 0.72, 1.0) * smoothstep(px * 3.5, px * 0.8, dFr) * 0.55 * min(beamVis, 1.2);
if (ivHall.x < ivHall.y) {
vec2 hL = vec2(cos(camAng + ivHall.x), sin(camAng + ivHall.x));
vec2 hR = vec2(cos(camAng + ivHall.y), sin(camAng + ivHall.y));
float dH = min(sdSegment(uv, cam, cam + hL * 1.4), sdSegment(uv, cam, cam + hR * 1.4));
col += vec3(0.22, 0.96, 0.72) * smoothstep(px * 3.5, px * 0.8, dH) * 0.75 * min(beamVis, 1.2);
}
}
// Camera beacon
col = mix(col, vec3(1.0, 0.96, 0.82), smoothstep(0.026, 0.010, length(uv - cam)));
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| portal-pvs-culling-live | Tesla T4 1920x1080 | 10.6× baseline (moderate) · 0.333 ms / 0.342 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| portal-pvs-culling-live | NVIDIA L4 1920x1080 | 9.80× baseline (moderate) · 0.155 ms / 0.166 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| portal-pvs-culling-live | NVIDIA A100-SXM4-40GB 1920x1080 | 6.50× baseline (moderate) · 0.187 ms / 0.207 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Shadow Volumes; cited by GPU hardware occlusion queries.
Crosses
- Lightmap Baking: The same cell partition used for the visibility bake can organize lightmap charts per room.
Sources
- primarySeth J. Teller, Carlo H. Séquin (1991). Visibility preprocessing for interactive walkthroughs. Proceedings of the 18th annual conference on Computer graphics and interactive techniques.Verified via crossref · 2026-11-29doi:10.1145/122718.122725
- secondaryDavid Luebke, Chris Georges (1995). Portals and mirrors. Proceedings of the 1995 symposium on Interactive 3D graphics - SI3D '95.Verified via crossref · 2026-11-29doi:10.1145/199404.199422