元編程參考文件

高度圖權重圖

3 個節點

本頁內容 3

計算材質編號

函數

Gives each cell the index of its heaviest layer: a material ID map for engines and shaders that take one material per cell.

簽名
計算材質編號 -> Scalar Field
    權重: Scalar Field 陣列
    歸一化到 0 至 1: 真否
ScalarField2D CalculateMaterialId(
    ScalarField2D[] weights,
    bool normalizeToUnitRange = false)

參數

名稱型別預設值說明
權重Scalar Field 陣列—Layer weights or masks, all the same size.
歸一化到 0 至 1真否FalseFalse for the raw index (0, 1, 2, ...); true to divide by the last index so the map views as a 0..1 greyscale.

返回

結果Scalar Field
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
高度圖權重圖
所屬包
程序化生成

歸一化權重

函數

Converts material masks into layer weights that sum to 1 at every cell.

簽名
歸一化權重 -> Scalar Field 陣列
    蒙版: Scalar Field 陣列
    分層: 真否
    包含基礎圖層: 真否
    對比度: 數字
ScalarField2D[] NormalizeWeights(
    ScalarField2D[] masks,
    bool layered = true,
    bool includeBaseLayer = true,
    double contrast = 1)

參數

名稱型別預設值說明
蒙版Scalar Field 陣列—Material masks in 0..1, bottom layer first, all the same size.
分層真否TrueTrue to stack masks in order, false to share overlaps proportionally.
包含基礎圖層真否TrueTrue to add a remainder layer at index 0 of the output.
對比度數字1Exponent applied to every mask first; above 1 sharpens transitions between layers, below 1 widens them.

返回

結果Scalar Field 陣列

備註

Masks are given bottom first: each later mask is a layer above the earlier ones. Layered, a layer covers the layers below it by its own weight, the way paint layers stack (a cell with rock 0.8 over grass 1 is 80 % rock, 20 % grass). Not layered, overlapping masks share the cell in proportion to their values. With a base layer, whatever no mask claims goes to an extra layer placed first in the output; without one, the bottom mask takes it (layered) or the masks are scaled up to fill the cell (not layered, split equally where every mask is 0).

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
高度圖權重圖
所屬包
程序化生成

打包權重

函數

Packs layer weights four to an image, in the red, green, blue and alpha channels, the layout terrain engines read splatmaps in.

簽名
打包權重(權重: Scalar Field 陣列) -> Pixel Image 陣列
PixelImage[] PackWeights(ScalarField2D[] weights)

參數

名稱型別預設值說明
權重Scalar Field 陣列—Layer weights, normally from HeightmapSplatmaps.NormalizeWeights.

返回

結果Pixel Image 陣列

備註

Layer i goes to image i / 4, channel i % 4 (R, G, B, A); unused channels of the last image are 0. Bytes are rounded so that, where the weights sum to 1, the channels of all the images together sum to exactly 255 (largest-remainder rounding), so no cell loses or gains coverage to rounding.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
高度圖權重圖
所屬包
程序化生成