Skip to content

NoCoderRandom/fortranWormhole

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hyperspace Tunnel Demo

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.

Hyperspace Tunnel Demo

Watch the full 30-second demo (MKV)

Build

Requirements

  • 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

Controls

Key Action
ESC Quit
SPACE Pause / Resume
R Restart timeline from zero
1-4 Switch color palette

What You're Seeing

A 30-second demo in five acts:

  1. Entry (0-4s) — Camera accelerates, tunnel materializes, cool blue palette
  2. Acceleration (4-12s) — Speed ramps, streaks intensify, first color shift
  3. Turbulence (12-22s) — Aggressive banks, hot palette, distortion peaks
  4. Breakthrough (22-27s) — Everything maxes out, bloom whiteout
  5. Exit (27-30s) — Tunnel dissolves, fade to black

Then loops.

Architecture

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

Algorithms

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

Shader Hot-Reload

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.

Performance

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

Recording

Record the 30-second demo to video and GIF:

bash record.sh

This 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.

Technical Details

See METHODS.md for a detailed breakdown of all algorithms, rendering techniques, and Fortran 2018 features used.

License

Public domain. Use however you like.

About

Cinematic hyperspace tunnel demo — Fortran 2018 + OpenGL 3.3, real-time rendering with simplex noise, bloom, particles, and ACES tonemapping

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors