Skip to content

Commit 34d2799

Browse files
donmccurdyMugen87
authored andcommitted
Examples: Updates for color management (pt3) (mrdoob#25889)
* LWOLoader: Updates for color management * MMDLoader: Updates for color management * Examples: Update more loader examples for color management --------- Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
1 parent 5614fa9 commit 34d2799

22 files changed

+50
-63
lines changed

examples/jsm/loaders/LWOLoader.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
Points,
3636
PointsMaterial,
3737
RepeatWrapping,
38+
SRGBColorSpace,
3839
TextureLoader,
3940
Vector2
4041
} from 'three';
@@ -464,17 +465,20 @@ class MaterialParser {
464465

465466
case 'Color':
466467
maps.map = texture;
468+
maps.map.colorSpace = SRGBColorSpace;
467469
break;
468470
case 'Roughness':
469471
maps.roughnessMap = texture;
470472
maps.roughness = 1;
471473
break;
472474
case 'Specular':
473475
maps.specularMap = texture;
476+
maps.specularMap.colorSpace = SRGBColorSpace;
474477
maps.specular = 0xffffff;
475478
break;
476479
case 'Luminous':
477480
maps.emissiveMap = texture;
481+
maps.emissiveMap.colorSpace = SRGBColorSpace;
478482
maps.emissive = 0x808080;
479483
break;
480484
case 'Luminous Color':
@@ -532,6 +536,7 @@ class MaterialParser {
532536

533537
case 'Color':
534538
maps.map = texture;
539+
maps.map.colorSpace = SRGBColorSpace;
535540
break;
536541
case 'Diffuse':
537542
maps.aoMap = texture;
@@ -542,10 +547,12 @@ class MaterialParser {
542547
break;
543548
case 'Specular':
544549
maps.specularMap = texture;
550+
maps.specularMap.colorSpace = SRGBColorSpace;
545551
maps.specular = 0xffffff;
546552
break;
547553
case 'Luminosity':
548554
maps.emissiveMap = texture;
555+
maps.emissiveMap.colorSpace = SRGBColorSpace;
549556
maps.emissive = 0x808080;
550557
break;
551558
case 'Metallic':
@@ -581,7 +588,11 @@ class MaterialParser {
581588

582589
params.color = new Color().fromArray( attributes.Color.value );
583590

584-
} else params.color = new Color();
591+
} else {
592+
593+
params.color = new Color();
594+
595+
}
585596

586597

587598
if ( attributes.Transparency && attributes.Transparency.value !== 0 ) {

examples/jsm/loaders/MMDLoader.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Bone,
55
BufferGeometry,
66
Color,
7+
ColorManagement,
78
CustomBlending,
89
TangentSpaceNormalMap,
910
DoubleSide,
@@ -1108,6 +1109,14 @@ class MaterialBuilder {
11081109
params.emissive = new Color().fromArray( material.ambient );
11091110
params.transparent = params.opacity !== 1.0;
11101111

1112+
if ( ColorManagement.enabled === true ) {
1113+
1114+
params.diffuse.convertSRGBToLinear();
1115+
params.specular.convertSRGBToLinear();
1116+
params.emissive.convertSRGBToLinear();
1117+
1118+
}
1119+
11111120
//
11121121

11131122
params.fog = true;
-741 Bytes
Loading
137 Bytes
Loading
-661 Bytes
Loading
-143 Bytes
Loading
-785 Bytes
Loading
-1.94 KB
Loading

examples/webgl_geometry_extrude_shapes2.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838

3939
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
4040

41-
THREE.ColorManagement.enabled = false; // TODO: Confirm correct color management.
42-
4341
// From d3-threeD.js
4442
/* This Source Code Form is subject to the terms of the Mozilla Public
4543
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
@@ -443,7 +441,6 @@
443441
renderer = new THREE.WebGLRenderer( { antialias: true } );
444442
renderer.setPixelRatio( window.devicePixelRatio );
445443
renderer.setSize( window.innerWidth, window.innerHeight );
446-
renderer.outputColorSpace = THREE.LinearSRGBColorSpace;
447444
container.appendChild( renderer.domElement );
448445

449446
//

examples/webgl_loader_collada_kinematics.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import TWEEN from 'three/addons/libs/tween.module.js';
3535
import { ColladaLoader } from 'three/addons/loaders/ColladaLoader.js';
3636

37-
THREE.ColorManagement.enabled = false; // TODO: Consider enabling color management.
38-
3937
let container, stats;
4038

4139
let camera, scene, renderer;
@@ -84,7 +82,7 @@
8482

8583
// Grid
8684

87-
const grid = new THREE.GridHelper( 20, 20, 0x888888, 0x444444 );
85+
const grid = new THREE.GridHelper( 20, 20, 0xc1c1c1, 0x8d8d8d );
8886
scene.add( grid );
8987

9088
// Add the COLLADA
@@ -96,7 +94,7 @@
9694

9795
// Lights
9896

99-
const light = new THREE.HemisphereLight( 0xffeeee, 0x111122 );
97+
const light = new THREE.HemisphereLight( 0xfff7f7, 0x494966 );
10098
scene.add( light );
10199

102100
const pointLight = new THREE.PointLight( 0xffffff, 0.3 );

0 commit comments

Comments
 (0)