Skip to content

Commit 488b510

Browse files
committed
Label and convert textures and colors correctly in MTLLoader
1 parent 84f3e57 commit 488b510

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

examples/jsm/loaders/MTLLoader.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
MeshPhongMaterial,
99
RepeatWrapping,
1010
TextureLoader,
11-
Vector2
11+
Vector2,
12+
sRGBEncoding
1213
} from 'three';
1314

1415
/**
@@ -358,6 +359,12 @@ class MaterialCreator {
358359
map.wrapS = scope.wrap;
359360
map.wrapT = scope.wrap;
360361

362+
if ( mapType === 'map' || mapType === 'emissiveMap' ) {
363+
364+
map.encoding = sRGBEncoding;
365+
366+
}
367+
361368
params[ mapType ] = map;
362369

363370
}
@@ -377,21 +384,21 @@ class MaterialCreator {
377384

378385
// Diffuse color (color under white light) using RGB values
379386

380-
params.color = new Color().fromArray( value );
387+
params.color = new Color().fromArray( value ).convertSRGBToLinear();
381388

382389
break;
383390

384391
case 'ks':
385392

386393
// Specular color (color when light is reflected from shiny surface) using RGB values
387-
params.specular = new Color().fromArray( value );
394+
params.specular = new Color().fromArray( value ).convertSRGBToLinear();
388395

389396
break;
390397

391398
case 'ke':
392399

393400
// Emissive using RGB values
394-
params.emissive = new Color().fromArray( value );
401+
params.emissive = new Color().fromArray( value ).convertSRGBToLinear();
395402

396403
break;
397404

examples/webgl_loader_obj_mtl.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
//
106106

107107
renderer = new THREE.WebGLRenderer();
108+
renderer.outputEncoding = THREE.sRGBEncoding;
108109
renderer.setPixelRatio( window.devicePixelRatio );
109110
renderer.setSize( window.innerWidth, window.innerHeight );
110111
container.appendChild( renderer.domElement );

0 commit comments

Comments
 (0)