ShadowDusk.Wasm 0.7.0

dotnet add package ShadowDusk.Wasm --version 0.7.0
                    
NuGet\Install-Package ShadowDusk.Wasm -Version 0.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ShadowDusk.Wasm" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ShadowDusk.Wasm" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="ShadowDusk.Wasm" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ShadowDusk.Wasm --version 0.7.0
                    
#r "nuget: ShadowDusk.Wasm, 0.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ShadowDusk.Wasm@0.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ShadowDusk.Wasm&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=ShadowDusk.Wasm&version=0.7.0
                    
Install as a Cake Tool

ShadowDusk.Wasm

In-browser HLSL shader compiler for MonoGame / KNI / FNA, for Blazor WebAssembly (net8.0-browser) apps. Compile .fx shaders to MonoGame/KNI .mgfx bytes — or DirectX .mgfx / FNA .fxb for download — at runtime, in the browser: no server round-trip, no fxc.exe, no mgfxc, no native install.

It runs the same faithful pipeline as the desktop compiler (pinned DXC → SPIR-V → SPIRV-Cross → GLSL for OpenGL/WebGL; pinned vkd3d-shader → DXBC / D3D9 bytecode for DirectX/FNA), so the in-browser output is byte-identical to the desktop/CLI output. The DXC + SPIRV-Cross + vkd3d-shader WebAssembly modules ride inside this package as Blazor static web assets and self-register — you wire nothing.

Install

dotnet add package ShadowDusk.Wasm

(or search ShadowDusk in Visual Studio's NuGet UI and install ShadowDusk.Wasm.)

The dxcompiler.wasm / spirv-cross.wasm / vkd3d-shader.wasm modules ship in the package and are served automatically at _content/ShadowDusk.Wasm/… — there is nothing to copy or configure.

Use (KNI / MonoGame Blazor WASM)

using ShadowDusk.Core;
using ShadowDusk.Wasm;

// 1. Compile .fx -> .mgfx bytes, in the browser, at runtime.
IShaderCompiler compiler = new WasmShaderCompiler();
var result = await compiler.CompileAsync(fxSource, new CompilerOptions
{
    Target = PlatformTarget.OpenGL,   // WebGL / KNI
});

if (result.IsFailure)
{
    foreach (var e in result.Error)
        Console.Error.WriteLine($"{e.Code}: {e.Message}");
    return;
}

byte[] mgfx = result.Value.Data;

// 2. Load the bytes into a real KNI/MonoGame Effect and render.
var effect = new Effect(graphicsDevice, mgfx);

That's it: search → install → call WasmShaderCompiler.CompileAsync → feed the bytes to new Effect(gd, bytes).

DirectX & FNA — export targets

The same CompileAsync also accepts PlatformTarget.DirectX (DX11 SM5 DXBC .mgfx) and PlatformTarget.Fna (D3D9 fx_2_0 .fxb) in the browser, via the pinned vkd3d-shader compiled to WebAssembly — the bytes are identical to a desktop compile. These are export targets: a browser cannot render DXBC or D3D9 bytecode, so use them to offer downloads (e.g. a shader-fiddle "export" button) that render in the user's MonoGame WindowsDX / FNA game. If the vkd3d module is genuinely absent the compile fails loudly with diagnostic SD1902.

Notes

  • Target framework: net8.0-browser (Blazor WebAssembly / KNI web).
  • Self-contained: the WASM native modules are inside the package; first use downloads them with your app's _framework/_content assets.
  • Lazy, per-target download: each module is fetched by the first compile that needs it — dxcompiler.wasm (~17 MB raw, ~6 MB compressed) for OpenGL/WebGL, vkd3d-shader.wasm (~1.3 MB raw, ~0.4 MB compressed) for DirectX/FNA. Serve with HTTP compression.
  • KNI HiDef / WebGL2: a single .mgfx loads in both KNI Reach (WebGL1) and HiDef (WebGL2 / GLSL ES 3.00) — no flag, no separate build.
  • Output container: the default MGFX v10 loads on every MonoGame/KNI runtime; the same opt-in newer containers as the desktop library are available via CompilerOptions (MgfxVersion = 11 for MonoGame 3.8.5+, Container = EffectContainer.Knifx for KNI v4.02+).
  • Output parity: byte-identical to the desktop/CLI compiler for the same source + target (machine-verified in a real browser over the full byte-identity corpus).

See the ShadowDusk repository for the full pipeline, samples (samples/ShaderFiddle.Web), and the desktop library (ShadowDusk.Compiler) / mgfxc CLI tool.

Product Compatible and additional computed target framework versions.
.NET net8.0-browser1.0 is compatible.  net9.0-browser was computed.  net10.0-browser was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.0 38 6/15/2026
0.6.0 38 6/14/2026
0.5.1 52 6/13/2026
0.5.0 42 6/13/2026
0.4.0 74 6/11/2026
0.3.0 75 6/11/2026
0.2.0 98 6/8/2026
0.1.1 90 6/7/2026
0.1.0 86 6/7/2026