Skip to content

Commit

Permalink
Editor: Fixed pathtracer render when environment is null.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Jan 30, 2024
1 parent 2b6dfe9 commit 1e771e1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion editor/js/Viewport.Pathtracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import {
PhysicalPathTracingMaterial
} from 'three-gpu-pathtracer';

function buildColorTexture( color ) {

const data = new Uint8Array( [ color.r * 255, color.g * 255, color.b * 255, 255 ] );
const texture = new THREE.DataTexture( data, 1, 1, THREE.RGBAFormat );
texture.needsUpdate = true;

return texture;

}

function ViewportPathtracer( renderer ) {

let pathtracer = null;
Expand Down Expand Up @@ -50,10 +60,16 @@ function ViewportPathtracer( renderer ) {
ptMaterial.materials.updateFrom( materials, textures );
ptMaterial.lights.updateFrom( lights );

if ( scene.environment && scene.environment.isTexture === true ) {
const environment = scene.environment;

if ( environment && environment.isTexture === true ) {

ptMaterial.envMapInfo.updateFrom( scene.environment );

} else {

ptMaterial.envMapInfo.updateFrom( buildColorTexture( new THREE.Color( 0xffffff ) ) );

}

}
Expand Down

0 comments on commit 1e771e1

Please sign in to comment.