Skip to content

Commit 9a7a54a

Browse files
committed
WIP: Write a Preset Authoring Guide
1 parent a0162e6 commit 9a7a54a

38 files changed

+1851
-42
lines changed

bun.lock

Lines changed: 85 additions & 40 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: Preset Authoring Guide
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Introduction
3+
description: A comprehensive guide to Milkdrop presets.
4+
---
5+
6+
## A Comprehensive Guide to Authoring Milkdrop Presets
7+
8+
This section contains all information required to create new and edit existing Milkdrop presets.
9+
10+
Starting with a general overview on the file format and general rendering process, the guide also covers each built-in
11+
effect, syntax and usage of the Milkdrop-specific expressions and making use of HLSL shaders to further improve the
12+
resulting visuals.
13+
14+
### Available Editors
15+
16+
The original Milkdrop plug-in for WinAmp<span>&reg;</span> has a built-in editor which allows editing all parameters
17+
and code blocks. While not being overly user-friendly, it is the editor which was used to create basically all presets
18+
available in the wild.
19+
20+
Recently, more community projects have started implementing their own, improved editors, including projectM. As of now,
21+
none of these editors are released publicly. Once they become available, we'll add links here.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Preset Files (.milk)
3+
description: An overview of the format of Milkdrop presets.
4+
---
5+
6+
## General File Syntax
7+
8+
Since Milkdrop has been around since the late 1990's, the choice for the file format was based on best practices in
9+
Windows development during that era. XML, JSON and other modern structural formats weren't a thing then, so the NullSoft
10+
developers decided to use readily-available functions in the Win32 API to save and load presets and thus chose the
11+
Windows INI file format.
12+
13+
A preset file consists of only a single INI section, `[preset00]`, which contains all parameters, expressions and shader
14+
code blocks. Presets since Milkdrop 2 also use a few additional keys in the global section to enable use of HLSL pixel
15+
shaders.
16+
17+
Each setting in the preset file follows the `key=value` scheme. If a key is present multiple times, the _first_ value
18+
found in the file is being used.
19+
20+
## Default Parameters
21+
22+
Many default preset parameters follow a certain syntax, determining the data type expected as the value:
23+
24+
- Keys starting with `b` are considered boolean values, e.g. `0` means false/off and any non-zero value is considered
25+
true/on.
26+
- Keys starting with `i` are parsed as integer values without decimals.
27+
- Keys starting with `f` are floating-point numbers.
28+
29+
The values of default parameters can be changed within expressions in most, but not all cases. For example, the `enabled`
30+
values of custom waves and shapes cannot be set in expressions, as well as the `shapecode_#_num_inst` value.
31+
32+
## Code Blocks
33+
34+
Milkdrop presets can contain expression code and HLSL shaders with more than a single line. Each code block has its own
35+
key prefix (e.g. `per_frame_`), followed by a 1-based line number without leading zeroes. A code block is read in by
36+
incrementing the line number by one each and then checking if the key exists. Once a key isn't found, the code block is
37+
considered finished. A maximum of 99999 lines per code block are allowed.
38+
39+
Shader code blocks (with the `warp_` and `comp_` prefixes) start with an additional `` ` `` after the `=`, which is
40+
discarded automatically when reading in the preset. Using the backtick is fully optional, e.g. shader code will parse
41+
properly without it and expression code will be parsed correctly if there is a backtick at the beginning of each line's
42+
value.
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: Rendering Process
3+
description: All built-in effects and their rendering order.
4+
---
5+
6+
## Preset Versions
7+
8+
Before listing all effects, it's important to know the differences between preset versions.
9+
10+
In general, presets are different between Milkdrop 1.x and Milkdrop 2.x. This is because Milkdrop 1 did not support
11+
using pixel shaders, they only supported a fixed set of effects which could be controlled using certain predefined
12+
parameters.
13+
14+
Milkdrop 2.0 introduced shader support and since Milkdrop 2.0.1, preset authors could choose to use different shader
15+
versions for both warp and composite shaders (or disable them individually).
16+
17+
As a rule of thumb, all Milkdrop 1 post-processing effects listed below will be disabled if a user-defined composite
18+
shader is enabled.
19+
20+
## Preset Loading
21+
22+
When loading a preset, all `init` expression code blocks will be executed _once_, in this order:
23+
24+
- `per_frame_init`
25+
- `wave_0_init`
26+
- `wave_1_init`
27+
- `wave_2_init`
28+
- `wave_3_init`
29+
- `shape_0_init`
30+
- `shape_1_init`
31+
- `shape_2_init`
32+
- `shape_3_init`
33+
34+
## Rendering Order
35+
36+
The following sections lists all Milkdrop built-in effects in the order they're being rendered. The rendering order is
37+
important to achieve certain effects.
38+
39+
Each effect is described in more detail in the [following chapter](effects).
40+
41+
### Frame Setup
42+
43+
This step doesn't render anything, but executes the `per_frame_` code block.
44+
45+
### Motion Vector Grid
46+
47+
Draws a grid of colored dots or lines on top of the previous frame's image. The lines represent the apparent motion (
48+
speed and direction) of the warp effect.
49+
50+
Not that this is the only effect which is drawn _before_ warping the image.
51+
52+
### Image Warp
53+
54+
A full-screen effect which allows to transform the previous frame's image in many different ways. This effect consists
55+
of multiple steps:
56+
57+
1. For each intersection in the user-defined warp mesh grid, the "per-vertex" or "per-pixel" expression code is
58+
executed.
59+
2. If the preset version is less than `200` or the warp pixel shader version less than `2`, a simple default warp shader
60+
will be used. This shader also applies the `decay` value by multiplying the resulting color with the set value.
61+
3. Otherwise, the warp shader contained in the preset will be executed and rendered. It may or may not use the warp grid
62+
U/V coordinates. The `decay` value will not be applied automatically.
63+
64+
### Custom Shapes
65+
66+
A preset may use up to 4 sets of custom shapes, each with 1 to 1024 instances. Shapes 1 to 4 are rendered in order and
67+
thus on top of each other.
68+
69+
Each shape instance can have a colored or textured interior, and also an optional colored border around it.
70+
71+
### Custom Waveforms
72+
73+
Custom waveforms, of which up to 4 can be used, render lines or dots and can use audio or spectrum data to animate the
74+
waveform.
75+
76+
The coordinates and color of each individual point which makes up the waveform can be scripted using expression code.
77+
This allows to draw arbitrary shapes.
78+
79+
### Default Waveform
80+
81+
A single waveform with eight predefined drawing modes. The mode, color, position and scaling of the waveform can be
82+
customized.
83+
84+
### Darken Center
85+
86+
A simple effect which draws a diamond-shaped area in the center of the screen which darkens pixels more the closer they
87+
are to the center.
88+
89+
### Image Borders
90+
91+
Two configurable borders around the whole screen, one inner and one outer border. Each can have individual color and
92+
width.
93+
94+
### Post-Processing / Composite Effect(s)
95+
96+
Before any post-processing effects are applied, the current preset image is stored and passed on to the next frame. This
97+
means any of the effects described in this section are only display to the viewer and the image will then be discarded.
98+
99+
If the preset version is at least `200` (Milkdrop 2.0) and a pixel shader version >= 2 is set for the composite shader,
100+
only the "Composite Shader" effect is drawn and the other effects below are skipped.
101+
102+
If no composite shader is enabled as stated above, the five "classic" post-processing filters are drawn if enabled
103+
individually.
104+
105+
#### Composite Shader
106+
107+
The composite shader can contain arbitrary HLSL code.
108+
109+
If the preset contains composite shader code, the shader is executed to draw the final image. none of the following
110+
effects will be applied in this case.
111+
112+
#### Video Echo
113+
114+
Renders a copy of the current preset image ofer the existing one. The image can be flipped on the X and Y axis and
115+
zoomed in or out. The opacity of the effect can also be specified from 0% (effect disabled) to 100% (only rendering the
116+
echo).
117+
118+
#### Brighten Image
119+
120+
Brightens the whole image using a square filter.
121+
122+
#### Darken Image
123+
124+
Darkens the whole image using a square filter.
125+
126+
#### Solarize
127+
128+
Emphasizes medium-bright colors of the image.
129+
130+
#### Gamma Adjustment
131+
132+
Applies a gamma filter, eventually multiple times, to adjust the overall image brightness.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: Built-In Effects
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Effects Reference
3+
description: A detailed description of all available built-in effects.
4+
---
5+
6+
This chapter contains a reference of all available visual effects. They are ordered in the same
7+
way [as effects are drawn](preset-rendering-process).
8+
9+
For each effect, available parameters are explained in detail, with screenshots to provide examples.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Motion-Vector Grid
3+
description: A configurable grid with dots or lines following the warp motion.
4+
---
5+
6+
![Motion Vectors Effect](/content/preset-guide/effect-motion-vectors.jpg){style="width: 50%;"}
7+
8+
The Motion Vector Grid is the very first effect being drawn, even before the [Warp effect](image-warp) is applied.
9+
10+
The effect draws a grid of lines (or dots, if length is set to minimum). The lines resemble the reverse-propagated
11+
motion vectors of the Warp effect as drawn in the _previous_ frame, pointing into the direction of movement, with the
12+
line length representing the movement speed.
13+
14+
## Default Settings
15+
16+
In the preset file, the following settings configure the default values for the Motion Vector Grid effect:
17+
18+
| .milk Setting Key | Type | Range | Description |
19+
|-------------------|-------|-------------|--------------------------------------------------------------------------|
20+
| nMotionVectorsX | INT | 0 .. 64 | The number of motion vectors in the X direction |
21+
| nMotionVectorsY | INT | 0 .. 48 | The number of motion vectors in the Y direction |
22+
| mv_dx | FLOAT | -1.0 .. 1.0 | Horizontal placement offset of the motion vectors |
23+
| mv_dy | FLOAT | -1.0 .. 1.0 | Vertical placement offset of the motion vectors |
24+
| mv_l | FLOAT | 0.0 .. 5.0 | The length of the motion vectors (0=dot/no trail, 1=normal, 2=double...) |
25+
| mv_r | FLOAT | 0.0 .. 1.0 | The red color value of the motion vector grid |
26+
| mv_g | FLOAT | 0.0 .. 1.0 | The green color value of the motion vector grid |
27+
| mv_b | FLOAT | 0.0 .. 1.0 | The blue color value of the motion vector grid |
28+
| mv_a | FLOAT | 0.0 .. 1.0 | The opacity of the motion vector grid |
29+
30+
## Expression Code Usage
31+
32+
All settings of the Motion Vector Grid can be manipulated using Milkdrop expression code using the variables described
33+
below in one of the following blocks:
34+
35+
- `per_frame_init_`
36+
- `per_frame_`
37+
38+
| .milk Setting Key | Expression Variable | Writeable |
39+
|-------------------|---------------------|-----------|
40+
| nMotionVectorsX | mv_x | YES |
41+
| nMotionVectorsY | mx_y | YES |
42+
| mv_dx | mv_dx | YES |
43+
| mv_dy | mv_dy | YES |
44+
| mv_l | mv_l | YES |
45+
| mv_r | mv_r | YES |
46+
| mv_g | mv_g | YES |
47+
| mv_b | mv_b | YES |
48+
| mv_a | mv_a | YES |
49+
50+
**Notes:**
51+
52+
- Values are not retained across frames, they're only used to draw the current frame and then discarded.
53+
- Each value will be set to the default value assigned in the .milk file at the start of each of the above code blocks.
54+
- Any changes made to the variables in the `per_frame_init_` code are discarded and reset to defaults in the
55+
`per_frame_` block.
56+
57+
This means:
58+
59+
- Only read the values in the `per_frame_init_` bock, e.g. to init user-defined or global variables.
60+
- An expression like `mv_dx += 0.01;` will not animate the value, it'll instead add a constant value to the default one.

0 commit comments

Comments
 (0)