# [WIP] Celestial Body Resources for ISRU

Every resource a player can mine has to come from somewhere specific. Redux answers that with a **resource density map**: one greyscale image per body-and-resource pair, wrapped around the planet, where white means "dig here" and black means "don't bother". A drill sitting on the ground reads the pixel under itself and mines proportionally. The map view paints the same image over the globe so players can pick a landing site instead of guessing.

The SDK generates these for you. You don't paint them by hand.

# What’s a density map?

A square greyscale PNG in equirectangular projection, 2048×2048 by default. The runtime reads **the red channel only**, as a value from 0 to 1. The other channels are written to match but never sampled.

The projection is fixed and matches the game’s convention:

* **X** runs from −180° longitude at the left edge to +180° at the right.
* **Y** runs from −90° (south pole) at the bottom row to +90° (north pole) at the top.

Two things read that value:

* **Mining** samples it at the vessel's coordinates and scales output rates by it.
* **The map-view overlay and the resource scanner window** display it, once the player has actually scanned that resource on that body.

# Prerequesites

Before you begin, you need to following elements.

* **A biome mask for the body.** You have to supply the SDK your own copy of the biome mask, wether by ripping it from stock (for stock celestial bodies) or by crafting it yourself (for your custom celestial bodies). The window expects them in `reference/biome-masks` at the repository root.
* **An Addressables group named** `**Resource Maps**`**.** If it doesn't exist, generation still writes your files and warns you — but the game will never see them.

# Creating a resource map

## Opening the tool

**Modding → Planet Authoring → Resource Maps.**

 ![The Resource Maps window](https://docs.ksp2redux.org/api/files.get?sig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1cGxvYWRzLzk2ODE5MmJiLThjN2ItNGMzZC1hNmZiLWVlMWU2ZTg0MDY0NS85NGMwZGZmYS1iZjk3LTRiNTYtYTdlMi1lYThkNTE4ZDM0YzQvaW1hZ2UucG5nIiwidHlwZSI6ImF0dGFjaG1lbnQiLCJpYXQiOjE3OTM1MDkyMDAsImV4cCI6MTc5MzU5NTYwMH0.s-iLTEH6b0NsjaqUU1Eqt8-GpqzosiP9jB3AwYrmoLE " =597x1303")

## The authoring asset

Create one asset per body. It stores the body name, the file name of its biome mask, and the list of resources you've authored for it, but not the mask itself, since that lives outside the project.

* **A body name that matches the game's exactly.** The window offers a dropdown built from the project's celestial body localization table, so pick from it where you can. `Other...` is there for a body the project doesn't declare yet, which is what you'll use for a body of your own.
* **A resource name that matches a real resource definition.** Same deal: the dropdown is built by listing the project's `ResourceDefinitions` folder. A name that matches nothing produces a map the game loads and then never associates with anything, and nothing tells you.

Hit **Create New Resource Map Authoring**, name it after the body. The asset file is saved in `Assets/ReduxAssets/Definitions/ResourceSystem/ResourceMapAuthoring`. The window remembers the last asset you had open and reopens it next time.

This asset is editor-only. It’s not packaged into the game. Deleting it doesn't break any map you already generated, it just means you've thrown away the settings that produced them. So keep it.

## Importing the biome mask

Click the mask button and pick your PNG. It gets copied into the mask folder, and its file name is stored on the asset. If the file is named after its body in one of the usual ways (ex: `duna_biome_mask.png`), the body dropdown fills itself in.

A biome mask packs **four coverage channels** into one image: red, green, blue and alpha, each 0 to 1, each marking one biome.

 ![Vall biome mask](https://docs.ksp2redux.org/api/files.get?sig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1cGxvYWRzLzk2ODE5MmJiLThjN2ItNGMzZC1hNmZiLWVlMWU2ZTg0MDY0NS8zMTA1YjM3Yy04MjMxLTRkNWQtYWU3NS1mNTMyYWFkY2FkYWYvaW1hZ2UucG5nIiwidHlwZSI6ImF0dGFjaG1lbnQiLCJpYXQiOjE3OTM1MDkyMDAsImV4cCI6MTc5MzU5NTYwMH0.T5pVsOQzGDjVorHdqZZBiDCTLNYqN_eKfUp0aAmaODA " =381x382")

The window checks the mask as it loads and tells you when something looks off:

* A channel with **no coverage anywhere** carries no biome. Its tab is dimmed, because anything you tune there can never reach the output.
* A mask that isn't square or 2:1 gets flagged, since equirectangular art is normally one or the other.
* A mask that isn't in the folder at all gets an explicit warning. This is the common first-run stumble.