Skip to content

Commit

Permalink
fix: don't try to encode invalid sRGB textures (#2762)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Feb 16, 2023
1 parent 27d7164 commit 6a0ece0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/fiber/src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,13 @@ export function applyProps(instance: Instance, data: InstanceProps | DiffSet) {
currentInstance[key] = value
// Auto-convert sRGB textures, for now ...
// https://github.com/pmndrs/react-three-fiber/issues/344
if (!rootState.linear && currentInstance[key] instanceof THREE.Texture) {
if (
!rootState.linear &&
currentInstance[key] instanceof THREE.Texture &&
// sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
currentInstance[key].format === THREE.RGBAFormat &&
currentInstance[key].type === THREE.UnsignedByteType
) {
currentInstance[key].encoding = THREE.sRGBEncoding
}
}
Expand Down

0 comments on commit 6a0ece0

Please sign in to comment.