Orrery Terrain · OrreryTerrain module · function
BrushBake::
FromSplatRgba16
Bake an RGBA image into up to four step masks, one per used channel (splat paint).
Declaration
EOrreryTerrainBrushBake FromSplatRgba16(const uint16* Rgba, int32 Width, int32 Height, uint32 Used, const FBakeSpec& Spec,
std::shared_ptr<const OrreryTerrain::Native::FBrushMask> (&OutMasks)[kSplatChannels]);- Header
#include "OrreryTerrainBrushAsset.h"- Module
PublicDependencyModuleNames.Add("OrreryTerrain");in your module’s Build.cs.- Stability
- Stable: changes within a major version only add.
- Thread
- Any thread.
Description
The channels are read as layer weights (coverage), and the masks are made so that four masked Paint steps at full opacity, in channel order red, green, blue, alpha, leave each layer at its channel's weight. A Paint step moves its layer toward full by the mask and scales every other layer down by the same fraction, so a later step takes from the earlier ones; the bake undoes that. With w the used channels' weights (scaled together to sum to 1 when they sum above it) and T the sum of the weights after a channel, its mask is w / (1 - T). A uniform pixel (0.5, 0.25, 0.25, 0) therefore paints the first layer at 0.5, the second and third at 0.25 each, and keeps nothing of the ground (sum 1); a pixel that sums to 0.6 keeps 0.4 of what was there. A channel that is not used counts as 0 (an image's alpha is often opaque: leave its layer unset).
The resample and the transform are integer only, so the same pixels and spec give the same bytes and hashes everywhere. Each mask's hash covers its own bytes only.
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
Rgba | const uint16* | — | Width x Height pixels of 4 unorm 16-bit samples (R, G, B, A), row-major, 0 to 65535. |
Width | int32 | — | Pixels a row. |
Height | int32 | — | Rows. |
Used | uint32 | — | Bit c set: channel c becomes a mask (bit 0 red to bit 3 alpha); other bits are ignored. |
Spec | const FBake | — | The bake settings: Side and Depth (Usage Strength gives 256 and 8 bits); Channel and Invert are ignored. |
OutMasks | std:: | — | Per channel, its mask on Ok when used, else null. |
Returns
Ok, BadSize or Refused.
Any thread.