BorrowedTorch.Ormh 1.0.0

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

BorrowedTorch.Ormh

Packs the four single-channel maps of a PBR material into one RGBA texture: R = ambient occlusion, G = roughness, B = metallic, A = height. Four textures become one, a shader reads three values with one fetch, and a parallax march reads height from the channel block compression keeps finest (DXT5 stores alpha on its own).

This package is the format and the packing, with no dependencies: it knows nothing about MonoGame or any image format. You hand it decoded pixels; it hands back packed ones. To build packed maps as part of a MonoGame content build, use BorrowedTorch.ContentPipeline, which is built on this package and packs exactly the same bytes.

What you get:

  • The .ormh descriptor: a small JSON file naming where each channel comes from - an image, one channel of an image (optionally inverted), or a constant.
  • The packer: one call from a layout and an image loader to the packed image. Sources of different sizes are resampled to the largest the way a GPU magnifies them, so a 256 x 256 height map next to 2048 x 2048 maps looks the same packed as it did bound on its own.
  • Descriptors written back: a layout serializes to descriptor text again, sources as absolute paths, for building a copy of a descriptor somewhere else.

Requirements

  • .NET 8 or later. No other dependencies.

Installing

dotnet add package BorrowedTorch.Ormh

Concepts

Type What it is
OrmhLayout Where each of the four channels comes from. Read from a descriptor, or built in code.
OrmhChannelSource One channel: a channel of an image, maybe inverted, or a constant.
OrmhPacker Packs a layout into one image, decoding sources through the loader you pass it.
OrmhImage 8-bit RGBA pixels, rows top to bottom, straight alpha. In and out of the packer.

Everything is in the BorrowedTorch.Ormh namespace.

The descriptor

// Rock/ORMH.ormh - paths are relative to this file
{
    "ao": "Rock_AO.png",
    "roughness": { "source": "Rock_Gloss.png", "invert": true },
    "metallic": 0,
    "height": { "source": "Rock_Height.png", "channel": "r" }
}

Each of the four channels is one of:

Form Meaning
"Map.png" The image's red channel.
{ "source": "Map.png", "channel": "g", "invert": true } Any of r, g, b, a; invert stores 255 minus it.
0.5 A constant from 0 to 1 over the whole map.

All four are required - roughness and metallic have no value that means "absent", so a channel left out is more likely a slip than a choice. Comments and trailing commas are allowed. Anything wrong with a descriptor, malformed JSON included, comes back as a FormatException with a message that says what to write instead.

Packing

using BorrowedTorch.Ormh;

var layout = OrmhLayout.Load("Textures/Rock/ORMH.ormh");

// Decode the sources however your tool already does: the packer only wants 8-bit RGBA.
OrmhImage packed = OrmhPacker.Pack(layout, path => MyDecoder.LoadRgba(path));

// packed.Rgba is Width x Height x 4 bytes: R = AO, G = roughness, B = metallic, A = height.

Or without a descriptor:

var layout = new OrmhLayout(
    ao: new OrmhChannelSource { SourcePath = "maps/Rock_AO.png" },
    roughness: new OrmhChannelSource { SourcePath = "maps/Rock_Gloss.png", Invert = true },
    metallic: new OrmhChannelSource { Constant = 0 },
    height: new OrmhChannelSource { SourcePath = "maps/Rock_Height.png" });

Paths in a layout built in code are handed to your loader as they are; each distinct path is asked for once, however many channels read it.

Using a packed map

Alpha holds height, not coverage. Whatever builds the texture must leave it straight: premultiplying alpha scales the other three channels by height, and a colour key zeroes whole texels.

License

MIT.

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.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BorrowedTorch.Ormh:

Package Downloads
BorrowedTorch.Engine

Kindling, Borrowed Torch's game engine: what a game's own code builds against - its features registering components, systems, keys and UI handlers - for the Kindling editor and player to run

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 164 10/29/2026