ShadowDusk.Compiler 0.8.0

dotnet add package ShadowDusk.Compiler --version 0.8.0
                    
NuGet\Install-Package ShadowDusk.Compiler -Version 0.8.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.Compiler" Version="0.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ShadowDusk.Compiler" Version="0.8.0" />
                    
Directory.Packages.props
<PackageReference Include="ShadowDusk.Compiler" />
                    
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.Compiler --version 0.8.0
                    
#r "nuget: ShadowDusk.Compiler, 0.8.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.Compiler@0.8.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.Compiler&version=0.8.0
                    
Install as a Cake Addin
#tool nuget:?package=ShadowDusk.Compiler&version=0.8.0
                    
Install as a Cake Tool

ShadowDusk.Compiler

Cross-platform, in-memory HLSL Effect compiler for MonoGame, KNI, and FNA — a drop-in replacement for mgfxc that compiles .fx source to MonoGame/KNI .mgfx bytes (or FNA .fxb) at runtime, on Linux, macOS, and Windows, with no fxc.exe, no mgfxc, no Wine, and no Windows SDK. Add the package and call the API — every native piece rides inside the package set.

The output loads in a real MonoGame/KNI Effect and renders equivalently to mgfxc's — one faithful pipeline (DXC → SPIR-V → SPIRV-Cross → GLSL, or vkd3d-shader → DXBC/D3D9 bytecode) on every OS, byte-identical output across hosts.

Install

dotnet add package ShadowDusk.Compiler

Use

using ShadowDusk.Core;
using ShadowDusk.Compiler;

IShaderCompiler compiler = new EffectCompiler();
var result = await compiler.CompileAsync(fxSource, new CompilerOptions
{
    Target = PlatformTarget.OpenGL,   // or DirectX, or Fna
});

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

var effect = new Effect(graphicsDevice, result.Value.Data);

Need to compile from a synchronous call site (e.g. inside Content.Load<Effect>)? Await compiler.InitializeAsync() once at startup, then call the synchronous compiler.Compile(...) anywhere — same pipeline, byte-identical output.

Targets

CompilerOptions.Target Output Runtime
OpenGL .mgfx (GLSL) MonoGame DesktopGL, KNI (incl. WebGL)
DirectX .mgfx (SM5 DXBC) MonoGame WindowsDX, KNI
Fna .fxb (D3D9 fx_2_0) FNA

All three compile on every desktop OS and produce the same bytes on every OS. Errors come back as ShaderError[] with the file, line, column, and compiler message verbatim.

Output container (v10 default; opt-in v11 / KNIFX)

The default container is MGFX v10, which loads on every MonoGame 3.8.2+ and KNI runtime — you never set a flag for correct output. For newer runtimes, two opt-in, experimental containers are available (additive; the v10 default is unchanged):

  • CompilerOptions.MgfxVersion = 11 — a faithful MonoGame MGFX v11 container (MonoGame 3.8.5+).
  • CompilerOptions.Container = EffectContainer.Knifx — KNI's KNIFX v11 container (KNI v4.02+).

Both render identically to v10 and are render-proven in their real engines; leave the default unless you specifically target a newer runtime.

Prefer to pick a whole target (backend and container) in one value? Set CompilerOptions.Profile to a CapabilityProfile (e.g. CapabilityProfile.KniGL_4_02 for KNIFX on OpenGL); a profile fully specifies the output and overrides Target / Container / MgfxVersion. For an in-app compile, RuntimeProfileDetector.Recommend(typeof(Game).Assembly, target) returns the proven profile for the loaded framework.

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

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ShadowDusk.Compiler:

Package Downloads
ShadowDusk.Wasm

In-browser (WebAssembly / Blazor net8.0-browser) HLSL Effect compiler for MonoGame, KNI, and FNA. Add the package to a net8.0-browser app, call WasmShaderCompiler.CompileAsync, and feed the .mgfx bytes to new Effect(gd, bytes) — the native DXC + SPIRV-Cross + vkd3d-shader WASM modules ride inside the package as Blazor static web assets (served at _content/ShadowDusk.Wasm/) and self-register; the consumer wires NOTHING. Uses the faithful pinned DXC -> SPIR-V -> SPIRV-Cross -> GLSL pipeline (OpenGL/WebGL) and the pinned vkd3d-shader -> DXBC / D3D9 pipeline (DirectX .mgfx and FNA .fxb as in-browser export targets), byte-identical to the desktop CLI output.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.8.0 6 6/18/2026
0.7.0 102 6/15/2026
0.6.0 96 6/14/2026
0.5.1 97 6/13/2026
0.5.0 96 6/13/2026
0.4.0 95 6/11/2026
0.3.0 95 6/11/2026
0.2.0 115 6/8/2026
0.1.1 102 6/7/2026
0.1.0 103 6/7/2026