ShadowDusk.Wasm 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ShadowDusk.Wasm --version 0.1.1
                    
NuGet\Install-Package ShadowDusk.Wasm -Version 0.1.1
                    
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.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ShadowDusk.Wasm" Version="0.1.1" />
                    
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.1.1
                    
#r "nuget: ShadowDusk.Wasm, 0.1.1"
                    
#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.1.1
                    
#: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.1.1
                    
Install as a Cake Addin
#tool nuget:?package=ShadowDusk.Wasm&version=0.1.1
                    
Install as a Cake Tool

ShadowDusk.Wasm

In-browser HLSL → .mgfx shader compiler for MonoGame / KNI, for Blazor WebAssembly (net8.0-browser) apps. Compile .fx shaders to MonoGame .mgfx bytes 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), so the in-browser output matches the desktop/CLI output. The DXC + SPIRV-Cross 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 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).

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.
  • 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 parity: byte-identical to the desktop/CLI compiler for the same source + target.

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.2.0 42 6/8/2026
0.1.1 46 6/7/2026
0.1.0 44 6/7/2026