The Fractal Engine
The Oorxx flying above the planet
|
When the Oorxx flies above the planet, the terrain is computed in realtime. Some games on 8 bits systems have a similar wireframe fractal engine: Rescue on Fractalus, Koronis Rift, The Eidolon.
The procedural terrain generator uses 1D fractional brownian motion (fBm) with random mid-point displacement. Up to 10 curves are displayed on screen.
When a new curve appears at the horizon, 7 vertices are computed. Then mid-point displacement with fBm are applied to thes 7 initial points. This results in a discrete curve of 512 samples.
The random number generator and the fBm Hurst parameter H are adapted according to the current terrain type (flat, canyon...). This gives very different visual landscapes (plains, moutains, desert...).
No more fractal computation is done on the discrete curve. When a curve is drawn, only 256 of the 512 samples are used (according to the position of the Oorxx).
The view is 256 pixels wide, so if the visible part of the curve is larger than the 256 samples, the curve will be drawn zoomed with pixels linearly interpolated between the samples. Otherwise the curve will be drawn shrinked without any interpolation and using only some of the 256 samples.
The raytraced fractal landscape is computed from these 10 curves.
A raytraced fractal landscape
|
For each pair of the 10 curves (1-2, 2-3, ..., 9-10), 50 curves are computed in between using random interpolations. Then the raytracer colorizes each strip, applying shadow when needed:
Starting point of the raytracer
|
Intermediate result: 50 interpolated random curves between each of the 10 curves
|
Final result of the raytraced fractal landscape
|
The above screenshots have been made with the Fractal Viewer of my reverse engineered work of the Atari ST version.
The next logical step has been to adapt the viewer to use the raytracer in real-time during the flight as you can see in the following video.
Because the raytracer computes the intermediate curves every frame and the 10 curves move at different speed horizontally to fake a depth perception, you will see some glitches when moving left or right (the points of the curve pair are shifted, giving different starting and ending points for the interpolation).
2 videos showing the Fractal Viewer in action, using the 3 different rendering methods (original, intermediate and raytraced):
You can download the Fractal Viewer and its C# source code here (it requires the Microsoft Framework .NET 3.5):
[07/03/2016] Fractal Viewer - v1.00.zip (source + binaries):
Instructions:
- Left mouse button while dragging the mouse to change the horizontal and vertical motion of the Oorxx.
- 'V' key to stop any horizontal and vertical motion.
- Right mouse button while dragging the mouse forward/backward to speed up/down the Oorxx.
- <Spacebar> to toggle between classic and raytracer mode.
- 'B' key to toggle wireframe while in raytracer mode.
The Digitized Speech
Captain Blood uses digitized speech through the whole game.
The game contains 17 samples. Some are words, others are sound effects:
- Words: space, vision, planet, galaxy, map, destroy, Oorxx, landing, teleport, desintegrate, activated, hyper, up, com
- Effects: engine (long), engine (first half), engine (second half)
Samples are played together to form sentences:
- Galaxy Map Activated
- Destroy Planet Activated
- Oorxx Landing Activated
- Desintegrate Activated
- Teleport Activated
- Vision Planet Activated
- Vision Space Activated
- Up Com Activated
- Vision Oorxx Activated
- Hyper Space Activated
The sound engine has 3 main features, it can:
- play a sample at a choosen frequency. A higher frequency gives a fast and high voice. A lower frequency gives a slow and low voice.
- start playing a sample at a specific memory location for a specific duration. All the samples are adjacent to each other in memory (forming 1 block), without additional data between them. They could be played from the first to the last in one go without any glitches.
- play a sample reversed (yes, from end to start, reversed!).
These 3 features are the core of the aliens digitized speech.
- Each alien race has its own voice frequency.
- Each symbol is made up of 2 syllables. Each syllable is defined by 2 values:
- a value indicating if the syllable is played reversed or not
- an index used to compute the start offset of the sample in the "contigous sample memory block" seen previously (offset = index * 1437). To give a reference point, the word Vision has a length of 3488 bytes.
Every syllables have the same memory length of 1024 bytes, but the frequency with which they are played makes them shorter or longer.
This is a very ingenious system, building a language on top of existing samples.