Introduction
A version 6 formula is a Mandelbulb 3D formula file with .Version = 6. One hundred and
ninety of the 714 files examined have it (one hundred and twenty-three different files), and
they are mostly the dIFS formulas: MengerIFS, SphereIFS,
HeightMapIFS, TorusIFS, transformIFS and many more whose names
end in IFS. The program’s readme calls dIFS (distance iterated function system)
formulas a type of their own and says some of them need a processor with SSE2. 124 of the
version 6 files have .DEoption = 20 and 38 have .DEoption = 21; those
values are found in no other version.
Version 6 is also the version with the most options: 2Doubles (119 files),
3SingleAngles (75), 6SingleAngles (18), SingleAngle and
ADEscale (24 files) appear here far more than in the others.
The file is Windows text, lines ending in CR LF, and the code is 32-bit x86 written as
hexadecimal digits: x87 in some files, SSE2 in the 122 that have a .SSE2 line.
Layout
| Part | Starts with | Holds |
|---|---|---|
| Options | [OPTIONS] | One line for each setting or option. The first is .Version = 6. |
| Constants | [CONSTANTS] | Present in 109 of the 190 files: Double = … and INT64 = $7FFFFFFFFFFFFFFF lines, which the code addresses as data (SphereIFS has two such lines). |
| Code | [CODE] | The machine code as hexadecimal digits, 64 digits (32 bytes) to a line. |
| End | [END] | Ends the code. |
| Description | a blank line, then Description: | Free text to the end of the file, when there is any. |
Option lines
| Line | In version 6 files |
|---|---|
.Version = 6 | All 190. |
.DEoption = n | All 190: 20 in 124, 21 in 38, 6 in 18, 2 in 6, 11 in 2, -1 in 2. |
.SSE2 | 122 files: a flag with no value. The code in these uses SSE2 instructions. |
.ADEscale = x | 24 files: the scale of an analytic distance estimate. |
.DEscale, .SIpower, .RStop | 26, 22 and 26 files. |
.Double, .Integer, .Single | 179, 154 and 22 files. |
.2Doubles | 119 files: two doubles under one name, for example .2Doubles Scale = 2 (the file lists one default). |
.3SingleAngles, .6SingleAngles, .SingleAngle, .DoubleAngle | 75, 18, 8 and 4 files. |
.Boxscale, .DRecipro | 4 and 1 files. |
Machine code
Two styles are seen. The x87 files, such as transformIFS, start straight in
with fld qword ptr [edi - 0x58] (DD 47 A8) and read their option
values at negative offsets from esi and edi, and end with
C3 (ret). The SSE2 files, such as SphereIFS, start with
movupd xmm0, [esi - 0x78] (66 0F 10 46 88), use packed double
instructions (mulpd, addpd) and, in SphereIFS, also end with
C3. Neither has the
push ebp prologue of the earlier versions, and the registers are set by the program
before the call. Some version 6 files still end with C2 08 00. This is read off the
disassembly of the sample files.
A worked example
transformIFS.m3f is 487 bytes, with .DEoption = 21, eight option lines
and 128 bytes of x87 code.
00000000 5B 4F 50 54 49 4F 4E 53 5D 0D 0A 2E 56 65 72 73 [OPTIONS] .Vers
00000010 69 6F 6E 20 3D 20 36 0D 0A 2E 44 45 6F 70 74 69 ion = 6 .DEopti
00000020 6F 6E 20 3D 20 32 31 0D 0A 2E 44 6F 75 62 6C 65 on = 21 .Double
00000030 20 41 64 64 20 58 20 3D 20 30 0D 0A 2E 44 6F 75 Add X = 0 .Dou
000000C0 6C 65 20 53 63 61 6C 65 20 3D 20 31 0D 0A 5B 43 le Scale = 1 [C
000000D0 4F 44 45 5D 0D 0A 44 44 34 37 41 38 44 44 34 36 39 38 ODE] DD47A8DD4698
transformIFS.m3f: the first option lines, the last option line, and the start of the code at offset 0xD6 (the rows between are more option lines)The options are Add X, Add Y, Add Z (doubles),
3SingleAngles Rotation, Integer Abs X, Abs Y, Abs Z
and Double Scale. The code is DD 47 A8 DD 46 98 D8 C9 DC 47 E0 …:
fld [edi-0x58], fld [esi-0x68], fmul st, st(1),
fadd [edi-0x20] and so on, and it ends DD D8 C3
(fstp st(0); ret).
Quirks
- A byte is never split across two hex lines; the last hex line is shorter.
- An
INT64constant is written with a dollar sign and hexadecimal digits; the explorer shows it as a number too. - An option kind such as
2Doubleshas one line and one default. - Text in the description may use Windows-1252 characters.
Not described
What this page and the explorer leave out or only infer for version 6 files.
- Reference: what version 6 changes from version 5 is not known; that these are dIFS formulas follows from
.DEoption20 and 21, and only 20 (and the range 20 to 22) has a meaning in the source. The values 6, 2 and 11 seen here are not described. - Reference: how the SSE2 code receives its data (which registers hold what) and what the
INT64constants are used for are not described; the two styles of code are told from a few examined files. - Viewer: the machine code is a linear disassembly (no jump following, no data/code separation, constants not shown beside the code); options, including the 2Doubles kind, are not linked to the code that reads them.
Variants
- Version 2 – the commonest: x87 code with a push ebp prologue, many add-ons
- Version 3 – twelve files, among them David Makin’s formulas, with SSE2 and SSE3 flags
- Version 4 – twenty-eight files, the reciprocal add-ons and Amazing Box variants
- Version 5 – sixty-one files, mostly four-dimensional formulas
- Version 6 – one hundred and ninety files, mostly the dIFS formulas
- Version 8 – six files, the newest number seen
Links
Software
- Mandelbulb 3D – the Windows program that loads these formulas (Windows)
Reference
- M3P file format – the parameter files that name the formulas in use