fix(web): decode textures as sRGB in 3D viewers
TextureLoader leaves colorSpace as NoColorSpace, so card, tile, token, model, and part art is uploaded as linear and then double-decoded in the shader, washing out contrast. Mark each texture sRGB so the GPU decodes it once, correctly.
This commit is contained in:
@@ -83,6 +83,11 @@ function Tint({ root, tint }: { root: Object3D; tint: THREE.Color }) {
|
||||
function DiffuseTexture({ root, url }: { root: Object3D; url: string }) {
|
||||
const texture = useTexture(assetUrl(url));
|
||||
|
||||
// Diffuse art is sRGB-encoded; `TextureLoader` leaves `colorSpace` as
|
||||
// `NoColorSpace`, which double-decodes it in the shader and washes out
|
||||
// contrast. Mark it sRGB so the GPU decodes it once, correctly.
|
||||
texture.colorSpace = THREE.SRGBColorSpace;
|
||||
|
||||
// Apply the diffuse texture to every mesh material on the loaded model.
|
||||
useLayoutEffect(() => {
|
||||
root.traverse((child) => {
|
||||
|
||||
Reference in New Issue
Block a user