Repository navigation
decode.webgpu.Class.GainMapNode
@monogrid/gainmap-js / decode/webgpu / GainMapNode
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:74
A TSL texture node holding the HDR image decoded from an SDR image + gain map.
The decode runs on the GPU into a HalfFloat render target, and only when something changed (textures loaded/swapped or any uniform value changed): sampling the node costs a single texture read, like any other texture.
The node updates itself before rendering whenever it is part of a rendered node graph
(material, scene.backgroundNode, ...). When only its texture is used (node.value,
e.g. scene.environment = node.value) call GainMapNode.decode yourself.
Re-decoding also flags the texture for PMREM regeneration, so environment maps are recomputed only when the image actually changes.
node.value gets its final size once loaded: three.js PMREMs don't follow texture resizes,
so assign it to scene.environment (or pmremTexture()) after load.
import { GainMapNode } from '@monogrid/gainmap-js/webgpu'
import { equirectUV } from 'three/tsl'
const hdr = new GainMapNode()
.setTextures(sdrTexture, gainMapTexture)
.setMetadata(metadata)
material.colorNode = hdr
scene.backgroundNode = hdr.sample(equirectUV())
hdr.maxDisplayBoost.value = 2 // re-decodes once, on the next frameTextureNode
new GainMapNode():
GainMapNode
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:93
GainMapNode
TextureNode.constructor
readonlyrenderTarget:RenderTarget
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:85
The render target holding the decoded HDR image
readonlyuniforms:GainMapNodeUniforms
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:80
Shared textures and uniforms
get gainMap():
Texture<unknown,TextureEventMap>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:134
The gain map recovery texture (linear)
Texture<unknown, TextureEventMap>
get gainMapMax():
UniformNode<"vec3",Vector3>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:145
UniformNode<"vec3", Vector3>
get gainMapMin():
UniformNode<"vec3",Vector3>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:143
UniformNode<"vec3", Vector3>
get gamma():
UniformNode<"vec3",Vector3>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:137
UniformNode<"vec3", Vector3>
get hdrCapacityMax():
UniformNode<"float",number>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:149
GainMapMetadata.hdrCapacityMax
UniformNode<"float", number>
get hdrCapacityMin():
UniformNode<"float",number>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:147
GainMapMetadata.hdrCapacityMin
UniformNode<"float", number>
get height():
number
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:159
Height of the SDR image, 0 until loaded
number
get maxDisplayBoost():
UniformNode<"float",number>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:154
GainmapDecodingParameters.maxDisplayBoost
Non Logarithmic space
UniformNode<"float", number>
get offsetHdr():
UniformNode<"vec3",Vector3>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:141
UniformNode<"vec3", Vector3>
get offsetSdr():
UniformNode<"vec3",Vector3>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:139
UniformNode<"vec3", Vector3>
get sdr():
Texture<unknown,TextureEventMap>
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:132
The SDR rendition texture (sRGB)
Texture<unknown, TextureEventMap>
get value():
Texture
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:246
Texture
set value(
value):void
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:240
Texture
void
TextureNode.value
get width():
number
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:157
Width of the SDR image, 0 until loaded
number
get
statictype():string
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:75
The type of the class. The value is usually the constructor name.
string
clone():
GainMapNode
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:254
Clones created by sample() & co. are plain TextureNodes reading this node's texture,
they keep it updated before rendering as well
GainMapNode
TextureNode.clone
decode(
renderer):boolean
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:213
Decodes the image into GainMapNode.renderTarget, only if something changed since the last decode.
Called automatically when the node is part of a rendered node graph.
WebGPURenderer
boolean
true if the image was decoded
dispose():
void
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:265
Disposes the render target, the SDR and gain map textures
void
TextureNode.dispose
setMetadata(
metadata):GainMapNode
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:182
Copies the gain map metadata into the uniforms.
Also sets maxDisplayBoost to fully restore the HDR range.
GainMapNode
setTextures(
sdr,gainMap):GainMapNode
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:168
Sets the SDR and gain map textures. The SDR texture is expected in sRGB color space, the gain map in linear.
Texture
Texture
GainMapNode
updateBefore(
frame):undefined
Defined in: src/decode/webgpu/nodes/GainMapNode.ts:235
Calls GainMapNode.decode once per render, before the node is evaluated.
NodeFrame
undefined
TextureNode.updateBefore