Hi @gkjohnson, thank you very much for your response. My apologies if my question was not clear, I’m very new to Three.js and 3D.
I would like to ask some questions to clarify my path. ‘Material model’ means the materials implemented by three-gpu-pathtracing library, right?
‘Emissive materials’ means materials with the emissive property being enabled? In that case, the material lighting is independent from the outside lighting, right?
I’ve been trying to use this library for a project that allows the user to dinamically position GLB on a scene, to later click a button and render the scene with path tracing. This project does not use react-three-fiber, it uses plain React and Three, and I’m losing my mind on how to implement it. Could I get some help? This is how my render function looks like.
// My function to setup path tracing..
setupPathTracing () {
this.ptMaterial = new PhysicalPathTracingMaterial();
this.ptRenderer = new PathTracingRenderer( this.renderer );
this.ptRenderer.setSize( window.innerWidth, window.innerHeight );
this.ptRenderer.camera = this.camera;
this.ptRenderer.material = this.ptMaterial;
this.fsQuad = new FullScreenQuad( new MeshBasicMaterial( {
map: this.ptRenderer.target.texture
} ) );
this.scene3D.updateMatrixWorld();
this.generator = new PathTracingSceneGenerator();
// this.generator = new DynamicPathTracingSceneGenerator();
const { bvh, textures, materials, lights } = this.generator.generate( this.scene3D );
const geometry = bvh.geometry;
this.ptMaterial.bvh.updateFrom( bvh );
// update bvh and geometry attribute textures
this.ptMaterial.bvh.updateFrom( bvh );
this.ptMaterial.attributesArray.updateFrom(
geometry.attributes.normal,
geometry.attributes.tangent,
geometry.attributes.uv,
geometry.attributes.color,
);
// update materials and texture arrays
this.ptMaterial.materialIndexAttribute.updateFrom( geometry.attributes.materialIndex );
this.ptMaterial.textures.setTextures( this.renderer, 2048, 2048, textures );
this.ptMaterial.materials.updateFrom( materials, textures );
// update the lights
this.ptMaterial.lights.updateFrom( lights );
};
// Use this instead of usual render if path tracing mode is enabled
renderWithPathTracing () {
this.ptRenderer.reset();
this.camera.updateMatrixWorld();
this.ptRenderer.update();
// if using alpha = true then the target texture will change every frame
// so we must retrieve it before render.
this.fsQuad.material.map = this.ptRenderer.target.texture;
// copy the current state of the path tracer to canvas to display
this.fsQuad.render( this.renderer );
};
...
// Render loop inside componentDidUpdate
let render = () => {
//** UPDATE CAMERAS */
orbitController.update();
this.camera.updateMatrix();
this.camera.updateMatrixWorld();
cubeCamera.update( this.renderer, this.scene3D );
for ( let elemID in planData.sceneGraph.LODs ) {
planData.sceneGraph.LODs[ elemID ].update( this.camera );
}
if ( this.props.isPathTracing ) {
if ( this.ptRenderer === null || this.ptMaterial === null ) {
this.setupPathTracing();
}
this.renderWithPathTracing();
} else {
this.renderer.render( this.scene3D, this.camera );
}
this.renderingID = requestAnimationFrame( render );
};
render();
When I execute this and I enable path tracing mode, the render view turns black and I get the following error on console:
three.module.js:19016 THREE.WebGLProgram: Program Info Log: C:\fakepath(3817,10-36): warning X3577: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed
C:\fakepath(3817,10-36): warning X3577: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed
C:\fakepath(1329,1-6): warning X4000: use of potentially uninitialized variable (dyn_index_vec3_int)
error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Index Dimension 1 out of range (4904 specified, max allowed is 31) for operand #2 of opcode #5078 (counts are 1-based). Aborting.
error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Can't continue validation - aborting.
Warning: D3D shader compilation failed with default flags. (ps_5_0)
Retrying with skip validation
C:\fakepath(3817,10-36): warning X3577: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed
C:\fakepath(3817,10-36): warning X3577: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed
C:\fakepath(1329,1-6): warning X4000: use of potentially uninitialized variable (dyn_index_vec3_int)
error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Index Dimension 1 out of range (4904 specified, max allowed is 31) for operand #2 of opcode #5078 (counts are 1-based). Aborting.
error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Can't continue validation - aborting.
Warning: D3D shader compilation failed with skip validation flags. (ps_5_0)
Retrying with skip optimization
C:\fakepath(3817,10-36): warning X3577: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed
C:\fakepath(3817,10-36): warning X3577: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed
C:\fakepath(3817,10-36): warning X3577: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed
C:\fakepath(3817,10-36): warning X3577: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed
C:\fakepath(1329,1-6): warning X4000: use of potentially uninitialized variable (dyn_index_vec3_int)
C:\fakepath(2160,1): warning X4000: use of potentially uninitialized variable (f_intersectsRectangle)
C:\fakepath(2161,1): warning X4000: use of potentially uninitialized variable (f_intersectsRectangle)
C:\fakepath(2162,1): warning X4000: use of potentially uninitialized variable (f_intersectsRectangle)
C:\fakepath(2178,1): warning X4000: use of potentially uninitialized variable (f_intersectsCircle)
C:\fakepath(2179,1): warning X4000: use of potentially uninitialized variable (f_intersectsCircle)
C:\fakepath(2825,1): warning X4000: use of potentially uninitialized variable (f_envMapDirectionPdf)
C:\fakepath(2272,1): warning X4000: use of potentially uninitialized variable (f_ggxDistribution)
C:\fakepath(2383,1): warning X4000: use of potentially uninitialized variable (f_evalIridescence)
C:\fakepath(2523,1): warning X4000: use of potentially uninitialized variable (f_transmissionEval__SurfaceRec)
C:\fakepath(2272,1): warning X4000: use of potentially uninitialized variable (f_ggxDistribution)
C:\fakepath(1329,1-6): warning X4000: use of potentially uninitialized variable (dyn_index_vec3_int)
C:\fakepath(2272,1): warning X4000: use of potentially uninitialized variable (f_ggxDistribution)
C:\fakepath(2383,1): warning X4000: use of potentially uninitialized variable (f_evalIridescence)
C:\fakepath(2523,1): warning X4000: use of potentially uninitialized variable (f_transmissionEval__SurfaceRec)
C:\fakepath(2272,1): warning X4000: use of potentially uninitialized variable (f_ggxDistribution)
C:\fakepath(2825,1): warning X4000: use of potentially uninitialized variable (f_envMapDirectionPdf)
C:\fakepath(1329,1-6): warning X4000: use of potentially uninitialized variable (dyn_index_vec3_int)
C:\fakepath(2272,1): warning X4000: use of potentially uninitialized variable (f_ggxDistribution)
C:\fakepath(2383,1): warning X4000: use of potentially uninitialized variable (f_evalIridescence)
C:\fakepath(2523,1): warning X4000: use of potentially uninitialized variable (f_transmissionEval__SurfaceRec)
C:\fakepath(2272,1): warning X4000: use of potentially uninitialized variable (f_ggxDistribution)
Any help would be appreciated, I’m looking forward to learning more on this matter, but right now I’m stuck trying to implement it.