From f75cbd1e115c606c82ebba5dc44f149f8779d8b7 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Mon, 31 Jan 2022 11:15:20 -0800 Subject: [PATCH] Adjust OBJExporter to convert Linear colors to sRGB (#23374) --- examples/jsm/exporters/OBJExporter.js | 2 +- examples/misc_exporter_obj.html | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/jsm/exporters/OBJExporter.js b/examples/jsm/exporters/OBJExporter.js index b2136096120287..d7f83a8ca0df0b 100644 --- a/examples/jsm/exporters/OBJExporter.js +++ b/examples/jsm/exporters/OBJExporter.js @@ -251,7 +251,7 @@ class OBJExporter { if ( colors !== undefined ) { - color.fromBufferAttribute( colors, i ); + color.fromBufferAttribute( colors, i ).convertLinearToSRGB(); output += ' ' + color.r + ' ' + color.g + ' ' + color.b; diff --git a/examples/misc_exporter_obj.html b/examples/misc_exporter_obj.html index a5d21eee6980c0..d186cc54ea1d8c 100644 --- a/examples/misc_exporter_obj.html +++ b/examples/misc_exporter_obj.html @@ -130,7 +130,7 @@ } else if ( type === 6 ) { const points = [ 0, 0, 0, 100, 0, 0, 100, 100, 0, 0, 100, 0 ]; - const colors = [ 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ]; + const colors = [ 0.5, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0.5, 0 ]; const geometry = new THREE.BufferGeometry(); geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( points, 3 ) ); @@ -149,6 +149,7 @@ function init() { renderer = new THREE.WebGLRenderer(); + renderer.outputEncoding = THREE.sRGBEncoding; renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement );