-
Notifications
You must be signed in to change notification settings - Fork 5
encode.Function.encode
github-actions[bot] edited this page Sep 3, 2024
·
7 revisions
@monogrid/gainmap-js / encode / encode
encode(
params
):object
Encodes a Gainmap starting from an HDR file.
• params: EncodingParametersBase
Encoding Parameters
object
gainMap:
QuadRenderer
<1009
,GainMapEncoderMaterial
> =gainMapRenderer
getMetadata: () =>
GainMapMetadata
hdr:
DataTexture
=dataTexture
sdr:
QuadRenderer
<1009
,SDRMaterial
>
if you do not pass a renderer
parameter
you must manually dispose the result
const encodingResult = await encode({ ... })
// do something with the buffers
const sdr = encodingResult.sdr.getArray()
const gainMap = encodingResult.gainMap.getArray()
// after that
encodingResult.sdr.dispose()
encodingResult.gainMap.dispose()
import { encode, findTextureMinMax } from '@monogrid/gainmap-js'
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
// load an HDR file
const loader = new EXRLoader()
const image = await loader.loadAsync('image.exr')
// find RAW RGB Max value of a texture
const textureMax = await findTextureMinMax(image)
// Encode the gainmap
const encodingResult = encode({
image,
// this will encode the full HDR range
maxContentBoost: Math.max.apply(this, textureMax)
})
// can be re-encoded after changing parameters
encodingResult.sdr.material.exposure = 0.9
encodingResult.sdr.render()
// or
encodingResult.gainMap.material.gamma = [1.1, 1.1, 1.1]
encodingResult.gainMap.render()
// do something with encodingResult.gainMap.toArray()
// and encodingResult.sdr.toArray()
// renderers must be manually disposed
encodingResult.sdr.dispose()
encodingResult.gainMap.dispose()