A cinematic sci-fi hyperspace tunnel rendered in real-time using Fortran 2018 and OpenGL 3.3+.
"Wait, that's Fortran?"
Yes. Modern Fortran with iso_c_binding, clean module architecture, and direct OpenGL calls — no game engine, no external scene graph.
Watch the full 30-second demo (MKV)
- gfortran 13+ or nvfortran (NVIDIA HPC SDK)
- GLFW 3 development headers (
libglfw3-dev) - OpenGL (
libgl-dev)
# Ubuntu/Debian
sudo apt install gfortran libglfw3-dev libgl-dev
# Build
bash build.sh
# Run
bash run.sh| Key | Action |
|---|---|
| ESC | Quit |
| SPACE | Pause / Resume |
| R | Restart timeline from zero |
| 1-4 | Switch color palette |
A 30-second demo in five acts:
- Entry (0-4s) — Camera accelerates, tunnel materializes, cool blue palette
- Acceleration (4-12s) — Speed ramps, streaks intensify, first color shift
- Turbulence (12-22s) — Aggressive banks, hot palette, distortion peaks
- Breakthrough (22-27s) — Everything maxes out, bloom whiteout
- Exit (27-30s) — Tunnel dissolves, fade to black
Then loops.
src/
gl_constants.f90 OpenGL/GLFW named constants
gl_bindings.f90 iso_c_binding interfaces (~140 GL/GLFW functions)
math_utils.f90 Vec3, mat4, Catmull-Rom splines, smoothstep
shader_utils.f90 GLSL load/compile/link, uniform helpers, hot-reload
camera.f90 Spline path-following, roll, shake, FOV pumping
tunnel.f90 Centerline generation, parallel-transport tube mesh
particles.f90 12K streak particle ring-buffer, CPU update, GPU draw
palette.f90 4 hand-crafted color ramps, HSV<->RGB
timeline.f90 Keyframe system driving all visual parameters
postfx.f90 HDR FBO, bloom pyramid, final composite pass
main.f90 Window, input, main loop, orchestration
| Component | Algorithm |
|---|---|
| Tunnel path | Catmull-Rom spline through Lissajous-sum control points |
| Tube geometry | Parallel-transport frames (stable, no Frenet twist) |
| Wall energy | Simplex noise FBM + domain-warped arcs + hex grid overlay |
| Particles | Ring-buffer pool, GL_LINES with velocity-stretched tails |
| Color | 1D gradient LUTs sampled by depth + time, palette blending |
| Bloom | Bright pass → 3-level downsample pyramid → separable Gaussian → combine |
| Post-FX | Chromatic aberration, radial motion blur, vignette, film grain |
| Tonemap | ACES filmic (Narkowicz fit) |
| Timeline | Sorted keyframe tracks with smoothstep interpolation |
Edit any .frag or .vert file while the demo runs — changes are detected and reloaded within ~0.5 seconds. Failed compiles keep the old shader.
Target: 1440p @ 120 fps on RTX 3070 (8 GB VRAM, ~8 ms frame budget).
- Tunnel mesh: 200 segments × 48 radial = 9,600 quads — trivial
- Particles: 12K lines, CPU update + GPU upload — <1 ms
- Post-FX: 3-level bloom pyramid + composite — ~3 ms
- Total VRAM: <100 MB
Record the 30-second demo to video and GIF:
bash record.shThis renders all 900 frames at 1280x720, then encodes:
- MKV (x265, ~9 MB) — high quality, small file
- MP4 (x264, ~9 MB) — broad compatibility
- GIF (12s preview, ~13 MB)
Requires ffmpeg with libx265 and libx264 support.
See METHODS.md for a detailed breakdown of all algorithms, rendering techniques, and Fortran 2018 features used.
Public domain. Use however you like.
