three-gpu-pathtracer 0.0.14 → 0.0.16
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/LICENSE +21 -21
- package/README.md +1004 -981
- package/build/index.module.js +7413 -6902
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +7446 -6933
- package/build/index.umd.cjs.map +1 -1
- package/package.json +73 -73
- package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
- package/src/core/MaterialReducer.js +256 -256
- package/src/core/PathTracingRenderer.js +346 -346
- package/src/core/PathTracingSceneGenerator.js +69 -69
- package/src/core/QuiltPathTracingRenderer.js +223 -223
- package/src/detectors/CompatibilityDetector.js +38 -0
- package/src/detectors/MaterialCompileDetector.js +50 -0
- package/src/detectors/PrecisionDetector.js +85 -0
- package/src/detectors/PrecisionMaterial.js +160 -0
- package/src/index.js +40 -36
- package/src/materials/MaterialBase.js +56 -56
- package/src/materials/debug/GraphMaterial.js +243 -243
- package/src/materials/fullscreen/AlphaDisplayMaterial.js +50 -48
- package/src/materials/fullscreen/BlendMaterial.js +67 -67
- package/src/materials/fullscreen/DenoiseMaterial.js +142 -142
- package/src/materials/fullscreen/GradientMapMaterial.js +82 -0
- package/src/materials/pathtracing/LambertPathTracingMaterial.js +296 -296
- package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +118 -196
- package/src/materials/pathtracing/glsl/attenuateHit.glsl.js +177 -179
- package/src/materials/pathtracing/glsl/cameraUtils.glsl.js +84 -81
- package/src/materials/pathtracing/glsl/directLightContribution.glsl.js +93 -0
- package/src/materials/pathtracing/glsl/getSurfaceRecord.glsl.js +323 -317
- package/src/materials/pathtracing/glsl/renderStructs.glsl.js +50 -0
- package/src/materials/pathtracing/glsl/traceScene.glsl.js +52 -54
- package/src/materials/surface/AmbientOcclusionMaterial.js +207 -207
- package/src/materials/surface/FogVolumeMaterial.js +23 -23
- package/src/objects/EquirectCamera.js +13 -13
- package/src/objects/PhysicalCamera.js +42 -28
- package/src/objects/PhysicalSpotLight.js +25 -14
- package/src/objects/ShapedAreaLight.js +22 -12
- package/src/shader/bsdf/bsdfSampling.glsl.js +499 -490
- package/src/shader/bsdf/fog.glsl.js +22 -23
- package/src/shader/bsdf/ggx.glsl.js +102 -102
- package/src/shader/bsdf/iridescence.glsl.js +135 -135
- package/src/shader/bsdf/sheen.glsl.js +98 -98
- package/src/shader/common/arraySamplerTexelFetch.glsl.js +25 -25
- package/src/shader/common/bvhAnyHit.glsl.js +76 -76
- package/src/shader/common/fresnel.glsl.js +98 -98
- package/src/shader/common/intersectShapes.glsl.js +62 -62
- package/src/shader/common/math.glsl.js +81 -81
- package/src/shader/common/utils.glsl.js +116 -116
- package/src/shader/rand/pcg.glsl.js +57 -57
- package/src/shader/rand/sobol.glsl.js +256 -256
- package/src/shader/sampling/equirectSampling.glsl.js +62 -62
- package/src/shader/sampling/lightSampling.glsl.js +223 -223
- package/src/shader/sampling/shapeSampling.glsl.js +86 -86
- package/src/shader/structs/cameraStruct.glsl.js +13 -13
- package/src/shader/structs/equirectStruct.glsl.js +13 -14
- package/src/shader/structs/fogMaterialBvh.glsl.js +62 -62
- package/src/shader/structs/lightsStruct.glsl.js +78 -78
- package/src/shader/structs/materialStruct.glsl.js +207 -207
- package/src/textures/GradientEquirectTexture.js +35 -35
- package/src/textures/ProceduralEquirectTexture.js +75 -75
- package/src/uniforms/AttributesTextureArray.js +35 -35
- package/src/uniforms/EquirectHdrInfoUniform.js +269 -277
- package/src/uniforms/FloatAttributeTextureArray.js +169 -169
- package/src/uniforms/IESProfilesTexture.js +100 -100
- package/src/uniforms/LightsInfoUniformStruct.js +212 -212
- package/src/uniforms/MaterialsTexture.js +503 -503
- package/src/uniforms/PhysicalCameraUniform.js +36 -36
- package/src/uniforms/RenderTarget2DArray.js +97 -97
- package/src/uniforms/utils.js +30 -30
- package/src/utils/BlurredEnvMapGenerator.js +116 -116
- package/src/utils/GeometryPreparationUtils.js +214 -214
- package/src/utils/IESLoader.js +325 -325
- package/src/utils/SobolNumberMapGenerator.js +80 -80
- package/src/utils/UVUnwrapper.js +101 -101
- package/src/utils/macroify.js +9 -9
- package/src/workers/PathTracingSceneWorker.js +42 -42
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
export const fogMaterialBvhGLSL = /* glsl */`
|
|
2
|
-
|
|
3
|
-
#ifndef FOG_CHECK_ITERATIONS
|
|
4
|
-
#define FOG_CHECK_ITERATIONS 30
|
|
5
|
-
#endif
|
|
6
|
-
|
|
7
|
-
// returns whether the given material is a fog material or not
|
|
8
|
-
bool isMaterialFogVolume( sampler2D materials, uint materialIndex ) {
|
|
9
|
-
|
|
10
|
-
uint i = materialIndex * 45u;
|
|
11
|
-
vec4 s14 = texelFetch1D( materials, i + 14u );
|
|
12
|
-
return bool( int( s14.b ) & 4 );
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// returns true if we're within the first fog volume we hit
|
|
17
|
-
bool bvhIntersectFogVolumeHit(
|
|
18
|
-
BVH bvh, vec3 rayOrigin, vec3 rayDirection,
|
|
19
|
-
usampler2D materialIndexAttribute, sampler2D materials,
|
|
20
|
-
out Material material
|
|
21
|
-
) {
|
|
22
|
-
|
|
23
|
-
material.fogVolume = false;
|
|
24
|
-
|
|
25
|
-
for ( int i = 0; i < FOG_CHECK_ITERATIONS; i ++ ) {
|
|
26
|
-
|
|
27
|
-
// find nearest hit
|
|
28
|
-
uvec4 faceIndices = uvec4( 0u );
|
|
29
|
-
vec3 faceNormal = vec3( 0.0, 0.0, 1.0 );
|
|
30
|
-
vec3 barycoord = vec3( 0.0 );
|
|
31
|
-
float side = 1.0;
|
|
32
|
-
float dist = 0.0;
|
|
33
|
-
bool hit = bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist );
|
|
34
|
-
if ( hit ) {
|
|
35
|
-
|
|
36
|
-
// if it's a fog volume return whether we hit the front or back face
|
|
37
|
-
uint materialIndex = uTexelFetch1D( materialIndexAttribute, faceIndices.x ).r;
|
|
38
|
-
if ( isMaterialFogVolume( materials, materialIndex ) ) {
|
|
39
|
-
|
|
40
|
-
material = readMaterialInfo( materials, materialIndex );
|
|
41
|
-
return side == - 1.0;
|
|
42
|
-
|
|
43
|
-
} else {
|
|
44
|
-
|
|
45
|
-
// move the ray forward
|
|
46
|
-
rayOrigin = stepRayOrigin( rayOrigin, rayDirection, - faceNormal, dist );
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
} else {
|
|
51
|
-
|
|
52
|
-
return false;
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return false;
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
`;
|
|
1
|
+
export const fogMaterialBvhGLSL = /* glsl */`
|
|
2
|
+
|
|
3
|
+
#ifndef FOG_CHECK_ITERATIONS
|
|
4
|
+
#define FOG_CHECK_ITERATIONS 30
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
// returns whether the given material is a fog material or not
|
|
8
|
+
bool isMaterialFogVolume( sampler2D materials, uint materialIndex ) {
|
|
9
|
+
|
|
10
|
+
uint i = materialIndex * 45u;
|
|
11
|
+
vec4 s14 = texelFetch1D( materials, i + 14u );
|
|
12
|
+
return bool( int( s14.b ) & 4 );
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// returns true if we're within the first fog volume we hit
|
|
17
|
+
bool bvhIntersectFogVolumeHit(
|
|
18
|
+
BVH bvh, vec3 rayOrigin, vec3 rayDirection,
|
|
19
|
+
usampler2D materialIndexAttribute, sampler2D materials,
|
|
20
|
+
out Material material
|
|
21
|
+
) {
|
|
22
|
+
|
|
23
|
+
material.fogVolume = false;
|
|
24
|
+
|
|
25
|
+
for ( int i = 0; i < FOG_CHECK_ITERATIONS; i ++ ) {
|
|
26
|
+
|
|
27
|
+
// find nearest hit
|
|
28
|
+
uvec4 faceIndices = uvec4( 0u );
|
|
29
|
+
vec3 faceNormal = vec3( 0.0, 0.0, 1.0 );
|
|
30
|
+
vec3 barycoord = vec3( 0.0 );
|
|
31
|
+
float side = 1.0;
|
|
32
|
+
float dist = 0.0;
|
|
33
|
+
bool hit = bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist );
|
|
34
|
+
if ( hit ) {
|
|
35
|
+
|
|
36
|
+
// if it's a fog volume return whether we hit the front or back face
|
|
37
|
+
uint materialIndex = uTexelFetch1D( materialIndexAttribute, faceIndices.x ).r;
|
|
38
|
+
if ( isMaterialFogVolume( materials, materialIndex ) ) {
|
|
39
|
+
|
|
40
|
+
material = readMaterialInfo( materials, materialIndex );
|
|
41
|
+
return side == - 1.0;
|
|
42
|
+
|
|
43
|
+
} else {
|
|
44
|
+
|
|
45
|
+
// move the ray forward
|
|
46
|
+
rayOrigin = stepRayOrigin( rayOrigin, rayDirection, - faceNormal, dist );
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
} else {
|
|
51
|
+
|
|
52
|
+
return false;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return false;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`;
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
export const lightsStructGLSL = /* glsl */`
|
|
2
|
-
|
|
3
|
-
#define RECT_AREA_LIGHT_TYPE 0
|
|
4
|
-
#define CIRC_AREA_LIGHT_TYPE 1
|
|
5
|
-
#define SPOT_LIGHT_TYPE 2
|
|
6
|
-
#define DIR_LIGHT_TYPE 3
|
|
7
|
-
#define POINT_LIGHT_TYPE 4
|
|
8
|
-
|
|
9
|
-
struct LightsInfo {
|
|
10
|
-
|
|
11
|
-
sampler2D tex;
|
|
12
|
-
uint count;
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
struct Light {
|
|
17
|
-
|
|
18
|
-
vec3 position;
|
|
19
|
-
int type;
|
|
20
|
-
|
|
21
|
-
vec3 color;
|
|
22
|
-
float intensity;
|
|
23
|
-
|
|
24
|
-
vec3 u;
|
|
25
|
-
vec3 v;
|
|
26
|
-
float area;
|
|
27
|
-
|
|
28
|
-
// spot light fields
|
|
29
|
-
float radius;
|
|
30
|
-
float near;
|
|
31
|
-
float decay;
|
|
32
|
-
float distance;
|
|
33
|
-
float coneCos;
|
|
34
|
-
float penumbraCos;
|
|
35
|
-
int iesProfile;
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
Light readLightInfo( sampler2D tex, uint index ) {
|
|
40
|
-
|
|
41
|
-
uint i = index * 6u;
|
|
42
|
-
|
|
43
|
-
vec4 s0 = texelFetch1D( tex, i + 0u );
|
|
44
|
-
vec4 s1 = texelFetch1D( tex, i + 1u );
|
|
45
|
-
vec4 s2 = texelFetch1D( tex, i + 2u );
|
|
46
|
-
vec4 s3 = texelFetch1D( tex, i + 3u );
|
|
47
|
-
|
|
48
|
-
Light l;
|
|
49
|
-
l.position = s0.rgb;
|
|
50
|
-
l.type = int( round( s0.a ) );
|
|
51
|
-
|
|
52
|
-
l.color = s1.rgb;
|
|
53
|
-
l.intensity = s1.a;
|
|
54
|
-
|
|
55
|
-
l.u = s2.rgb;
|
|
56
|
-
l.v = s3.rgb;
|
|
57
|
-
l.area = s3.a;
|
|
58
|
-
|
|
59
|
-
if ( l.type == SPOT_LIGHT_TYPE || l.type == POINT_LIGHT_TYPE ) {
|
|
60
|
-
|
|
61
|
-
vec4 s4 = texelFetch1D( tex, i + 4u );
|
|
62
|
-
vec4 s5 = texelFetch1D( tex, i + 5u );
|
|
63
|
-
l.radius = s4.r;
|
|
64
|
-
l.near = s4.g;
|
|
65
|
-
l.decay = s4.b;
|
|
66
|
-
l.distance = s4.a;
|
|
67
|
-
|
|
68
|
-
l.coneCos = s5.r;
|
|
69
|
-
l.penumbraCos = s5.g;
|
|
70
|
-
l.iesProfile = int( round ( s5.b ) );
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return l;
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
`;
|
|
1
|
+
export const lightsStructGLSL = /* glsl */`
|
|
2
|
+
|
|
3
|
+
#define RECT_AREA_LIGHT_TYPE 0
|
|
4
|
+
#define CIRC_AREA_LIGHT_TYPE 1
|
|
5
|
+
#define SPOT_LIGHT_TYPE 2
|
|
6
|
+
#define DIR_LIGHT_TYPE 3
|
|
7
|
+
#define POINT_LIGHT_TYPE 4
|
|
8
|
+
|
|
9
|
+
struct LightsInfo {
|
|
10
|
+
|
|
11
|
+
sampler2D tex;
|
|
12
|
+
uint count;
|
|
13
|
+
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
struct Light {
|
|
17
|
+
|
|
18
|
+
vec3 position;
|
|
19
|
+
int type;
|
|
20
|
+
|
|
21
|
+
vec3 color;
|
|
22
|
+
float intensity;
|
|
23
|
+
|
|
24
|
+
vec3 u;
|
|
25
|
+
vec3 v;
|
|
26
|
+
float area;
|
|
27
|
+
|
|
28
|
+
// spot light fields
|
|
29
|
+
float radius;
|
|
30
|
+
float near;
|
|
31
|
+
float decay;
|
|
32
|
+
float distance;
|
|
33
|
+
float coneCos;
|
|
34
|
+
float penumbraCos;
|
|
35
|
+
int iesProfile;
|
|
36
|
+
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Light readLightInfo( sampler2D tex, uint index ) {
|
|
40
|
+
|
|
41
|
+
uint i = index * 6u;
|
|
42
|
+
|
|
43
|
+
vec4 s0 = texelFetch1D( tex, i + 0u );
|
|
44
|
+
vec4 s1 = texelFetch1D( tex, i + 1u );
|
|
45
|
+
vec4 s2 = texelFetch1D( tex, i + 2u );
|
|
46
|
+
vec4 s3 = texelFetch1D( tex, i + 3u );
|
|
47
|
+
|
|
48
|
+
Light l;
|
|
49
|
+
l.position = s0.rgb;
|
|
50
|
+
l.type = int( round( s0.a ) );
|
|
51
|
+
|
|
52
|
+
l.color = s1.rgb;
|
|
53
|
+
l.intensity = s1.a;
|
|
54
|
+
|
|
55
|
+
l.u = s2.rgb;
|
|
56
|
+
l.v = s3.rgb;
|
|
57
|
+
l.area = s3.a;
|
|
58
|
+
|
|
59
|
+
if ( l.type == SPOT_LIGHT_TYPE || l.type == POINT_LIGHT_TYPE ) {
|
|
60
|
+
|
|
61
|
+
vec4 s4 = texelFetch1D( tex, i + 4u );
|
|
62
|
+
vec4 s5 = texelFetch1D( tex, i + 5u );
|
|
63
|
+
l.radius = s4.r;
|
|
64
|
+
l.near = s4.g;
|
|
65
|
+
l.decay = s4.b;
|
|
66
|
+
l.distance = s4.a;
|
|
67
|
+
|
|
68
|
+
l.coneCos = s5.r;
|
|
69
|
+
l.penumbraCos = s5.g;
|
|
70
|
+
l.iesProfile = int( round ( s5.b ) );
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return l;
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
`;
|