Skip to content

Recursive Portal

Doorways inside doorways spiral away into a glowing depth, falling in at a steady rate. Loops perfectly.

Background, V1 Effects3DSeamless loop, verified249 lines of codev1.0.0

In Science & maths, Light, glass & shine, Patterns & illusions

Next: Particle GalaxySurprise me

Recursive Portal preview
Starting live preview…
00:00:00:00 / 00:00:00:01

Live, running the real source at reduced resolution.

Your current settings go with it. Combine several clips and hand them over together from your sequence.

Effect controls

Presets

0.6
0.25

Turn per level, in radians; negative spirals the other way.

1
1

The preview runs the same code your AI receives. These settings travel with the hand-off.

Info

What it is

A doorway with a smaller copy of itself in its opening, and another in that, receding into an endless glowing depth. The whole picture falls in towards the middle at a steady rate, one copy of the doorway passing into the next every loop, and each level turns a little more than the one before, so the corridor spirals as it goes. Doorways can be arches, rectangles or circles. Choose the shape, the colours (ember, ocean, violet or mono), how much smaller each doorway is than the last, the twist per level, the frame thickness and the brightness.

Reuse it in your own idea

  • Fantasy transition: Ember arch.
  • Sci-fi: Ocean, round, strong twist.
  • Clean: Violet rectangle.

Which part is reusable

src/recursive-portal.js is the ingredient your AI reuses. demo.js is only the example scene around it, and uses the demo harness only for the demo.

Good to know

  • It is a flat self-similar picture, not a 3D corridor: there is no parallax.
  • Very high ratios (0.75 and above) draw many levels and are slower.

Technical details

Technical details
Implementation
Three.js 0.185.1 (WebGL) · ES module src/recursive-portal.js
Exports
  • createRecursivePortal({ shape?, palette?, ratio?, twist?, frame?, brightness? }) => { scene, camera, setSize(width, height), update(time, loopSeconds), dispose() }
  • createBloomPass(renderer, { width, height, glow?, exposure?, grain? }) => { render(scene, camera, output?), dispose() }
  • PALETTES: { ember, ocean, violet, mono }
Dependencies (exact)
  • three@0.185.1 (source) — Renderer and a full-screen shader material.
  • apw-runtime@1.0.0 (demo) — Demo harness.
How it fits a scene

Coordinates: Screen-centred, ±1 vertically; every doorway is centred on the origin; level n has scale ratio^n and turns n × twist.

Lighting: Self-lit: walls shade towards the frame, frames are bevelled, and a glow sits at the far end; the bloom adds to it.

Timing: update(time, loopSeconds) sets the loop phase; frames render in any order.

Output
1080×1080, 30 fps, 10 s · procedural (computed from the frame number) · seamless loop — The picture is the same after one step of shrinking by the ratio and turning by the twist; over the loop it shrinks and turns by exactly one step, and the number of levels is set from the ratio so the same set of levels is always drawn, so the last frame meets the first.
Tested
Rendered 300 frames on 2026-10-06 in Chrome 154.0.8037.97 headless on Linux 7.0.0-38-generic (x64), Node 22.14.0 (WebGL 2 via SwiftShader (software)). Same frame twice from fresh pages: identical. Loop: Frame 0 vs end state (progress 1): mean |Δ| 0.0000, max |Δ| 0 of 255.
Performance
One full-screen fragment shader with up to 33 levels per pixel (13 at the default ratio), plus the bloom: a couple of milliseconds a frame at 1080² on an integrated Intel GPU. Software WebGL renders in about two seconds a frame.
Export a video yourself
Download the source, then in the folder: npm install npm run render -- recursive-portal/1.0.0 --out my-video.mp4Needs Node 18+, ffmpeg and Chrome/Chromium. Add --params my-settings.json (from Copy settings) for your own settings.
Version
1.0.0 · sha256:3bc799e0ae1c6d24…
Files
License
MIT. Copyright (c) 2026 AI Pixel Wizard. Released under the MIT License. See LICENSE in this folder. License details
Provenance
Adapted from the owner's threejs-sketches/abstract-artistic/recursive-portal (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original shader: a Droste-style self-similar corridor whose colour depends only on scale, falling in by exactly one step per loop, on an exact loop.
BinMore like this

String Art

Background3DSeamless loop12 seconds