Skip to content

Commit

Permalink
fix(encode): encodes a valid image when an invalid tonemapping value …
Browse files Browse the repository at this point in the history
…was provided as input
  • Loading branch information
daniele-pelagatti committed Dec 5, 2023
1 parent b425943 commit 94cec23
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/encode/materials/SDRMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,32 @@ export class SDRMaterial extends ShaderMaterial {

get toneMapping () { return this._toneMapping }
set toneMapping (value: ToneMapping) {
let valid = false
switch (value) {
case ACESFilmicToneMapping:
this.defines.TONEMAPPING_FUNCTION = 'ACESFilmicToneMapping'
valid = true
break
case ReinhardToneMapping:
this.defines.TONEMAPPING_FUNCTION = 'ReinhardToneMapping'
valid = true
break
case CineonToneMapping:
this.defines.TONEMAPPING_FUNCTION = 'CineonToneMapping'
valid = true
break
case LinearToneMapping:
this.defines.TONEMAPPING_FUNCTION = 'LinearToneMapping'
valid = true
break
default:
console.error('Unsupported toneMapping')
return
console.error(`Unsupported toneMapping: ${value}. Using LinearToneMapping.`)
this.defines.TONEMAPPING_FUNCTION = 'LinearToneMapping'
this._toneMapping = LinearToneMapping
}
if (valid) {
this._toneMapping = value
}
this._toneMapping = value
this.needsUpdate = true
}

Expand Down

0 comments on commit 94cec23

Please sign in to comment.