|
@@ -48,8 +48,8 @@
|
|
"three": "../build/three.module.js",
|
|
"three": "../build/three.module.js",
|
|
"three/addons/": "./jsm/",
|
|
"three/addons/": "./jsm/",
|
|
"three/examples/": "./",
|
|
"three/examples/": "./",
|
|
- "three-gpu-pathtracer": "https://unpkg.com/[email protected].7/build/index.module.js",
|
|
|
|
- "three-mesh-bvh": "https://unpkg.com/three-mesh-bvh@^0.5.10/build/index.module.js"
|
|
|
|
|
|
+ "three-gpu-pathtracer": "https://unpkg.com/[email protected].11/build/index.module.js",
|
|
|
|
+ "three-mesh-bvh": "https://unpkg.com/three-mesh-bvh@^0.5.21/build/index.module.js"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
@@ -66,7 +66,7 @@
|
|
import { LDrawUtils } from 'three/addons/utils/LDrawUtils.js';
|
|
import { LDrawUtils } from 'three/addons/utils/LDrawUtils.js';
|
|
import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';
|
|
import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';
|
|
|
|
|
|
- import { PhysicalPathTracingMaterial, PathTracingRenderer, MaterialReducer, BlurredEnvMapGenerator, PathTracingSceneGenerator } from 'three-gpu-pathtracer';
|
|
|
|
|
|
+ import { PhysicalPathTracingMaterial, PathTracingRenderer, MaterialReducer, BlurredEnvMapGenerator, PathTracingSceneGenerator, GradientEquirectTexture } from 'three-gpu-pathtracer';
|
|
|
|
|
|
let progressBarDiv, samplesEl;
|
|
let progressBarDiv, samplesEl;
|
|
let camera, scene, renderer, controls, gui;
|
|
let camera, scene, renderer, controls, gui;
|
|
@@ -114,10 +114,14 @@
|
|
pathTracer.alpha = true;
|
|
pathTracer.alpha = true;
|
|
pathTracer.tiles.set( params.tiles, params.tiles );
|
|
pathTracer.tiles.set( params.tiles, params.tiles );
|
|
pathTracer.material = new PhysicalPathTracingMaterial();
|
|
pathTracer.material = new PhysicalPathTracingMaterial();
|
|
- pathTracer.material.setDefine( 'FEATURE_GRADIENT_BG', 1 );
|
|
|
|
pathTracer.material.setDefine( 'FEATURE_MIS', 1 );
|
|
pathTracer.material.setDefine( 'FEATURE_MIS', 1 );
|
|
- pathTracer.material.bgGradientTop.set( 0xeeeeee );
|
|
|
|
- pathTracer.material.bgGradientBottom.set( 0xeaeaea );
|
|
|
|
|
|
+
|
|
|
|
+ const gradientMap = new GradientEquirectTexture();
|
|
|
|
+ gradientMap.topColor.set( 0xeeeeee );
|
|
|
|
+ gradientMap.bottomColor.set( 0xeaeaea );
|
|
|
|
+ gradientMap.update();
|
|
|
|
+
|
|
|
|
+ pathTracer.material.backgroundMap = gradientMap;
|
|
pathTracer.camera = camera;
|
|
pathTracer.camera = camera;
|
|
|
|
|
|
fsQuad = new FullScreenQuad( new THREE.MeshBasicMaterial( {
|
|
fsQuad = new FullScreenQuad( new THREE.MeshBasicMaterial( {
|
|
@@ -260,11 +264,13 @@
|
|
const material = pathTracer.material;
|
|
const material = pathTracer.material;
|
|
|
|
|
|
material.bvh.updateFrom( bvh );
|
|
material.bvh.updateFrom( bvh );
|
|
- material.normalAttribute.updateFrom( geometry.attributes.normal );
|
|
|
|
- material.tangentAttribute.updateFrom( geometry.attributes.tangent );
|
|
|
|
- material.uvAttribute.updateFrom( geometry.attributes.uv );
|
|
|
|
|
|
+ material.attributesArray.updateFrom(
|
|
|
|
+ geometry.attributes.normal,
|
|
|
|
+ geometry.attributes.tangent,
|
|
|
|
+ geometry.attributes.uv,
|
|
|
|
+ geometry.attributes.color,
|
|
|
|
+ );
|
|
material.materialIndexAttribute.updateFrom( geometry.attributes.materialIndex );
|
|
material.materialIndexAttribute.updateFrom( geometry.attributes.materialIndex );
|
|
- // material.colorAttribute.updateFrom( geometry.attributes.color );
|
|
|
|
material.textures.setTextures( renderer, 2048, 2048, textures );
|
|
material.textures.setTextures( renderer, 2048, 2048, textures );
|
|
material.materials.updateFrom( materials, textures );
|
|
material.materials.updateFrom( materials, textures );
|
|
pathTracer.material.envMapInfo.updateFrom( envMap );
|
|
pathTracer.material.envMapInfo.updateFrom( envMap );
|