dh.texture
Extension: .dh-tex — Type ID: dh.texture
Texture definitions describe compile-time texture operations. The compiler processes them during dh build — runtimes just load the pre-baked results.
Two modes: channel packing (pack) or single source (source). They’re mutually exclusive.
Properties
Section titled “Properties”| Property | Type | Required | Description |
|---|---|---|---|
$type | "dh.texture" | no | Type identifier |
name | string | no | Display name |
description | string | no | Description |
pack | object | one of | Channel packing map (mutually exclusive with source) |
source | string | one of | Single source texture path (mutually exclusive with pack) |
size | [w, h] | no | Target dimensions. Omit to keep original size. |
The type is inferred from the file extension —
$typeis not needed in source files. The compiler adds it automatically during builds.
Channel Packing
Section titled “Channel Packing”Combine channels from multiple source textures into a single output. Classic use case: ORM (Occlusion, Roughness, Metallic) packing.
{ "name": "Body ORM", "pack": { "r": "textures/occlusion.png@r", "g": "textures/roughness.png@r", "b": "textures/metallic.png@r" }}Each key is an output channel (r, g, b, a). Each value is a texture reference with optional @channel suffix.
Defaults for unspecified channels:
- RGB channels → 0 (black)
- Alpha channel → 255 (fully opaque)
Single Source
Section titled “Single Source”Process one texture — resize it or reference a single source:
{ "name": "Body Diffuse (1K)", "source": "textures/body-diffuse.png", "size": [1024, 1024]}If only one dimension is given in size, the other is calculated to preserve the aspect ratio.
@channel Syntax
Section titled “@channel Syntax”The @channel suffix extracts a single channel from a source texture. This works anywhere texture paths are used — in pack values, in source, and in material texture references.
| Syntax | Result |
|---|---|
textures/packed.png | Full RGBA texture |
textures/packed.png@r | Red channel as grayscale |
textures/packed.png@g | Green channel as grayscale |
textures/packed.png@b | Blue channel as grayscale |
textures/packed.png@a | Alpha channel as grayscale |
Works with cross-pallet barcodes too:
io.mltn.base:textures/packed-orm.png@rThe @ separator was chosen because it can’t appear in file paths and doesn’t conflict with : used for pallet references.
Examples
Section titled “Examples”ORM Pack
Section titled “ORM Pack”{ "name": "Body ORM", "pack": { "r": "textures/body-ao.png@r", "g": "textures/body-roughness.png@r", "b": "textures/body-metallic.png@r" }}Downscale for Performance
Section titled “Downscale for Performance”{ "name": "Body Diffuse (Mobile)", "source": "textures/body-diffuse-4k.png", "size": [512, 512]}RGBA with Alpha
Section titled “RGBA with Alpha”{ "name": "Decal with Transparency", "pack": { "r": "textures/decal-color.png@r", "g": "textures/decal-color.png@g", "b": "textures/decal-color.png@b", "a": "textures/decal-mask.png@r" }}