Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

Commit 1c74955

Browse files
committed
Convert material colors from linear to sRGB.
1 parent 154f9cd commit 1c74955

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

viewer/lib/playcanvas-gltf.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@
347347

348348
if (pbrData.hasOwnProperty('baseColorFactor')) {
349349
color = pbrData.baseColorFactor;
350-
material.diffuse.set(color[0], color[1], color[2]);
350+
// Convert from linear space to sRGB space
351+
material.diffuse.set(Math.pow(color[0], 1 / 2.2), Math.pow(color[1], 1 / 2.2), Math.pow(color[2], 1 / 2.2));
351352
material.opacity = color[3];
352353
} else {
353354
material.diffuse.set(1, 1, 1);
@@ -410,7 +411,8 @@
410411
}
411412
if (data.hasOwnProperty('emissiveFactor')) {
412413
color = data.emissiveFactor;
413-
material.emissive.set(color[0], color[1], color[2]);
414+
// Convert from linear space to sRGB space
415+
material.emissive.set(Math.pow(color[0], 1 / 2.2), Math.pow(color[1], 1 / 2.2), Math.pow(color[2], 1 / 2.2));
414416
material.emissiveTint = true;
415417
} else {
416418
material.emissive.set(0, 0, 0);

0 commit comments

Comments
 (0)