vs2convert 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vs2convert-0.2.0/LICENSE +21 -0
- vs2convert-0.2.0/MANIFEST.in +1 -0
- vs2convert-0.2.0/PKG-INFO +267 -0
- vs2convert-0.2.0/README.md +239 -0
- vs2convert-0.2.0/pyproject.toml +45 -0
- vs2convert-0.2.0/setup.cfg +4 -0
- vs2convert-0.2.0/src/vs2convert/__init__.py +10 -0
- vs2convert-0.2.0/src/vs2convert/api.py +194 -0
- vs2convert-0.2.0/src/vs2convert/cli.py +306 -0
- vs2convert-0.2.0/src/vs2convert/core/__init__.py +5 -0
- vs2convert-0.2.0/src/vs2convert/core/detector.py +248 -0
- vs2convert-0.2.0/src/vs2convert/core/gates.py +414 -0
- vs2convert-0.2.0/src/vs2convert/core/generator.py +1363 -0
- vs2convert-0.2.0/src/vs2convert/core/report.py +143 -0
- vs2convert-0.2.0/src/vs2convert/core/shadertoy_meta.py +149 -0
- vs2convert-0.2.0/src/vs2convert/core/textutil.py +80 -0
- vs2convert-0.2.0/src/vs2convert/renderer/__init__.py +5 -0
- vs2convert-0.2.0/src/vs2convert/renderer/assets/default_texture.png +0 -0
- vs2convert-0.2.0/src/vs2convert/renderer/pipeline.py +371 -0
- vs2convert-0.2.0/src/vs2convert/validators/__init__.py +3 -0
- vs2convert-0.2.0/src/vs2convert/validators/validator.py +197 -0
- vs2convert-0.2.0/src/vs2convert.egg-info/PKG-INFO +267 -0
- vs2convert-0.2.0/src/vs2convert.egg-info/SOURCES.txt +25 -0
- vs2convert-0.2.0/src/vs2convert.egg-info/dependency_links.txt +1 -0
- vs2convert-0.2.0/src/vs2convert.egg-info/entry_points.txt +2 -0
- vs2convert-0.2.0/src/vs2convert.egg-info/requires.txt +11 -0
- vs2convert-0.2.0/src/vs2convert.egg-info/top_level.txt +1 -0
vs2convert-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrew Miller
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
prune tests
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vs2convert
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Convert Shadertoy, ISF and GLSLSandbox shaders to VS 2 .frag files
|
|
5
|
+
Author: Andrew Miller
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/andrewpmiller/vs2convert
|
|
8
|
+
Project-URL: Repository, https://github.com/andrewpmiller/vs2convert
|
|
9
|
+
Project-URL: Issues, https://github.com/andrewpmiller/vs2convert/issues
|
|
10
|
+
Keywords: shader,glsl,vs2,shadertoy,isf
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Provides-Extra: render
|
|
19
|
+
Requires-Dist: moderngl; extra == "render"
|
|
20
|
+
Requires-Dist: numpy; extra == "render"
|
|
21
|
+
Requires-Dist: Pillow; extra == "render"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: coverage; extra == "dev"
|
|
25
|
+
Requires-Dist: build; extra == "dev"
|
|
26
|
+
Requires-Dist: twine; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# vs2convert
|
|
30
|
+
|
|
31
|
+
Turn a Shadertoy, ISF, or GLSLSandbox shader into a `.frag` file for VS 2.
|
|
32
|
+
|
|
33
|
+
One command reads the source, works out what kind of shader it is, converts
|
|
34
|
+
the body and parameters, checks the result against VS 2's rules, and writes
|
|
35
|
+
the file. Converting doesn't download anything, and it doesn't need a GPU
|
|
36
|
+
unless you ask it to render the result.
|
|
37
|
+
|
|
38
|
+
This is an independent project. It is not affiliated with or endorsed by
|
|
39
|
+
Imaginando, the maker of VS 2.
|
|
40
|
+
|
|
41
|
+
## Example
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
$ vs2convert shader.fs
|
|
45
|
+
✅ shader.fs -> shader.frag
|
|
46
|
+
GLSLSandbox · 0 params · validated
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## What you need
|
|
50
|
+
|
|
51
|
+
- Python 3.10 or newer. Development and testing use 3.13.
|
|
52
|
+
- VS 2, to load the finished `.frag`.
|
|
53
|
+
- For `--verify`: `moderngl`, NumPy, Pillow, and a working OpenGL driver.
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
pipx install vs2convert # the command, isolated
|
|
59
|
+
uv tool install vs2convert # the same, with uv
|
|
60
|
+
pip install vs2convert # library use
|
|
61
|
+
pip install "vs2convert[render]" # plus --verify
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`pipx` and `uv` print where they put the command. If `vs2convert` is not
|
|
65
|
+
found afterwards, run `pipx ensurepath` or `uv tool update-shell` and open a
|
|
66
|
+
new shell.
|
|
67
|
+
|
|
68
|
+
Or run it once without installing:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
uvx vs2convert shader.fs
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Render verification
|
|
75
|
+
|
|
76
|
+
`--verify` needs three extra packages. Add the `render` extra to whichever
|
|
77
|
+
install you used:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
pipx install "vs2convert[render]"
|
|
81
|
+
# or
|
|
82
|
+
uv tool install "vs2convert[render]"
|
|
83
|
+
# or
|
|
84
|
+
pip install "vs2convert[render]"
|
|
85
|
+
# or, for a one-off run
|
|
86
|
+
uvx --from "vs2convert[render]" vs2convert shader.fs --verify
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Convert a shader
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
vs2convert shader.fs
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
That writes `shader.frag` next to the input. You can name the output
|
|
96
|
+
yourself:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
vs2convert shader.fs path/to/output.frag
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Other common runs:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
vs2convert shader.fs --dry-run # print the result, write nothing
|
|
106
|
+
vs2convert shader.fs --verify # convert, then render and measure it
|
|
107
|
+
cat shader.glsl | vs2convert - out.frag
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
With stdin you must give the output path. There is nowhere else to put it.
|
|
111
|
+
|
|
112
|
+
A successful run looks like this:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
```
|
|
116
|
+
✅ julia.fs -> julia.frag
|
|
117
|
+
ISF · 2 params · validated
|
|
118
|
+
|
|
119
|
+
note: baked: speed -> 0.5 (speed baked per rule 4)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`-v` shows the steps it took and the full text of every note.
|
|
123
|
+
|
|
124
|
+
## What it can and cannot convert
|
|
125
|
+
|
|
126
|
+
It reads ISF, Shadertoy, and GLSLSandbox sources. HLSL and MilkDrop shaders
|
|
127
|
+
are detected and declined; `--force` cannot override that. Detection looks
|
|
128
|
+
for HLSL syntax (`frac`, `lerp`, `texture2D`, `SV_Target`, `Texture2D`,
|
|
129
|
+
`technique`, `floatN main`), so an unusual HLSL file can slip through;
|
|
130
|
+
`--verify` will usually catch it.
|
|
131
|
+
|
|
132
|
+
VS 2 binds one image, exposed as `imageTex`, so a shader may use one image
|
|
133
|
+
input. Two distinct image inputs, or two different `iChannel`s, are declined
|
|
134
|
+
rather than silently collapsed onto the first; `--force` cannot override that
|
|
135
|
+
either.
|
|
136
|
+
|
|
137
|
+
VS 2 takes at most 7 parameters. A source whose Shadertoy parameters block
|
|
138
|
+
or uniform declarations name more than 7 knobs is declined, and `--force`
|
|
139
|
+
does not override it. Engine variables (`time`, `resolution`, `imageTex` and
|
|
140
|
+
the rest) are supplied by VS 2 and cost no slot. ISF INPUTS are handled
|
|
141
|
+
differently: beyond the first 7 they are
|
|
142
|
+
baked into the shader at their default values, and every baked input is
|
|
143
|
+
listed by name in the output, not only under `-v`. None are dropped
|
|
144
|
+
silently.
|
|
145
|
+
|
|
146
|
+
Every file that gets written has passed the structural validator. That check
|
|
147
|
+
covers the manifest and the shape of the body; it does not compile the GLSL.
|
|
148
|
+
If the result is structurally invalid, the run declines instead of writing
|
|
149
|
+
it. There is no `--validate` flag because validation is not optional. Use
|
|
150
|
+
`--verify` when you need evidence that the shader compiles and draws.
|
|
151
|
+
|
|
152
|
+
## Reading the output
|
|
153
|
+
|
|
154
|
+
Declines print the stage and gate that stopped the conversion, what to do
|
|
155
|
+
about it, and a link that opens a GitHub issue with the command and source
|
|
156
|
+
already in the body:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
❌ broken.fs - declined
|
|
161
|
+
convert/missing-entry-point: no mainImage() or main() entry point
|
|
162
|
+
found
|
|
163
|
+
The source has no mainImage()/main(). Check that it is a
|
|
164
|
+
complete shader.
|
|
165
|
+
-> fix the source, or convert it by hand
|
|
166
|
+
exit 1 . nothing written
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
A note that starts with `UNVERIFIED` is different from a refusal. The
|
|
170
|
+
conversion was written, but the tool could not prove one part of the mapping
|
|
171
|
+
matches the original. One case is a Shadertoy `iChannel`: VS 2's `imageTex`
|
|
172
|
+
is not a drop-in replacement for every channel type, so the output is marked
|
|
173
|
+
and you should look at it in VS 2 before trusting it. The file is written and
|
|
174
|
+
the run exits 0. With `--strict` the run exits 5 instead, and writes nothing.
|
|
175
|
+
|
|
176
|
+
## Options
|
|
177
|
+
|
|
178
|
+
**`--verify`** renders the converted file headlessly and prints the measured
|
|
179
|
+
luminance mean, spread, alpha and motion. It answers "does this compile and
|
|
180
|
+
draw something that moves", not "does this match VS 2". A passing render is
|
|
181
|
+
evidence the file works, not proof it looks like the original. Needs the
|
|
182
|
+
render extra and a GL driver.
|
|
183
|
+
|
|
184
|
+
**`--dry-run`** prints the converted shader instead of writing it. Useful
|
|
185
|
+
when you want to read the manifest or diff two attempts. The shader is the
|
|
186
|
+
only thing on stdout, so `vs2convert x.fs --dry-run > x.frag` writes a
|
|
187
|
+
valid file; the verdict goes to stderr.
|
|
188
|
+
|
|
189
|
+
**`--force`** converts past a capability gate. It warns that the output is
|
|
190
|
+
very likely broken, because it usually is. It cannot override HLSL/MilkDrop,
|
|
191
|
+
image-input and channel limits, the 7-parameter budget, or a source with no
|
|
192
|
+
`mainImage()`/`main()` entry point.
|
|
193
|
+
|
|
194
|
+
**`--strict`** exits 5 if the conversion is only `UNVERIFIED`, and writes
|
|
195
|
+
nothing. Use it in scripts that should not accept a maybe.
|
|
196
|
+
|
|
197
|
+
**`--meta FILE`** supplies Shadertoy pass and channel metadata. The tool also
|
|
198
|
+
looks for `<stem>.stmeta.json` beside the source, a lone `*.stmeta.json` in
|
|
199
|
+
the same directory, or an inline `/*{...}*/` JSON block at the top of the
|
|
200
|
+
source. Precedence is `--meta`, then sidecar, then inline. Only
|
|
201
|
+
Shadertoy-style sources consult it; passing `--meta` with an ISF or
|
|
202
|
+
GLSLSandbox file is ignored, with a note. Details are in
|
|
203
|
+
[docs/shadertoy.md](https://github.com/andrewpmiller/vs2convert/blob/main/docs/shadertoy.md).
|
|
204
|
+
|
|
205
|
+
**`-v`, `--verbose`** shows every step and the full text of each note.
|
|
206
|
+
|
|
207
|
+
## Exit codes
|
|
208
|
+
|
|
209
|
+
| Code | Meaning |
|
|
210
|
+
|---|---|
|
|
211
|
+
| 0 | Converted, validated, and rendered if you asked for it |
|
|
212
|
+
| 1 | Declined, including a validation failure or a failed render check; also the input or metadata could not be read |
|
|
213
|
+
| 2 | Render verification unavailable (missing packages or no usable GL context), or bad command-line usage |
|
|
214
|
+
| 3 | Declined at the suitability stage: the format is recognised but cannot be converted |
|
|
215
|
+
| 4 | Could not write the output: missing directory, write error, or the output path is the input |
|
|
216
|
+
| 5 | `--strict` was set and the conversion was unverified |
|
|
217
|
+
|
|
218
|
+
## When it declines
|
|
219
|
+
|
|
220
|
+
The message names the gate, so start there.
|
|
221
|
+
|
|
222
|
+
- **`convert/missing-entry-point`** means the file has no `mainImage()` or
|
|
223
|
+
`main()`. It is not a complete shader, or it was truncated.
|
|
224
|
+
- **A suitability decline (exit 3)** means the format is recognised but
|
|
225
|
+
cannot be converted: HLSL or MilkDrop, more than 7 parameters, or distinct
|
|
226
|
+
`iChannel`s. `--force` does not override these. The action line says whether
|
|
227
|
+
to edit the source or port it by hand.
|
|
228
|
+
- **A channel the metadata declares (exit 1)** means the source reads a
|
|
229
|
+
channel VS 2 has no input for (buffer, cubemap, keyboard), or an `audio`
|
|
230
|
+
channel. VS 2 has an audio sampler, `fftTex`, but no mapping is implemented
|
|
231
|
+
and the metadata does not say whether it is a waveform or an FFT. Change the
|
|
232
|
+
channel to a texture, or convert by hand. `--force` does not override it.
|
|
233
|
+
- **"would overwrite"** means the output path is the input, whether you named
|
|
234
|
+
it or the default `.frag` would replace a `.frag` input. Give the output a
|
|
235
|
+
different name.
|
|
236
|
+
- **"render verification unavailable"** means `--verify` could not run. Install
|
|
237
|
+
the render extra or fix the OpenGL driver. It is not a shader failure; a
|
|
238
|
+
machine with no usable GL context exits 2 and says so.
|
|
239
|
+
- **"two image inputs"** means exactly that. Keep one image path; `--force`
|
|
240
|
+
will not collapse them.
|
|
241
|
+
|
|
242
|
+
If you think the converter got it wrong, use the issue link the decline
|
|
243
|
+
prints. It includes the command, the rejection, and the source, which is what
|
|
244
|
+
makes the report actionable.
|
|
245
|
+
|
|
246
|
+
## Contributing
|
|
247
|
+
|
|
248
|
+
Start from a checkout:
|
|
249
|
+
|
|
250
|
+
```sh
|
|
251
|
+
git clone https://github.com/andrewpmiller/vs2convert.git
|
|
252
|
+
cd vs2convert
|
|
253
|
+
uv venv --python 3.13 .venv
|
|
254
|
+
uv pip install -e ".[dev,render]"
|
|
255
|
+
.venv/bin/python -m pytest
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Contributions are accepted under the MIT license with a DCO sign-off. Use
|
|
259
|
+
`git commit -s`. The hooks, coverage and test rules are in
|
|
260
|
+
[CONTRIBUTING.md](https://github.com/andrewpmiller/vs2convert/blob/main/CONTRIBUTING.md).
|
|
261
|
+
|
|
262
|
+
Bugs and bad conversions: open an issue at
|
|
263
|
+
<https://github.com/andrewpmiller/vs2convert/issues>.
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
MIT. See `LICENSE`.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# vs2convert
|
|
2
|
+
|
|
3
|
+
Turn a Shadertoy, ISF, or GLSLSandbox shader into a `.frag` file for VS 2.
|
|
4
|
+
|
|
5
|
+
One command reads the source, works out what kind of shader it is, converts
|
|
6
|
+
the body and parameters, checks the result against VS 2's rules, and writes
|
|
7
|
+
the file. Converting doesn't download anything, and it doesn't need a GPU
|
|
8
|
+
unless you ask it to render the result.
|
|
9
|
+
|
|
10
|
+
This is an independent project. It is not affiliated with or endorsed by
|
|
11
|
+
Imaginando, the maker of VS 2.
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
$ vs2convert shader.fs
|
|
17
|
+
✅ shader.fs -> shader.frag
|
|
18
|
+
GLSLSandbox · 0 params · validated
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What you need
|
|
22
|
+
|
|
23
|
+
- Python 3.10 or newer. Development and testing use 3.13.
|
|
24
|
+
- VS 2, to load the finished `.frag`.
|
|
25
|
+
- For `--verify`: `moderngl`, NumPy, Pillow, and a working OpenGL driver.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pipx install vs2convert # the command, isolated
|
|
31
|
+
uv tool install vs2convert # the same, with uv
|
|
32
|
+
pip install vs2convert # library use
|
|
33
|
+
pip install "vs2convert[render]" # plus --verify
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`pipx` and `uv` print where they put the command. If `vs2convert` is not
|
|
37
|
+
found afterwards, run `pipx ensurepath` or `uv tool update-shell` and open a
|
|
38
|
+
new shell.
|
|
39
|
+
|
|
40
|
+
Or run it once without installing:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
uvx vs2convert shader.fs
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Render verification
|
|
47
|
+
|
|
48
|
+
`--verify` needs three extra packages. Add the `render` extra to whichever
|
|
49
|
+
install you used:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pipx install "vs2convert[render]"
|
|
53
|
+
# or
|
|
54
|
+
uv tool install "vs2convert[render]"
|
|
55
|
+
# or
|
|
56
|
+
pip install "vs2convert[render]"
|
|
57
|
+
# or, for a one-off run
|
|
58
|
+
uvx --from "vs2convert[render]" vs2convert shader.fs --verify
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Convert a shader
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
vs2convert shader.fs
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
That writes `shader.frag` next to the input. You can name the output
|
|
68
|
+
yourself:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
vs2convert shader.fs path/to/output.frag
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Other common runs:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
vs2convert shader.fs --dry-run # print the result, write nothing
|
|
78
|
+
vs2convert shader.fs --verify # convert, then render and measure it
|
|
79
|
+
cat shader.glsl | vs2convert - out.frag
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
With stdin you must give the output path. There is nowhere else to put it.
|
|
83
|
+
|
|
84
|
+
A successful run looks like this:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
```
|
|
88
|
+
✅ julia.fs -> julia.frag
|
|
89
|
+
ISF · 2 params · validated
|
|
90
|
+
|
|
91
|
+
note: baked: speed -> 0.5 (speed baked per rule 4)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`-v` shows the steps it took and the full text of every note.
|
|
95
|
+
|
|
96
|
+
## What it can and cannot convert
|
|
97
|
+
|
|
98
|
+
It reads ISF, Shadertoy, and GLSLSandbox sources. HLSL and MilkDrop shaders
|
|
99
|
+
are detected and declined; `--force` cannot override that. Detection looks
|
|
100
|
+
for HLSL syntax (`frac`, `lerp`, `texture2D`, `SV_Target`, `Texture2D`,
|
|
101
|
+
`technique`, `floatN main`), so an unusual HLSL file can slip through;
|
|
102
|
+
`--verify` will usually catch it.
|
|
103
|
+
|
|
104
|
+
VS 2 binds one image, exposed as `imageTex`, so a shader may use one image
|
|
105
|
+
input. Two distinct image inputs, or two different `iChannel`s, are declined
|
|
106
|
+
rather than silently collapsed onto the first; `--force` cannot override that
|
|
107
|
+
either.
|
|
108
|
+
|
|
109
|
+
VS 2 takes at most 7 parameters. A source whose Shadertoy parameters block
|
|
110
|
+
or uniform declarations name more than 7 knobs is declined, and `--force`
|
|
111
|
+
does not override it. Engine variables (`time`, `resolution`, `imageTex` and
|
|
112
|
+
the rest) are supplied by VS 2 and cost no slot. ISF INPUTS are handled
|
|
113
|
+
differently: beyond the first 7 they are
|
|
114
|
+
baked into the shader at their default values, and every baked input is
|
|
115
|
+
listed by name in the output, not only under `-v`. None are dropped
|
|
116
|
+
silently.
|
|
117
|
+
|
|
118
|
+
Every file that gets written has passed the structural validator. That check
|
|
119
|
+
covers the manifest and the shape of the body; it does not compile the GLSL.
|
|
120
|
+
If the result is structurally invalid, the run declines instead of writing
|
|
121
|
+
it. There is no `--validate` flag because validation is not optional. Use
|
|
122
|
+
`--verify` when you need evidence that the shader compiles and draws.
|
|
123
|
+
|
|
124
|
+
## Reading the output
|
|
125
|
+
|
|
126
|
+
Declines print the stage and gate that stopped the conversion, what to do
|
|
127
|
+
about it, and a link that opens a GitHub issue with the command and source
|
|
128
|
+
already in the body:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
❌ broken.fs - declined
|
|
133
|
+
convert/missing-entry-point: no mainImage() or main() entry point
|
|
134
|
+
found
|
|
135
|
+
The source has no mainImage()/main(). Check that it is a
|
|
136
|
+
complete shader.
|
|
137
|
+
-> fix the source, or convert it by hand
|
|
138
|
+
exit 1 . nothing written
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
A note that starts with `UNVERIFIED` is different from a refusal. The
|
|
142
|
+
conversion was written, but the tool could not prove one part of the mapping
|
|
143
|
+
matches the original. One case is a Shadertoy `iChannel`: VS 2's `imageTex`
|
|
144
|
+
is not a drop-in replacement for every channel type, so the output is marked
|
|
145
|
+
and you should look at it in VS 2 before trusting it. The file is written and
|
|
146
|
+
the run exits 0. With `--strict` the run exits 5 instead, and writes nothing.
|
|
147
|
+
|
|
148
|
+
## Options
|
|
149
|
+
|
|
150
|
+
**`--verify`** renders the converted file headlessly and prints the measured
|
|
151
|
+
luminance mean, spread, alpha and motion. It answers "does this compile and
|
|
152
|
+
draw something that moves", not "does this match VS 2". A passing render is
|
|
153
|
+
evidence the file works, not proof it looks like the original. Needs the
|
|
154
|
+
render extra and a GL driver.
|
|
155
|
+
|
|
156
|
+
**`--dry-run`** prints the converted shader instead of writing it. Useful
|
|
157
|
+
when you want to read the manifest or diff two attempts. The shader is the
|
|
158
|
+
only thing on stdout, so `vs2convert x.fs --dry-run > x.frag` writes a
|
|
159
|
+
valid file; the verdict goes to stderr.
|
|
160
|
+
|
|
161
|
+
**`--force`** converts past a capability gate. It warns that the output is
|
|
162
|
+
very likely broken, because it usually is. It cannot override HLSL/MilkDrop,
|
|
163
|
+
image-input and channel limits, the 7-parameter budget, or a source with no
|
|
164
|
+
`mainImage()`/`main()` entry point.
|
|
165
|
+
|
|
166
|
+
**`--strict`** exits 5 if the conversion is only `UNVERIFIED`, and writes
|
|
167
|
+
nothing. Use it in scripts that should not accept a maybe.
|
|
168
|
+
|
|
169
|
+
**`--meta FILE`** supplies Shadertoy pass and channel metadata. The tool also
|
|
170
|
+
looks for `<stem>.stmeta.json` beside the source, a lone `*.stmeta.json` in
|
|
171
|
+
the same directory, or an inline `/*{...}*/` JSON block at the top of the
|
|
172
|
+
source. Precedence is `--meta`, then sidecar, then inline. Only
|
|
173
|
+
Shadertoy-style sources consult it; passing `--meta` with an ISF or
|
|
174
|
+
GLSLSandbox file is ignored, with a note. Details are in
|
|
175
|
+
[docs/shadertoy.md](https://github.com/andrewpmiller/vs2convert/blob/main/docs/shadertoy.md).
|
|
176
|
+
|
|
177
|
+
**`-v`, `--verbose`** shows every step and the full text of each note.
|
|
178
|
+
|
|
179
|
+
## Exit codes
|
|
180
|
+
|
|
181
|
+
| Code | Meaning |
|
|
182
|
+
|---|---|
|
|
183
|
+
| 0 | Converted, validated, and rendered if you asked for it |
|
|
184
|
+
| 1 | Declined, including a validation failure or a failed render check; also the input or metadata could not be read |
|
|
185
|
+
| 2 | Render verification unavailable (missing packages or no usable GL context), or bad command-line usage |
|
|
186
|
+
| 3 | Declined at the suitability stage: the format is recognised but cannot be converted |
|
|
187
|
+
| 4 | Could not write the output: missing directory, write error, or the output path is the input |
|
|
188
|
+
| 5 | `--strict` was set and the conversion was unverified |
|
|
189
|
+
|
|
190
|
+
## When it declines
|
|
191
|
+
|
|
192
|
+
The message names the gate, so start there.
|
|
193
|
+
|
|
194
|
+
- **`convert/missing-entry-point`** means the file has no `mainImage()` or
|
|
195
|
+
`main()`. It is not a complete shader, or it was truncated.
|
|
196
|
+
- **A suitability decline (exit 3)** means the format is recognised but
|
|
197
|
+
cannot be converted: HLSL or MilkDrop, more than 7 parameters, or distinct
|
|
198
|
+
`iChannel`s. `--force` does not override these. The action line says whether
|
|
199
|
+
to edit the source or port it by hand.
|
|
200
|
+
- **A channel the metadata declares (exit 1)** means the source reads a
|
|
201
|
+
channel VS 2 has no input for (buffer, cubemap, keyboard), or an `audio`
|
|
202
|
+
channel. VS 2 has an audio sampler, `fftTex`, but no mapping is implemented
|
|
203
|
+
and the metadata does not say whether it is a waveform or an FFT. Change the
|
|
204
|
+
channel to a texture, or convert by hand. `--force` does not override it.
|
|
205
|
+
- **"would overwrite"** means the output path is the input, whether you named
|
|
206
|
+
it or the default `.frag` would replace a `.frag` input. Give the output a
|
|
207
|
+
different name.
|
|
208
|
+
- **"render verification unavailable"** means `--verify` could not run. Install
|
|
209
|
+
the render extra or fix the OpenGL driver. It is not a shader failure; a
|
|
210
|
+
machine with no usable GL context exits 2 and says so.
|
|
211
|
+
- **"two image inputs"** means exactly that. Keep one image path; `--force`
|
|
212
|
+
will not collapse them.
|
|
213
|
+
|
|
214
|
+
If you think the converter got it wrong, use the issue link the decline
|
|
215
|
+
prints. It includes the command, the rejection, and the source, which is what
|
|
216
|
+
makes the report actionable.
|
|
217
|
+
|
|
218
|
+
## Contributing
|
|
219
|
+
|
|
220
|
+
Start from a checkout:
|
|
221
|
+
|
|
222
|
+
```sh
|
|
223
|
+
git clone https://github.com/andrewpmiller/vs2convert.git
|
|
224
|
+
cd vs2convert
|
|
225
|
+
uv venv --python 3.13 .venv
|
|
226
|
+
uv pip install -e ".[dev,render]"
|
|
227
|
+
.venv/bin/python -m pytest
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Contributions are accepted under the MIT license with a DCO sign-off. Use
|
|
231
|
+
`git commit -s`. The hooks, coverage and test rules are in
|
|
232
|
+
[CONTRIBUTING.md](https://github.com/andrewpmiller/vs2convert/blob/main/CONTRIBUTING.md).
|
|
233
|
+
|
|
234
|
+
Bugs and bad conversions: open an issue at
|
|
235
|
+
<https://github.com/andrewpmiller/vs2convert/issues>.
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
MIT. See `LICENSE`.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vs2convert"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Convert Shadertoy, ISF and GLSLSandbox shaders to VS 2 .frag files"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Andrew Miller" }]
|
|
14
|
+
keywords = ["shader", "glsl", "vs2", "shadertoy", "isf"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Topic :: Multimedia :: Graphics",
|
|
20
|
+
]
|
|
21
|
+
dependencies = []
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/andrewpmiller/vs2convert"
|
|
25
|
+
Repository = "https://github.com/andrewpmiller/vs2convert"
|
|
26
|
+
Issues = "https://github.com/andrewpmiller/vs2convert/issues"
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
render = ["moderngl", "numpy", "Pillow"]
|
|
30
|
+
dev = ["pytest", "coverage", "build", "twine"]
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
vs2convert = "vs2convert.cli:main"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools]
|
|
36
|
+
package-dir = { "" = "src" }
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.dynamic]
|
|
39
|
+
version = { attr = "vs2convert.__version__" }
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
where = ["src"]
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.package-data]
|
|
45
|
+
"vs2convert.renderer" = ["assets/*.png"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""vs2convert - convert Shadertoy, ISF and GLSLSandbox shaders to VS-2 .frag.
|
|
2
|
+
|
|
3
|
+
The library surface lives in :mod:`vs2convert.api`; the command line entry
|
|
4
|
+
point is :func:`vs2convert.cli.main`.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .api import ConversionResult, Rejection, convert
|
|
8
|
+
|
|
9
|
+
__all__ = ["convert", "ConversionResult", "Rejection"]
|
|
10
|
+
__version__ = "0.2.0"
|