import { type Node, type UniformNode, Vector3 } from 'three/webgpu'; import { type GainMapMetadata } from '../../../core/types'; import { RenderTargetNode } from '../../../core/webgpu/RenderTargetNode'; import { type GainmapEncodingParameters } from '../../types'; import { SDRRenditionNode } from './SDRRenditionNode'; /** * Uniforms driving a {@link GainMapEncoderNode} */ export type GainMapEncoderNodeUniforms = { gamma: UniformNode<'vec3', Vector3>; offsetSdr: UniformNode<'vec3', Vector3>; offsetHdr: UniformNode<'vec3', Vector3>; minContentBoost: UniformNode<'float', number>; maxContentBoost: UniformNode<'float', number>; }; /** * A TSL texture node holding the gain map (recovery map) of an HDR image: the second step of gain map encoding. * * The gain map is computed from the HDR input of a {@link SDRRenditionNode} and its SDR rendition, * into an 8 bit linear render target. The result is identical to the one of the WebGL `GainMapEncoderMaterial`. * * It renders only when something changed (the SDR rendition or any uniform value), * the SDR rendition is rendered first when needed. * * @category Nodes * @group Nodes * * @example * import { GainMapEncoderNode, SDRRenditionNode } from '@monogrid/gainmap-js/encode/webgpu' * * const sdr = new SDRRenditionNode(hdrTexture) * const gainMap = new GainMapEncoderNode(sdr, { maxContentBoost: 8 }) * * material.colorNode = gainMap * gainMap.gamma.value.setScalar(1.2) // renders again once, on the next frame * const metadata = gainMap.metadata */ export declare class GainMapEncoderNode extends RenderTargetNode { static get type(): string; /** * The SDR rendition this gain map is computed from */ readonly sdr: SDRRenditionNode; /** * Shared uniforms */ readonly uniforms: GainMapEncoderNodeUniforms; /** * The linear gain of each pixel, `(hdr + offsetHdr) / (sdr + offsetSdr)`, before it's clamped * to the content boost range and encoded */ readonly pixelGain: Node<'vec3'>; private _warned; /** * @param sdr the SDR rendition, its HDR input is the HDR input of the gain map * @param params encoding parameters, all of them can be changed later through the uniforms */ constructor(sdr: SDRRenditionNode, params?: Partial); /** @see {@link GainmapEncodingParameters.gamma} */ get gamma(): UniformNode<"vec3", Vector3>; /** @see {@link GainmapEncodingParameters.offsetSdr} */ get offsetSdr(): UniformNode<"vec3", Vector3>; /** @see {@link GainmapEncodingParameters.offsetHdr} */ get offsetHdr(): UniformNode<"vec3", Vector3>; /** * @see {@link GainmapEncodingParameters.minContentBoost} * @remarks Non logarithmic space */ get minContentBoost(): UniformNode<"float", number>; /** * @see {@link GainmapEncodingParameters.maxContentBoost} * @remarks Non logarithmic space, values <= 1 are clamped to 1.0001 since a gain map can't encode an empty boost range */ get maxContentBoost(): UniformNode<"float", number>; /** Same size as the SDR rendition */ get width(): number; /** Same size as the SDR rendition */ get height(): number; /** The min content boost actually encoded */ private get metadataMinContentBoost(); /** The max content boost actually encoded, clamped to a valid range */ private get metadataMaxContentBoost(); /** * The gain map metadata matching the current uniform values */ get metadata(): GainMapMetadata; protected _getState(): number[]; protected _getDependencies(): SDRRenditionNode[]; protected _onRender(): void; } /** * TSL function creating a {@link GainMapEncoderNode} * * @param sdr the SDR rendition, its HDR input is the HDR input of the gain map * @param params encoding parameters */ export declare const gainMapEncoder: (sdr: SDRRenditionNode, params?: Partial) => GainMapEncoderNode & Node;