import { type Node, Texture, type ToneMapping, type UniformNode } from 'three/webgpu'; import { RenderTargetNode } from '../../../core/webgpu/RenderTargetNode'; /** * HDR input of the encoder: a texture or any TSL node returning a linear HDR color (vec3 or vec4) * * Nodes are evaluated on a full screen quad, `uv()` spans the whole output image. * * @category Encoding Parameters * @group Encoding Parameters */ export type HDRInput = Texture | Node; /** * Options of a {@link SDRRenditionNode} * * @category Encoding Parameters * @group Encoding Parameters */ export type SDRRenditionNodeOptions = { /** * Tone mapping applied to the SDR rendition * @defaultValue `ACESFilmicToneMapping` */ toneMapping?: ToneMapping; /** * Width of the output, required when the HDR input is a generic node * (textures and texture nodes provide their own size) */ width?: number; /** * Height of the output, required when the HDR input is a generic node * (textures and texture nodes provide their own size) */ height?: number; }; /** * Uniforms driving a {@link SDRRenditionNode} */ export type SDRRenditionNodeUniforms = { exposure: UniformNode<'float', number>; brightness: UniformNode<'float', number>; contrast: UniformNode<'float', number>; saturation: UniformNode<'float', number>; }; /** * A TSL texture node holding the SDR rendition of an HDR image: the first step of gain map encoding. * * The HDR input is exposed, tone mapped (with the three.js TSL tone mapping functions) * and adjusted (brightness, contrast, saturation) into an 8 bit sRGB render target. * * It renders only when something changed (input, tone mapping or any uniform value): * sampling the node costs a single texture read, like any other texture. * * @category Nodes * @group Nodes * * @example * import { SDRRenditionNode } from '@monogrid/gainmap-js/encode/webgpu' * import { AgXToneMapping, LinearToneMapping } from 'three/webgpu' * * const sdr = new SDRRenditionNode(hdrTexture, { toneMapping: AgXToneMapping }) * material.colorNode = sdr * sdr.exposure.value = 0.8 // renders again once, on the next frame * sdr.setToneMapping(LinearToneMapping) */ export declare class SDRRenditionNode extends RenderTargetNode { static get type(): string; /** * The HDR input, as a node */ readonly hdr: Node; /** * Shared uniforms */ readonly uniforms: SDRRenditionNodeUniforms; private _hdrTexture; private _hdrSource; private _width; private _height; private _toneMapping; /** * @param hdr HDR input, a texture or a TSL node returning a linear HDR color * @param options * @throws {Error} if the input is a generic node and `width` or `height` are not provided */ constructor(hdr: HDRInput, options?: SDRRenditionNodeOptions); /** Exposure applied to the HDR input before tone mapping */ get exposure(): UniformNode<"float", number>; /** Brightness offset applied after tone mapping */ get brightness(): UniformNode<"float", number>; /** Contrast applied after tone mapping */ get contrast(): UniformNode<"float", number>; /** Saturation applied after tone mapping */ get saturation(): UniformNode<"float", number>; /** * The tone mapping applied to the SDR rendition */ getToneMapping(): ToneMapping; /** * Sets the tone mapping applied to the SDR rendition * (`toneMapping` can't be used as a property name: it's a TSL method of every node) * * @param value any three.js tone mapping, e.g. `ACESFilmicToneMapping`, `AgXToneMapping`, `NeutralToneMapping` * or `LinearToneMapping` (which keeps the SDR rendition closest to the HDR input) */ setToneMapping(value: ToneMapping): this; /** Width of the output, 0 while the input texture is not loaded */ get width(): number; /** Height of the output, 0 while the input texture is not loaded */ get height(): number; private _buildOutput; protected _getState(): (number | undefined)[]; protected _getDependencies(): RenderTargetNode[]; } /** * TSL function creating a {@link SDRRenditionNode} * * @param hdr HDR input, a texture or a TSL node returning a linear HDR color * @param options */ export declare const sdrRendition: (hdr: HDRInput, options?: SDRRenditionNodeOptions) => SDRRenditionNode & Node;