-
Notifications
You must be signed in to change notification settings - Fork 9
decode
- GainMapMetadata
- HDRJPGLoader
- QuadRenderer
- QuadRendererOptions
- QuadRendererTextureOptions
- TextureDataTypeToBufferType
Ƭ DecodeParameters: { gainMap
: Texture
; renderTargetOptions?
: QuadRendererTextureOptions
; renderer?
: WebGLRenderer
; sdr
: Texture
} & GainmapDecodingParameters
& GainMapMetadata
▸ decode(params
): QuadRenderer
<1016
, GainMapDecoderMaterial
>
Decodes a gain map using a WebGLRenderTarget
Name | Type |
---|---|
params |
DecodeParameters |
QuadRenderer
<1016
, GainMapDecoderMaterial
>
Example
import { decode } from '@monogrid/gainmap-js'
import {
Mesh,
MeshBasicMaterial,
PerspectiveCamera,
PlaneGeometry,
Scene,
TextureLoader,
WebGLRenderer
} from 'three'
const renderer = new WebGLRenderer()
const textureLoader = new TextureLoader()
// load SDR Representation
const sdr = await textureLoader.loadAsync('sdr.jpg')
// load Gain map recovery image
const gainMap = await textureLoader.loadAsync('gainmap.jpg')
// load metadata
const metadata = await (await fetch('metadata.json')).json()
const result = await decode({
sdr,
gainMap,
// this allows to use `result.renderTarget.texture` directly
renderer,
// this will restore the full HDR range
maxDisplayBoost: Math.pow(2, metadata.hdrCapacityMax),
...metadata
})
const scene = new Scene()
// `result` can be used to populate a Texture
const mesh = new Mesh(
new PlaneGeometry(),
new MeshBasicMaterial({ map: result.renderTarget.texture })
)
scene.add(mesh)
renderer.render(scene, new PerspectiveCamera())
// result must be manually disposed
// when you are done using it
result.dispose()
Throws
if the WebGLRenderer fails to render the gain map
▸ extractGainmapFromJPEG(jpegFile
): Promise
<{ gainMap
: Uint8Array
; metadata
: GainMapMetadata
; sdr
: Uint8Array
}>
Extracts XMP Metadata and the gain map recovery image from a single JPEG file.
Name | Type | Description |
---|---|---|
jpegFile |
Uint8Array |
an Uint8Array containing and encoded JPEG file |
Promise
<{ gainMap
: Uint8Array
; metadata
: GainMapMetadata
; sdr
: Uint8Array
}>
an sdr Uint8Array
compressed in JPEG, a gainMap Uint8Array
compressed in JPEG and the XMP parsed XMP metadata
Throws
Error if XMP Metadata is not found
Throws
Error if Gain map image is not found
Example
import { FileLoader } from 'three'
import { extractGainmapFromJPEG } from '@monogrid/gainmap-js'
const jpegFile = await new FileLoader()
.setResponseType('arraybuffer')
.loadAsync('image.jpg')
const { sdr, gainMap, metadata } = extractGainmapFromJPEG(jpegFile)
Re-exports GainMapMetadata
Renames and re-exports JPEGRLoader
Re-exports QuadRenderer
Re-exports QuadRendererOptions
Re-exports QuadRendererTextureOptions
Re-exports TextureDataTypeToBufferType
Ƭ GainmapDecodingParameters: Object
Necessary parameters for decoding a Gainmap
Name | Type | Description |
---|---|---|
maxDisplayBoost |
number |
The maximum available boost supported by a display, at a given point in time. Remarks This value can change over time based on device settings and other factors, such as ambient light conditions, or how many bright pixels are on the screen. Non Logarithmic space |