Skip to content

Commit

Permalink
fix(decode): changes usage of NoColorSpace to LinearSRGBColorSpace
Browse files Browse the repository at this point in the history
Better support of future `three` wide color gamut workflows by internally switching usage of
`NoColorSpace` to `LinearSRGBColorSpace`. Should not affect output
  • Loading branch information
daniele-pelagatti committed Nov 20, 2023
1 parent bc894c6 commit 587dc03
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/core/QuadRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
IntType,
LinearFilter,
LinearMipMapLinearFilter,
LinearSRGBColorSpace,
Material,
Mesh,
MeshBasicMaterial,
NoColorSpace,
OrthographicCamera,
PlaneGeometry,
RepeatWrapping,
Expand Down Expand Up @@ -87,7 +87,7 @@ const canReadPixels = (type: TextureDataType, renderer: WebGLRenderer, camera: O

const testRT = new WebGLRenderTarget(1, 1, {
type,
colorSpace: NoColorSpace,
colorSpace: LinearSRGBColorSpace,
format: RGBAFormat,
magFilter: LinearFilter,
minFilter: LinearFilter,
Expand Down Expand Up @@ -249,7 +249,7 @@ export class QuadRenderer<TType extends TextureDataType, TMaterial extends Mater
LinearFilter,
LinearMipMapLinearFilter,
1,
NoColorSpace
LinearSRGBColorSpace
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/get-data-texture.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataTexture, LinearFilter, NoColorSpace, RepeatWrapping, RGBAFormat, UVMapping } from 'three'
import { DataTexture, LinearFilter, LinearSRGBColorSpace, RepeatWrapping, RGBAFormat, UVMapping } from 'three'
import { EXR } from 'three/examples/jsm/loaders/EXRLoader'
import { LogLuv } from 'three/examples/jsm/loaders/LogLuvLoader'
import { RGBE } from 'three/examples/jsm/loaders/RGBELoader'
Expand Down Expand Up @@ -32,7 +32,7 @@ export const getDataTexture = (image: EXR | RGBE | LogLuv | DataTexture) => {
LinearFilter,
LinearFilter,
1,
'colorSpace' in image && image.colorSpace === 'srgb' ? image.colorSpace : NoColorSpace
'colorSpace' in image && image.colorSpace === 'srgb' ? image.colorSpace : LinearSRGBColorSpace
)

// TODO: This tries to detect a raw RGBE and applies flipY
Expand Down
10 changes: 5 additions & 5 deletions src/decode/decode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
HalfFloatType,
NoColorSpace,
LinearSRGBColorSpace,
SRGBColorSpace
} from 'three'

Expand Down Expand Up @@ -69,9 +69,9 @@ export const decode = (params: DecodeParameters): InstanceType<typeof QuadRender
}
sdr.needsUpdate = true

if (gainMap.colorSpace !== NoColorSpace) {
console.warn('Gainmap Colorspace needs to be *NoColorSpace*')
gainMap.colorSpace = NoColorSpace
if (gainMap.colorSpace !== LinearSRGBColorSpace) {
console.warn('Gainmap Colorspace needs to be *LinearSRGBColorSpace*')
gainMap.colorSpace = LinearSRGBColorSpace
}
gainMap.needsUpdate = true

Expand All @@ -82,7 +82,7 @@ export const decode = (params: DecodeParameters): InstanceType<typeof QuadRender
})
// TODO: three types are generic, eslint complains here, see how we can solve
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
const quadRenderer = new QuadRenderer(sdr.image.width, sdr.image.height, HalfFloatType, NoColorSpace, material, renderer)
const quadRenderer = new QuadRenderer(sdr.image.width, sdr.image.height, HalfFloatType, LinearSRGBColorSpace, material, renderer)
try {
quadRenderer.render()
} catch (e) {
Expand Down
6 changes: 3 additions & 3 deletions src/decode/loaders/LoaderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
HalfFloatType,
LinearFilter,
LinearMipMapLinearFilter,
LinearSRGBColorSpace,
Loader,
LoadingManager,
NoColorSpace,
RGBAFormat,
SRGBColorSpace,
Texture,
Expand Down Expand Up @@ -68,7 +68,7 @@ export class LoaderBase<TUrl = string> extends Loader<QuadRenderer<typeof HalfFl
16,
16,
HalfFloatType,
NoColorSpace,
LinearSRGBColorSpace,
material,
this.renderer
)
Expand Down Expand Up @@ -121,7 +121,7 @@ export class LoaderBase<TUrl = string> extends Loader<QuadRenderer<typeof HalfFl
RGBAFormat,
UnsignedByteType,
1,
NoColorSpace
LinearSRGBColorSpace
)

gainMap.flipY = needsFlip
Expand Down
4 changes: 2 additions & 2 deletions src/encode/get-gainmap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
NoColorSpace,
LinearSRGBColorSpace,
UnsignedByteType
} from 'three'

Expand All @@ -25,7 +25,7 @@ export const getGainMap = (params: { sdr: InstanceType<typeof QuadRenderer> } &
hdr: dataTexture
})

const quadRenderer = new QuadRenderer(dataTexture.image.width, dataTexture.image.height, UnsignedByteType, NoColorSpace, material, renderer)
const quadRenderer = new QuadRenderer(dataTexture.image.width, dataTexture.image.height, UnsignedByteType, LinearSRGBColorSpace, material, renderer)
try {
quadRenderer.render()
} catch (e) {
Expand Down

0 comments on commit 587dc03

Please sign in to comment.