Working -- prior to mushroom cloud addition.

This commit is contained in:
The Dust Council 2026-06-01 16:10:04 -07:00
commit 5defe65535
5 changed files with 1147 additions and 0 deletions

126
README.md Normal file
View file

@ -0,0 +1,126 @@
# vectordesert
An infinite wire-mesh vector desert flythrough, written in C with OpenGL
(GLFW). A vast, mostly-flat wireframe plain rolls past, interrupted now and
then by vector mountain ranges, with saguaro cacti scattered across both.
The terrain is built from **square wire-mesh frames**; the saguaros are
ribbed wire-mesh tubes shaped to resemble real cacti (tapered, dome-tipped
trunks with arms that curve out and sweep upward).
## Build
Requires a C compiler, GLFW 3, and OpenGL.
Debian/Ubuntu:
```
sudo apt install build-essential libglfw3-dev
```
Fedora:
```
sudo dnf install glfw-devel
```
macOS (Homebrew):
```
brew install glfw
```
Then:
```
make
```
## Run
```
./vectordesert # windowed
./vectordesert --fullscreen # full screen
```
### Command-line settings
```
--terrain-hue=0..1 hue of the terrain mesh (default 0.075)
--mountain-freq=0.2..4 how often the plain is interrupted by a range
(low = rare; high = frequent) (default 1.0)
--mountain-rough=0..1 flat-topped mesas .. jagged peaks (default 0.5)
--mountain-min-height=0..80 height of a range's low parts (default 6)
--mountain-max-height=0..80 height of the tallest peaks (default 26)
--cactus-freq=0..1 chance of a cactus per cell (default 0.35)
--cactus-size-var=0..0.95 random cactus size spread (default 0.55)
--cactus-min-size=1..30 smallest cactus height (default 4)
--cactus-max-size=1..30 largest cactus height (default 12)
--cactus-hue=0..1 hue of the cacti (default 0.33)
--max-arms=0..12 arms on the largest cacti (default 5)
```
Example:
```
./vectordesert --fullscreen --terrain-hue=0.55 --mountain-freq=1.8 \
--cactus-hue=0.30 --cactus-freq=0.5 --max-arms=8
```
### Camera
| keys | does |
|------|------|
| `W` / `S` | throttle: accelerate / decelerate forward speed (holds when released; `S` past zero goes into reverse) |
| `A` / `D` | strafe left / right |
| `Page Up` / `Page Down` | raise / lower camera altitude |
| `←` / `→` | pan view left / right |
| `↑` / `↓` | pan view up / down |
| `[` / `]` | decrease / increase rendering distance |
Velocity is held in world space, so panning the view with the arrow keys
only changes where you look — it does not change the direction you are
travelling. To steer, turn and then apply throttle.
The terrain is generated around the camera and cached — rebuilt only as you
travel out of the cached region — so the plain extends infinitely in every
direction. Rendering distance (`[` / `]`) ranges from 40 up to 960 units.
### Live setting controls
| keys | adjusts |
|------|---------|
| `1` / `2` | terrain hue |
| `3` / `4` | mountain range frequency |
| `,` / `.` | mountain roughness (flat mesas ↔ jagged peaks) |
| `T` / `Y` | minimum mountain range height |
| `U` / `I` | maximum mountain range height |
| `5` / `6` | cactus frequency |
| `7` / `8` | cactus size variation |
| `J` / `K` | minimum cactus size |
| `N` / `M` | maximum cactus size |
| `9` / `0` | cactus hue |
| `-` / `=` | maximum cactus arms |
| `F` | toggle fullscreen |
| `ESC` | quit |
Current settings are printed to the terminal as you change them, and an
on-screen heads-up display (drawn in the same vector style) lists every
setting next to the key(s) that change it. The HUD fades out after 10
seconds with no keypresses and snaps back as soon as you press a key.
## Notes
- **Arms scale with size:** the number of arms is derived from a cactus's
normalized size, so the smallest cacti always have the fewest arms (down
to a bare trunk) and the largest always reach `max-arms`.
- The world is generated procedurally from a hash-based value-noise height
field, so it is effectively infinite — the camera flies forever.
- Distance fog fades distant geometry into the dusk sky for depth.
## Performance
The renderer is built for throughput at large draw distances:
- All wireframe segments for a frame are collected into one vertex/colour
array and drawn with a single `glDrawArrays(GL_LINES)` per mesh, instead
of per-object immediate-mode `glBegin`/`glEnd`.
- Terrain and cactus meshes are **cached** and only rebuilt when a relevant
setting changes or the camera leaves the cached region; most frames do no
geometry work at all.
- Terrain uses a **cell budget** (level of detail): the grid spacing grows
with the rendering distance, so the cell count stays bounded as the radius
scales up.
- Each terrain vertex's height is computed once and shared by its edges (no
redundant noise evaluations).
- Cacti render out to the full rendering distance (like the terrain), but
drop ring facets and trunk segments with distance so far-off ones stay
cheap. The distance fade is done by **hardware fog** rather than the CPU.