Look through the surface.
A pair of portals turns render targets, off-axis camera projection, coordinate-space reflection, and renderer-state restoration into a controllable scene instead of a black-box effect.
Preparing two portal render targets and an off-axis portal camera...
- renderer
- -
- targets
- -
- captures
- -
- camera
- -
- passes
- -
- calls
- -
- triangles
- -
- frame ms
- -
Each pass renders both portals. Higher pass counts deepen the visible recursion but multiply capture work.
renderer.setRenderTarget(target)render off-screenCameraUtils.frameCorners()off-axis projectionworldToLocal -> reflect -> localToWorldportal-space camerarenderer.getRenderTarget()restore caller statetarget.dispose()release color/depth resourcesThe portal surface is only a texture. The illusion comes from rendering the scene again from a transformed camera whose projection is framed by the destination portal corners.
Orbit around the room and watch the portal camera keep the destination surface framed without changing the main camera.
Derived from the official portal example, CameraUtils, and the current RenderTarget / WebGLRenderer docs.