Skip to content

Commit

Permalink
Adjust OBJExporter to convert Linear colors to sRGB (#23374)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson authored Jan 31, 2022
1 parent a2cc7c1 commit f75cbd1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/jsm/exporters/OBJExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion examples/misc_exporter_obj.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand All @@ -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 );
Expand Down

0 comments on commit f75cbd1

Please sign in to comment.