ShadowDusk.Compiler 0.21.0

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

ShadowDusk.Compiler

An in-memory HLSL shader compiler for MonoGame, KNI, and FNA. Add the package, call CompileAsync(fx), and get back .mgfx bytes (or an FNA .fxb) you can load straight into an Effect — on Linux, macOS, or Windows, at build time or live at runtime.

It's a drop-in replacement for mgfxc: the output loads in a real MonoGame/KNI Effect and renders the same as mgfxc's, on every OS. Nothing extra to install (no fxc.exe, no mgfxc, no Wine, no Windows SDK) — every native piece ships inside the package.

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, DirectX12, Vulkan, 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
DirectX12 .mgfx (SM6 DXIL) MonoGame WindowsDX12 (3.8.5+)
Vulkan .mgfx (SPIR-V) MonoGame DesktopVK (3.8.5+)

Every target compiles on every desktop OS with deterministic output — the same source, compiler version, and target produce the same bytes. Errors come back as ShaderError[] with the file, line, column, and compiler message verbatim.

Output format

By default you get MGFX v10 (.mgfx), which loads on every MonoGame from 3.8.1.263 (the measured floor) through 3.8.5, plus KNI. You never set a flag to get correct output. (DirectX12 and Vulkan exist only on MonoGame 3.8.5+, so those two targets always emit v11.)

Targeting a newer runtime? Two optional formats load and render exactly like v10:

  • MonoGame 3.8.5+ → CompilerOptions.MgfxVersion = 11
  • KNI v4.02+ → CompilerOptions.Container = EffectContainer.Knifx

If you're not sure, keep the default.

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.

Beyond MonoGame: SkiaSharp and raylib

The same faithful front half (DXC, SPIRV-Cross) also feeds two source converters for a single-pass, pixel-only .fx. Neither produces an .mgfx, and neither runtime has a reference compiler, so both are judged by rendered-image fidelity, never mgfxc-equivalence:

  • SkiaSharp (SkSL): ShadowDusk.Compiler.Sksl.SkslConverter.Convert(fx, new SkslConvertOptions()) returns an SkslConversion whose SkSL text loads into SKRuntimeEffect.
  • raylib (Raylib-cs): ShadowDusk.Compiler.Raylib.RaylibConverter.Convert(fx, new RaylibConvertOptions()) returns a RaylibShader: a #version 330 fragment shader for Raylib.LoadShaderFromMemory(null, fs) plus its uniform and sampler binding contract.

Both also take .slang input (SkslConverter.ConvertSlang, RaylibConverter.ConvertSlang) through the built-in Slang subset; genuine Slang (generics, interfaces) goes through ShadowDusk.Slang's SlangCompiler.ConvertToSksl / ConvertToRaylib.

Anything outside what each runtime can hold is refused by name, never silently dropped.

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 is compatible.  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 (4)

Showing the top 4 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.

ShadowDusk.ContentPipeline

ShadowDusk's MonoGame content-pipeline importer and processor (ShadowDuskEffectImporter / ShadowDuskEffectProcessor) as a normal library, for MonoGame 3.8.5's code-centric Content Builder project: reference the package, pass the two instances in GetContentCollection, and your .fx compiles to .xnb through ShadowDusk in your Builder's own process, with no mgfxc, no fxc.exe, and no Wine. A delivery shape of the ShadowDusk compiler library - byte-for-byte the .mgfx the ShadowDusk CLI emits. For .mgcb / MGCB use ShadowDusk.MgcbPlugin instead.

ShadowDusk.Slang

ShadowDusk full Slang front-end: bundles the real slangc compiler for win-x64, linux-x64, osx-x64 and osx-arm64 (Apache-2.0, see THIRD-PARTY-NOTICES.txt) so a consumer gets genuine Slang input (import, generics, interfaces) compiled via slangc -target hlsl and handed to ShadowDusk's existing, unchanged, faithful DXC pipeline. Linux needs a GCC 11+ libstdc++ (Ubuntu 22.04 or later); macOS needs macOS 26 or later (the upstream build's own floor). Optional and additive: ShadowDusk.Compiler's own .slang support (an HLSL-compatible subset, no extra package) is untouched.

Gum.SkiaSharp.ShadowDusk

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.21.0 693 10/6/2026
0.20.0 10,328 9/10/2026
0.19.0 156 9/10/2026
0.18.0 281 8/3/2026
0.17.0 2,502 8/1/2026
0.16.0 163 7/31/2026
0.15.1 135 7/28/2026
0.15.0 129 7/28/2026
0.14.2 133 7/25/2026
0.14.1 141 7/25/2026
0.14.0 206 7/24/2026
0.13.0 140 7/23/2026
0.12.1 134 7/22/2026
0.12.0 144 7/19/2026
0.11.0 1,106 6/29/2026
0.10.0 148 6/28/2026
0.9.0 160 6/22/2026
0.8.0 4,774 6/18/2026
0.7.0 151 6/15/2026
0.6.0 136 6/14/2026
Loading failed