Function ExtractMaxChannelAsync
-
ExtractMaxChannelAsync(
name: string,
input: ITextureProcessOperand,
scene: Scene,
includeAlpha?: boolean,
outputColorSpace?: TextureColorSpace,
outputChannelMask?: ChannelMask,
outputOptions?: ITextureProcessorOutputOptions,
): Promise<ITextureProcessOperand>Parameters
- name: string
Name for the resulting procedural texture (used only when a GPU pass is needed)
- input: ITextureProcessOperand
Operand to reduce
- scene: Scene
Scene to create the texture in (used only when a GPU pass is needed)
- includeAlpha: boolean = false
When true, alpha participates in the max and is also set to the result. Defaults to false (alpha is preserved from the input).
OptionaloutputColorSpace: TextureColorSpaceOptional output color space. When
TextureColorSpace.SRGB, the linear result is converted to sRGB (IEC 61966-2-1) before being written. Defaults toTextureColorSpace.Linear.OptionaloutputChannelMask: ChannelMaskOptional bitmask of channels to write. Excluded color channels are set to
0.0; excluded alpha is set to1.0. Defaults toChannelMask.RGBA(all channels written).OptionaloutputOptions: ITextureProcessorOutputOptionsOptional render-target type, sampling, and mipmap settings.
Returns Promise<ITextureProcessOperand>
An operand whose
textureholds the GPU result, or whosefactorholds the CPU-folded constant - name: string
Extract the per-texel maximum channel value from a texture and broadcast it to all output channels, producing a single-value (greyscale) texture in a single GPU pass.
For each texel, computes
max(r, g, b)— ormax(r, g, b, a)whenincludeAlphais true — and writes that scalar to the output:includeAlpha = false(default): output is(m, m, m, a)wherem = max(r, g, b)includeAlpha = true: output is(m, m, m, m)wherem = max(r, g, b, a)This is more efficient than chaining
ExtractChannelAsynccalls throughMaxTexturesAsync, which would require multiple intermediate textures and GPU passes.Any
colorSpaceorchannelproperties on the input operand are honoured (sRGB linearization and channel swizzle applied before the max reduction).If the input is constant (no texture), the reduction is performed on the CPU.
When the input is the result of a previous operation (i.e. it carries a
disposefunction), its intermediate texture is automatically released after the GPU pass completes.