Regular JS minification & obfuscation does not alter the shader code generated by TypeGPU.
This is why we provide specific options for transforming shaders.
unplugin-typegpu collects function metadata, which is later used for WGSL code generation.
With the { unstable_obfuscate: true } option, all saved identifiers will be obfuscated:
In the AST, all parameters and variables will have their names changed to a, b, c, β¦
Externals (the captured scope used by the function) will also have their respective identifiers changed.
As an example, take a look at the following function:
Runtime minification removes all comments (possibly present in raw-WGSL implemented functions), and all redundant whitespaces.
To enable minification, set the { unstable_minify: true } option in either tgpu.resolve,
or in tgpu.init where it will act as a default for all rooted resolves.
As an example, the coneVolume function would look like this when minified: