three-gpu-pathtracer 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -464
- package/build/index.module.js +5691 -5312
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +5369 -5003
- package/build/index.umd.cjs.map +1 -1
- package/package.json +12 -6
- package/src/core/PathTracingRenderer.js +59 -46
- package/src/core/PathTracingSceneGenerator.js +245 -10
- package/src/core/WebGLPathTracer.js +472 -0
- package/src/core/utils/BakedGeometry.js +35 -0
- package/src/core/utils/BufferAttributeUtils.js +64 -0
- package/src/{utils → core/utils}/GeometryPreparationUtils.js +35 -35
- package/src/core/utils/MeshDiff.js +102 -0
- package/src/core/utils/StaticGeometryGenerator.js +285 -0
- package/src/core/utils/convertToStaticGeometry.js +344 -0
- package/src/core/utils/mergeGeometries.js +218 -0
- package/src/core/utils/sceneUpdateUtils.js +96 -0
- package/src/index.d.ts +274 -0
- package/src/index.js +4 -20
- package/src/materials/MaterialBase.js +4 -0
- package/src/materials/fullscreen/ClampedInterpolationMaterial.js +112 -0
- package/src/materials/fullscreen/DenoiseMaterial.js +4 -0
- package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +73 -76
- package/src/materials/pathtracing/glsl/{attenuateHit.glsl.js → attenuate_hit_function.glsl.js} +1 -1
- package/src/materials/pathtracing/glsl/{cameraUtils.glsl.js → camera_util_functions.glsl.js} +1 -1
- package/src/materials/pathtracing/glsl/{directLightContribution.glsl.js → direct_light_contribution_function.glsl.js} +1 -1
- package/src/materials/pathtracing/glsl/{getSurfaceRecord.glsl.js → get_surface_record_function.glsl.js} +1 -1
- package/src/materials/pathtracing/glsl/index.js +6 -0
- package/src/materials/pathtracing/glsl/{renderStructs.glsl.js → render_structs.glsl.js} +1 -1
- package/src/materials/pathtracing/glsl/{traceScene.glsl.js → trace_scene_function.glsl.js} +1 -3
- package/src/materials/surface/AmbientOcclusionMaterial.js +8 -8
- package/src/objects/PhysicalSpotLight.js +2 -2
- package/src/shader/bsdf/{bsdfSampling.glsl.js → bsdf_functions.glsl.js} +19 -72
- package/src/shader/bsdf/{fog.glsl.js → fog_functions.glsl.js} +1 -1
- package/src/shader/bsdf/{ggx.glsl.js → ggx_functions.glsl.js} +1 -1
- package/src/shader/bsdf/index.js +5 -0
- package/src/shader/bsdf/{iridescence.glsl.js → iridescence_functions.glsl.js} +1 -1
- package/src/shader/bsdf/{sheen.glsl.js → sheen_functions.glsl.js} +1 -1
- package/src/shader/bvh/index.js +2 -0
- package/src/shader/{structs/fogMaterialBvh.glsl.js → bvh/inside_fog_volume_function.glsl.js} +1 -1
- package/src/shader/{common/bvhAnyHit.glsl.js → bvh/ray_any_hit_function.glsl.js} +1 -1
- package/src/shader/common/{fresnel.glsl.js → fresnel_functions.glsl.js} +1 -1
- package/src/shader/common/index.js +5 -0
- package/src/shader/common/{math.glsl.js → math_functions.glsl.js} +1 -1
- package/src/shader/common/{intersectShapes.glsl.js → shape_intersection_functions.glsl.js} +1 -1
- package/src/shader/common/{arraySamplerTexelFetch.glsl.js → texture_sample_functions.glsl.js} +1 -1
- package/src/shader/common/{utils.glsl.js → util_functions.glsl.js} +1 -1
- package/src/shader/rand/index.js +3 -0
- package/src/shader/rand/pcg.glsl.js +1 -1
- package/src/shader/rand/sobol.glsl.js +4 -4
- package/src/shader/rand/{stratifiedTexture.glsl.js → stratified.glsl.js} +7 -2
- package/src/shader/sampling/{equirectSampling.glsl.js → equirect_sampling_functions.glsl.js} +1 -2
- package/src/shader/sampling/index.js +3 -0
- package/src/shader/sampling/{lightSampling.glsl.js → light_sampling_functions.glsl.js} +3 -3
- package/src/shader/sampling/{shapeSampling.glsl.js → shape_sampling_functions.glsl.js} +1 -1
- package/src/shader/structs/{cameraStruct.glsl.js → camera_struct.glsl.js} +1 -1
- package/src/shader/structs/{equirectStruct.glsl.js → equirect_struct.glsl.js} +1 -1
- package/src/shader/structs/index.js +5 -0
- package/src/shader/structs/{lightsStruct.glsl.js → lights_struct.glsl.js} +1 -1
- package/src/shader/structs/{materialStruct.glsl.js → material_struct.glsl.js} +2 -2
- package/src/shader/structs/surface_record_struct.glsl.js +63 -0
- package/src/uniforms/EquirectHdrInfoUniform.js +16 -11
- package/src/uniforms/LightsInfoUniformStruct.js +21 -10
- package/src/uniforms/MaterialsTexture.js +27 -86
- package/src/uniforms/RenderTarget2DArray.js +60 -20
- package/src/utils/BlurredEnvMapGenerator.js +12 -5
- package/src/utils/SobolNumberMapGenerator.js +3 -3
- package/src/utils/bufferToHash.js +22 -0
- package/src/core/DynamicPathTracingSceneGenerator.js +0 -164
- package/src/core/MaterialReducer.js +0 -256
- package/src/materials/pathtracing/LambertPathTracingMaterial.js +0 -297
- package/src/uniforms/IESProfilesTexture.js +0 -100
- package/src/uniforms/utils.js +0 -30
- package/src/utils/IESLoader.js +0 -327
- package/src/workers/PathTracingSceneWorker.js +0 -52
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { BufferAttribute, BufferGeometry } from 'three';
|
|
2
|
+
import { copyAttributeContents, createAttributeClone } from './BufferAttributeUtils.js';
|
|
3
|
+
|
|
4
|
+
function validateMergeability( geometries ) {
|
|
5
|
+
|
|
6
|
+
const isIndexed = geometries[ 0 ].index !== null;
|
|
7
|
+
const attributesUsed = new Set( Object.keys( geometries[ 0 ].attributes ) );
|
|
8
|
+
if ( ! geometries[ 0 ].getAttribute( 'position' ) ) {
|
|
9
|
+
|
|
10
|
+
throw new Error( 'StaticGeometryGenerator: position attribute is required.' );
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
for ( let i = 0; i < geometries.length; ++ i ) {
|
|
15
|
+
|
|
16
|
+
const geometry = geometries[ i ];
|
|
17
|
+
let attributesCount = 0;
|
|
18
|
+
|
|
19
|
+
// ensure that all geometries are indexed, or none
|
|
20
|
+
if ( isIndexed !== ( geometry.index !== null ) ) {
|
|
21
|
+
|
|
22
|
+
throw new Error( 'StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' );
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// gather attributes, exit early if they're different
|
|
27
|
+
for ( const name in geometry.attributes ) {
|
|
28
|
+
|
|
29
|
+
if ( ! attributesUsed.has( name ) ) {
|
|
30
|
+
|
|
31
|
+
throw new Error( 'StaticGeometryGenerator: All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.' );
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
attributesCount ++;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ensure geometries have the same number of attributes
|
|
40
|
+
if ( attributesCount !== attributesUsed.size ) {
|
|
41
|
+
|
|
42
|
+
throw new Error( 'StaticGeometryGenerator: All geometries must have the same number of attributes.' );
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getTotalIndexCount( geometries ) {
|
|
51
|
+
|
|
52
|
+
let result = 0;
|
|
53
|
+
for ( let i = 0, l = geometries.length; i < l; i ++ ) {
|
|
54
|
+
|
|
55
|
+
result += geometries[ i ].getIndex().count;
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return result;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getTotalAttributeCount( geometries ) {
|
|
64
|
+
|
|
65
|
+
let result = 0;
|
|
66
|
+
for ( let i = 0, l = geometries.length; i < l; i ++ ) {
|
|
67
|
+
|
|
68
|
+
result += geometries[ i ].getAttribute( 'position' ).count;
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return result;
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function trimMismatchedAttributes( target, indexCount, attrCount ) {
|
|
77
|
+
|
|
78
|
+
if ( target.index && target.index.count !== indexCount ) {
|
|
79
|
+
|
|
80
|
+
target.setIndex( null );
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const attributes = target.attributes;
|
|
85
|
+
for ( const key in attributes ) {
|
|
86
|
+
|
|
87
|
+
const attr = attributes[ key ];
|
|
88
|
+
if ( attr.count !== attrCount ) {
|
|
89
|
+
|
|
90
|
+
target.deleteAttribute( key );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Modified version of BufferGeometryUtils.mergeBufferGeometries that ignores morph targets and updates a attributes in place
|
|
99
|
+
export function mergeGeometries( geometries, options = {}, targetGeometry = new BufferGeometry() ) {
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
useGroups = false,
|
|
103
|
+
forceUpdate = false,
|
|
104
|
+
skipAssigningAttributes = [],
|
|
105
|
+
overwriteIndex = true,
|
|
106
|
+
} = options;
|
|
107
|
+
|
|
108
|
+
// check if we can merge these geometries
|
|
109
|
+
validateMergeability( geometries );
|
|
110
|
+
|
|
111
|
+
const isIndexed = geometries[ 0 ].index !== null;
|
|
112
|
+
const totalIndexCount = isIndexed ? getTotalIndexCount( geometries ) : - 1;
|
|
113
|
+
const totalAttributeCount = getTotalAttributeCount( geometries );
|
|
114
|
+
trimMismatchedAttributes( targetGeometry, totalIndexCount, totalAttributeCount );
|
|
115
|
+
|
|
116
|
+
// set up groups
|
|
117
|
+
if ( useGroups ) {
|
|
118
|
+
|
|
119
|
+
let offset = 0;
|
|
120
|
+
for ( let i = 0, l = geometries.length; i < l; i ++ ) {
|
|
121
|
+
|
|
122
|
+
const geometry = geometries[ i ];
|
|
123
|
+
|
|
124
|
+
let primitiveCount;
|
|
125
|
+
if ( isIndexed ) {
|
|
126
|
+
|
|
127
|
+
primitiveCount = geometry.getIndex().count;
|
|
128
|
+
|
|
129
|
+
} else {
|
|
130
|
+
|
|
131
|
+
primitiveCount = geometry.getAttribute( 'position' ).count;
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
targetGeometry.addGroup( offset, primitiveCount, i );
|
|
136
|
+
offset += primitiveCount;
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// generate the final geometry
|
|
143
|
+
// skip the assigning any attributes for items in the above array
|
|
144
|
+
if ( isIndexed ) {
|
|
145
|
+
|
|
146
|
+
// set up the index if it doesn't exist
|
|
147
|
+
let forceUpdateIndex = false;
|
|
148
|
+
if ( ! targetGeometry.index ) {
|
|
149
|
+
|
|
150
|
+
targetGeometry.setIndex( new BufferAttribute( new Uint32Array( totalIndexCount ), 1, false ) );
|
|
151
|
+
forceUpdateIndex = true;
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if ( forceUpdateIndex || overwriteIndex ) {
|
|
156
|
+
|
|
157
|
+
// copy the index data to the target geometry
|
|
158
|
+
let targetOffset = 0;
|
|
159
|
+
let indexOffset = 0;
|
|
160
|
+
const targetIndex = targetGeometry.getIndex();
|
|
161
|
+
for ( let i = 0, l = geometries.length; i < l; i ++ ) {
|
|
162
|
+
|
|
163
|
+
const geometry = geometries[ i ];
|
|
164
|
+
const index = geometry.getIndex();
|
|
165
|
+
const skip = ! forceUpdate && ! forceUpdateIndex && skipAssigningAttributes[ i ];
|
|
166
|
+
if ( ! skip ) {
|
|
167
|
+
|
|
168
|
+
for ( let j = 0; j < index.count; ++ j ) {
|
|
169
|
+
|
|
170
|
+
targetIndex.setX( targetOffset + j, index.getX( j ) + indexOffset );
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
targetOffset += index.count;
|
|
177
|
+
indexOffset += geometry.getAttribute( 'position' ).count;
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// copy all the attribute data over
|
|
186
|
+
const attributes = Object.keys( geometries[ 0 ].attributes );
|
|
187
|
+
for ( let i = 0, l = attributes.length; i < l; i ++ ) {
|
|
188
|
+
|
|
189
|
+
let forceUpdateAttr = false;
|
|
190
|
+
const key = attributes[ i ];
|
|
191
|
+
if ( ! targetGeometry.getAttribute( key ) ) {
|
|
192
|
+
|
|
193
|
+
const firstAttr = geometries[ 0 ].getAttribute( key );
|
|
194
|
+
targetGeometry.setAttribute( key, createAttributeClone( firstAttr, totalAttributeCount ) );
|
|
195
|
+
forceUpdateAttr = true;
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let offset = 0;
|
|
200
|
+
const targetAttribute = targetGeometry.getAttribute( key );
|
|
201
|
+
for ( let g = 0, l = geometries.length; g < l; g ++ ) {
|
|
202
|
+
|
|
203
|
+
const geometry = geometries[ g ];
|
|
204
|
+
const skip = ! forceUpdate && ! forceUpdateAttr && skipAssigningAttributes[ g ];
|
|
205
|
+
const attr = geometry.getAttribute( key );
|
|
206
|
+
if ( ! skip ) {
|
|
207
|
+
|
|
208
|
+
copyAttributeContents( attr, targetAttribute, offset );
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
offset += attr.count;
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
function uuidSort( a, b ) {
|
|
2
|
+
|
|
3
|
+
if ( a.uuid < b.uuid ) return 1;
|
|
4
|
+
if ( a.uuid > b.uuid ) return - 1;
|
|
5
|
+
return 0;
|
|
6
|
+
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// we must hash the texture to determine uniqueness using the encoding, as well, because the
|
|
10
|
+
// when rendering each texture to the texture array they must have a consistent color space.
|
|
11
|
+
export function getTextureHash( t ) {
|
|
12
|
+
|
|
13
|
+
return `${ t.source.uuid }:${ t.colorSpace }`;
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// reduce the set of textures to just those with a unique source while retaining
|
|
18
|
+
// the order of the textures.
|
|
19
|
+
function reduceTexturesToUniqueSources( textures ) {
|
|
20
|
+
|
|
21
|
+
const sourceSet = new Set();
|
|
22
|
+
const result = [];
|
|
23
|
+
for ( let i = 0, l = textures.length; i < l; i ++ ) {
|
|
24
|
+
|
|
25
|
+
const tex = textures[ i ];
|
|
26
|
+
const hash = getTextureHash( tex );
|
|
27
|
+
if ( ! sourceSet.has( hash ) ) {
|
|
28
|
+
|
|
29
|
+
sourceSet.add( hash );
|
|
30
|
+
result.push( tex );
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result;
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getIesTextures( lights ) {
|
|
41
|
+
|
|
42
|
+
const textures = lights.map( l => l.iesMap || null ).filter( t => t );
|
|
43
|
+
const textureSet = new Set( textures );
|
|
44
|
+
return Array.from( textureSet ).sort( uuidSort );
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getTextures( materials ) {
|
|
49
|
+
|
|
50
|
+
const textureSet = new Set();
|
|
51
|
+
for ( let i = 0, l = materials.length; i < l; i ++ ) {
|
|
52
|
+
|
|
53
|
+
const material = materials[ i ];
|
|
54
|
+
for ( const key in material ) {
|
|
55
|
+
|
|
56
|
+
const value = material[ key ];
|
|
57
|
+
if ( value && value.isTexture ) {
|
|
58
|
+
|
|
59
|
+
textureSet.add( value );
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const textureArray = Array.from( textureSet );
|
|
68
|
+
return reduceTexturesToUniqueSources( textureArray ).sort( uuidSort );
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function getLights( scene ) {
|
|
73
|
+
|
|
74
|
+
const lights = [];
|
|
75
|
+
scene.traverse( c => {
|
|
76
|
+
|
|
77
|
+
if ( c.visible ) {
|
|
78
|
+
|
|
79
|
+
if (
|
|
80
|
+
c.isRectAreaLight ||
|
|
81
|
+
c.isSpotLight ||
|
|
82
|
+
c.isPointLight ||
|
|
83
|
+
c.isDirectionalLight
|
|
84
|
+
) {
|
|
85
|
+
|
|
86
|
+
lights.push( c );
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
} );
|
|
93
|
+
|
|
94
|
+
return lights.sort( uuidSort );
|
|
95
|
+
|
|
96
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DataTexture,
|
|
3
|
+
RectAreaLight,
|
|
4
|
+
ShaderMaterial,
|
|
5
|
+
SpotLight,
|
|
6
|
+
Camera,
|
|
7
|
+
PerspectiveCamera,
|
|
8
|
+
MeshStandardMaterial,
|
|
9
|
+
Light,
|
|
10
|
+
Material,
|
|
11
|
+
Object3D,
|
|
12
|
+
Texture,
|
|
13
|
+
Vector2,
|
|
14
|
+
WebGLRenderer,
|
|
15
|
+
WebGLRenderTarget,
|
|
16
|
+
BufferGeometry,
|
|
17
|
+
Color,
|
|
18
|
+
ShaderMaterialParameters,
|
|
19
|
+
MeshStandardMaterialParameters,
|
|
20
|
+
Spherical,
|
|
21
|
+
Scene,
|
|
22
|
+
PMREMGenerator
|
|
23
|
+
} from 'three';
|
|
24
|
+
import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass';
|
|
25
|
+
import { MeshBVH, MeshBVHOptions } from 'three-mesh-bvh';
|
|
26
|
+
|
|
27
|
+
// three.js type augmentation
|
|
28
|
+
|
|
29
|
+
declare module 'three/src/materials/MeshStandardMaterial' {
|
|
30
|
+
|
|
31
|
+
export interface MeshStandardMaterial {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Whether to render the object as completely transparent against the rest of the environment
|
|
35
|
+
* so other objects can be composited later.
|
|
36
|
+
*
|
|
37
|
+
* Used by `WebGLPathTracer` from `three-gpu-pathtracer`.
|
|
38
|
+
*/
|
|
39
|
+
matte: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the object should cast a shadow.
|
|
42
|
+
*
|
|
43
|
+
* Used by `WebGLPathTracer` from `three-gpu-pathtracer`.
|
|
44
|
+
*/
|
|
45
|
+
castShadow: boolean;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// core
|
|
52
|
+
|
|
53
|
+
export interface PathTracingSceneGeneratorResult {
|
|
54
|
+
|
|
55
|
+
bvhChanged: boolean;
|
|
56
|
+
bvh: MeshBVH;
|
|
57
|
+
lights: Array<Light>;
|
|
58
|
+
iesTextures: Array<DataTexture>;
|
|
59
|
+
geometry: BufferGeometry;
|
|
60
|
+
materials: Array<Material>;
|
|
61
|
+
textures: Array<Texture>;
|
|
62
|
+
objects: Array<Object3D>;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface BVHWorker {
|
|
67
|
+
|
|
68
|
+
generate( geometry : BufferGeometry, options?: MeshBVHOptions ) : Promise<MeshBVH>
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated `PathTracingSceneGenerator` has been deprecated and will be removed in a future release.
|
|
74
|
+
* Use `WebGLPathTracer` instead, as it handles scene generation internally.
|
|
75
|
+
*/
|
|
76
|
+
export class PathTracingSceneGenerator {
|
|
77
|
+
|
|
78
|
+
constructor( objects?: Object3D | Array<Object3D> );
|
|
79
|
+
|
|
80
|
+
readonly initialized: boolean;
|
|
81
|
+
|
|
82
|
+
bvhOptions: MeshBVHOptions;
|
|
83
|
+
attributes: Array<string>;
|
|
84
|
+
generateBVH: boolean;
|
|
85
|
+
|
|
86
|
+
bvh: MeshBVH | null;
|
|
87
|
+
geometry: BufferGeometry;
|
|
88
|
+
|
|
89
|
+
setObjects( objects: Object3D | Array<Object3D> ): void;
|
|
90
|
+
setBVHWorker( bvhWorker: BVHWorker ): void;
|
|
91
|
+
|
|
92
|
+
generateAsync( onProgress?: ( progress: number ) => void ): Promise<PathTracingSceneGeneratorResult>;
|
|
93
|
+
generate( onProgress?: ( progress: number ) => void ): PathTracingSceneGeneratorResult;
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated `DynamicPathTracingSceneGenerator` has been deprecated and will be removed in a future release.
|
|
99
|
+
* Use `WebGLPathTracer` instead, as it handles scene generation internally.
|
|
100
|
+
*/
|
|
101
|
+
export class DynamicPathTracingSceneGenerator extends PathTracingSceneGenerator {}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated `PathTracingSceneWorker` has been deprecated and will be removed in a future release.
|
|
105
|
+
* Use `WebGLPathTracer` instead, as it handles scene generation internally.
|
|
106
|
+
*/
|
|
107
|
+
export class PathTracingSceneWorker extends PathTracingSceneGenerator {}
|
|
108
|
+
|
|
109
|
+
export class WebGLPathTracer {
|
|
110
|
+
|
|
111
|
+
constructor( renderer: WebGLRenderer );
|
|
112
|
+
|
|
113
|
+
readonly samples: number;
|
|
114
|
+
readonly target: WebGLRenderTarget;
|
|
115
|
+
readonly tiles: Vector2;
|
|
116
|
+
readonly camera: Camera | null;
|
|
117
|
+
readonly scene: Scene | null;
|
|
118
|
+
|
|
119
|
+
multipleImportanceSampling: boolean;
|
|
120
|
+
bounces: number;
|
|
121
|
+
transmissiveBounces: number;
|
|
122
|
+
filterGlossyFactor: number;
|
|
123
|
+
renderDelay: number;
|
|
124
|
+
minSamples: number;
|
|
125
|
+
fadeDuration: number;
|
|
126
|
+
enablePathTracing: boolean;
|
|
127
|
+
pausePathTracing: boolean;
|
|
128
|
+
dynamicLowRes: boolean;
|
|
129
|
+
lowResScale: number;
|
|
130
|
+
renderScale: number;
|
|
131
|
+
synchronizeRenderSize: boolean;
|
|
132
|
+
rasterizeScene: boolean;
|
|
133
|
+
renderToCanvas: boolean;
|
|
134
|
+
textureSize: Vector2;
|
|
135
|
+
|
|
136
|
+
rasterizeSceneCallback: ( scene: Scene, camera: Camera ) => void;
|
|
137
|
+
renderToCanvasCallback: ( target: WebGLRenderTarget, renderer: WebGLRenderer, quad: FullScreenQuad ) => void;
|
|
138
|
+
|
|
139
|
+
setBVHWorker( bvhWorker: BVHWorker ): void;
|
|
140
|
+
setScene(
|
|
141
|
+
scene: Scene,
|
|
142
|
+
camera: Camera,
|
|
143
|
+
options?: { onProgress?: ( progress: number ) => void }
|
|
144
|
+
): void;
|
|
145
|
+
setSceneAsync(
|
|
146
|
+
scene: Scene,
|
|
147
|
+
camera: Camera,
|
|
148
|
+
options?: { onProgress?: ( progress: number ) => void }
|
|
149
|
+
): Promise<void>;
|
|
150
|
+
setCamera( camera: Camera ): void;
|
|
151
|
+
|
|
152
|
+
updateCamera(): void;
|
|
153
|
+
updateMaterials(): void;
|
|
154
|
+
updateLights(): void;
|
|
155
|
+
updateEnvironment(): void;
|
|
156
|
+
renderSample(): void;
|
|
157
|
+
reset(): void;
|
|
158
|
+
dispose(): void;
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// objects
|
|
163
|
+
|
|
164
|
+
export class PhysicalCamera extends PerspectiveCamera {
|
|
165
|
+
|
|
166
|
+
focusDistance: number;
|
|
167
|
+
fStop: number;
|
|
168
|
+
bokehSize: number;
|
|
169
|
+
apertureBlades: number;
|
|
170
|
+
apertureRotation: number;
|
|
171
|
+
anamorphicRatio: number;
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export class EquirectCamera extends Camera {
|
|
176
|
+
|
|
177
|
+
readonly isEquirectCamera: true;
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export class PhysicalSpotLight extends SpotLight {
|
|
182
|
+
|
|
183
|
+
radius: number;
|
|
184
|
+
iesTexture: DataTexture | null;
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export class ShapedAreaLight extends RectAreaLight {
|
|
189
|
+
|
|
190
|
+
isCircular: boolean;
|
|
191
|
+
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// textures
|
|
195
|
+
|
|
196
|
+
export class ProceduralEquirectTexture extends DataTexture {
|
|
197
|
+
|
|
198
|
+
constructor( width?: number, height?: number );
|
|
199
|
+
|
|
200
|
+
generationCallback( polar: Spherical, uv: Vector2, coord: Vector2, color: Color ): void;
|
|
201
|
+
|
|
202
|
+
update(): void;
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export class GradientEquirectTexture extends ProceduralEquirectTexture {
|
|
207
|
+
|
|
208
|
+
constructor( resolution?: number );
|
|
209
|
+
|
|
210
|
+
exponent: number;
|
|
211
|
+
topColor: Color;
|
|
212
|
+
bottomColor: Color;
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// utils
|
|
217
|
+
|
|
218
|
+
export class BlurredEnvMapGenerator {
|
|
219
|
+
|
|
220
|
+
constructor( renderer: WebGLRenderer );
|
|
221
|
+
|
|
222
|
+
renderer: WebGLRenderer;
|
|
223
|
+
pmremGenerator: PMREMGenerator;
|
|
224
|
+
copyQuad: FullScreenQuad;
|
|
225
|
+
renderTarget: WebGLRenderTarget;
|
|
226
|
+
|
|
227
|
+
generate( texture: Texture, blur: number ): DataTexture;
|
|
228
|
+
dispose(): void;
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// materials
|
|
233
|
+
|
|
234
|
+
declare class MaterialBase extends ShaderMaterial {
|
|
235
|
+
|
|
236
|
+
setDefine( name: string, value: any ): boolean;
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface DenoiseMaterialParameters extends ShaderMaterialParameters {
|
|
241
|
+
|
|
242
|
+
sigma?: number;
|
|
243
|
+
kSigma?: number;
|
|
244
|
+
threshold?: number;
|
|
245
|
+
map?: Texture;
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export class DenoiseMaterial extends MaterialBase {
|
|
250
|
+
|
|
251
|
+
constructor( parameters?: DenoiseMaterialParameters );
|
|
252
|
+
|
|
253
|
+
sigma: number;
|
|
254
|
+
kSigma: number;
|
|
255
|
+
threshold: number;
|
|
256
|
+
map: Texture | null;
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface FogVolumeMaterialParameters extends MeshStandardMaterialParameters {
|
|
261
|
+
|
|
262
|
+
density?: number;
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export class FogVolumeMaterial extends MeshStandardMaterial {
|
|
267
|
+
|
|
268
|
+
constructor( parameters?: FogVolumeMaterialParameters );
|
|
269
|
+
|
|
270
|
+
readonly isFogVolumeMaterial: true;
|
|
271
|
+
|
|
272
|
+
density: number;
|
|
273
|
+
|
|
274
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// core
|
|
2
|
-
export * from './core/PathTracingRenderer.js';
|
|
3
|
-
export * from './core/QuiltPathTracingRenderer.js';
|
|
4
2
|
export * from './core/PathTracingSceneGenerator.js';
|
|
5
|
-
export * from './core/
|
|
6
|
-
export * from './core/MaterialReducer.js';
|
|
3
|
+
export * from './core/WebGLPathTracer.js';
|
|
7
4
|
|
|
8
5
|
// objects
|
|
9
6
|
export * from './objects/PhysicalCamera.js';
|
|
@@ -15,26 +12,13 @@ export * from './objects/ShapedAreaLight.js';
|
|
|
15
12
|
export * from './textures/ProceduralEquirectTexture.js';
|
|
16
13
|
export * from './textures/GradientEquirectTexture.js';
|
|
17
14
|
|
|
18
|
-
// uniforms
|
|
19
|
-
export * from './uniforms/MaterialsTexture.js';
|
|
20
|
-
export * from './uniforms/RenderTarget2DArray.js';
|
|
21
|
-
export * from './uniforms/EquirectHdrInfoUniform.js';
|
|
22
|
-
export * from './uniforms/PhysicalCameraUniform.js';
|
|
23
|
-
export * from './uniforms/LightsInfoUniformStruct.js';
|
|
24
|
-
export * from './uniforms/IESProfilesTexture.js';
|
|
25
|
-
|
|
26
15
|
// utils
|
|
27
|
-
export * from './utils/GeometryPreparationUtils.js';
|
|
28
16
|
export * from './utils/BlurredEnvMapGenerator.js';
|
|
29
|
-
export * from './utils/IESLoader.js';
|
|
30
17
|
|
|
31
18
|
// materials
|
|
32
19
|
export * from './materials/fullscreen/DenoiseMaterial.js';
|
|
33
|
-
export * from './materials/fullscreen/GradientMapMaterial.js';
|
|
34
|
-
export * from './materials/debug/GraphMaterial.js';
|
|
35
|
-
export * from './materials/MaterialBase.js';
|
|
36
|
-
export * from './materials/pathtracing/PhysicalPathTracingMaterial.js';
|
|
37
20
|
export * from './materials/surface/FogVolumeMaterial.js';
|
|
38
21
|
|
|
39
|
-
//
|
|
40
|
-
export * from './
|
|
22
|
+
// deprecated
|
|
23
|
+
export * from './materials/pathtracing/PhysicalPathTracingMaterial.js';
|
|
24
|
+
export * from './core/PathTracingRenderer.js';
|
|
@@ -37,6 +37,7 @@ export class MaterialBase extends ShaderMaterial {
|
|
|
37
37
|
|
|
38
38
|
delete this.defines[ name ];
|
|
39
39
|
this.needsUpdate = true;
|
|
40
|
+
return true;
|
|
40
41
|
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -46,11 +47,14 @@ export class MaterialBase extends ShaderMaterial {
|
|
|
46
47
|
|
|
47
48
|
this.defines[ name ] = value;
|
|
48
49
|
this.needsUpdate = true;
|
|
50
|
+
return true;
|
|
49
51
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
return false;
|
|
57
|
+
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
}
|