three-gpu-pathtracer 0.0.7 → 0.0.8

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.
Files changed (48) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +887 -815
  3. package/build/index.module.js +5796 -5451
  4. package/build/index.module.js.map +1 -1
  5. package/build/index.umd.cjs +5795 -5448
  6. package/build/index.umd.cjs.map +1 -1
  7. package/package.json +69 -68
  8. package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
  9. package/src/core/MaterialReducer.js +256 -256
  10. package/src/core/PathTracingRenderer.js +270 -270
  11. package/src/core/PathTracingSceneGenerator.js +1 -1
  12. package/src/index.js +39 -35
  13. package/src/materials/AlphaDisplayMaterial.js +48 -48
  14. package/src/materials/AmbientOcclusionMaterial.js +197 -197
  15. package/src/materials/BlendMaterial.js +67 -67
  16. package/src/materials/DenoiseMaterial.js +142 -142
  17. package/src/materials/GraphMaterial.js +243 -243
  18. package/src/materials/LambertPathTracingMaterial.js +285 -285
  19. package/src/materials/MaterialBase.js +56 -56
  20. package/src/materials/PhysicalPathTracingMaterial.js +973 -970
  21. package/src/objects/EquirectCamera.js +13 -13
  22. package/src/objects/PhysicalCamera.js +28 -28
  23. package/src/objects/PhysicalSpotLight.js +14 -14
  24. package/src/objects/ShapedAreaLight.js +12 -12
  25. package/src/shader/shaderEnvMapSampling.js +59 -59
  26. package/src/shader/shaderGGXFunctions.js +100 -100
  27. package/src/shader/shaderIridescenceFunctions.js +130 -130
  28. package/src/shader/shaderLayerTexelFetchFunctions.js +25 -0
  29. package/src/shader/shaderLightSampling.js +231 -231
  30. package/src/shader/shaderMaterialSampling.js +504 -542
  31. package/src/shader/shaderSheenFunctions.js +98 -98
  32. package/src/shader/shaderStructs.js +321 -321
  33. package/src/shader/shaderUtils.js +403 -364
  34. package/src/textures/GradientEquirectTexture.js +35 -0
  35. package/src/textures/ProceduralEquirectTexture.js +75 -0
  36. package/src/uniforms/AttributesTextureArray.js +35 -0
  37. package/src/uniforms/EquirectHdrInfoUniform.js +259 -259
  38. package/src/uniforms/FloatAttributeTextureArray.js +169 -0
  39. package/src/uniforms/IESProfilesTexture.js +100 -100
  40. package/src/uniforms/LightsInfoUniformStruct.js +162 -162
  41. package/src/uniforms/MaterialsTexture.js +420 -426
  42. package/src/uniforms/PhysicalCameraUniform.js +36 -36
  43. package/src/uniforms/RenderTarget2DArray.js +97 -93
  44. package/src/uniforms/utils.js +21 -0
  45. package/src/utils/BlurredEnvMapGenerator.js +116 -113
  46. package/src/utils/IESLoader.js +325 -325
  47. package/src/utils/UVUnwrapper.js +101 -101
  48. package/src/workers/PathTracingSceneWorker.js +42 -42
@@ -1,98 +1,98 @@
1
- export const shaderSheenFunctions = /* glsl */`
2
-
3
- // See equation (2) in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
4
- float velvetD( float cosThetaH, float roughness ) {
5
-
6
- float alpha = max( roughness, 0.07 );
7
- alpha = alpha * alpha;
8
-
9
- float invAlpha = 1.0 / alpha;
10
-
11
- float sqrCosThetaH = cosThetaH * cosThetaH;
12
- float sinThetaH = max( 1.0 - sqrCosThetaH, 0.001 );
13
-
14
- return ( 2.0 + invAlpha ) * pow( sinThetaH, 0.5 * invAlpha ) / ( 2.0 * PI );
15
-
16
- }
17
-
18
- float velvetParamsInterpolate( int i, float oneMinusAlphaSquared ) {
19
-
20
- const float p0[5] = float[5]( 25.3245, 3.32435, 0.16801, -1.27393, -4.85967 );
21
- const float p1[5] = float[5]( 21.5473, 3.82987, 0.19823, -1.97760, -4.32054 );
22
-
23
- return mix( p1[i], p0[i], oneMinusAlphaSquared );
24
-
25
- }
26
-
27
- float velvetL( float x, float alpha ) {
28
-
29
- float oneMinusAlpha = 1.0 - alpha;
30
- float oneMinusAlphaSquared = oneMinusAlpha * oneMinusAlpha;
31
-
32
- float a = velvetParamsInterpolate( 0, oneMinusAlphaSquared );
33
- float b = velvetParamsInterpolate( 1, oneMinusAlphaSquared );
34
- float c = velvetParamsInterpolate( 2, oneMinusAlphaSquared );
35
- float d = velvetParamsInterpolate( 3, oneMinusAlphaSquared );
36
- float e = velvetParamsInterpolate( 4, oneMinusAlphaSquared );
37
-
38
- return a / ( 1.0 + b * pow( abs( x ), c ) ) + d * x + e;
39
-
40
- }
41
-
42
- // See equation (3) in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
43
- float velvetLambda( float cosTheta, float alpha ) {
44
-
45
- return abs( cosTheta ) < 0.5 ? exp( velvetL( cosTheta, alpha ) ) : exp( 2.0 * velvetL( 0.5, alpha ) - velvetL( 1.0 - cosTheta, alpha ) );
46
-
47
- }
48
-
49
- // See Section 3, Shadowing Term, in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
50
- float velvetG( float cosThetaO, float cosThetaI, float roughness ) {
51
-
52
- float alpha = max( roughness, 0.07 );
53
- alpha = alpha * alpha;
54
-
55
- return 1.0 / ( 1.0 + velvetLambda( cosThetaO, alpha ) + velvetLambda( cosThetaI, alpha ) );
56
-
57
- }
58
-
59
- float directionalAlbedoSheen( float cosTheta, float alpha ) {
60
-
61
- cosTheta = saturate( cosTheta );
62
-
63
- float c = 1.0 - cosTheta;
64
- float c3 = c * c * c;
65
-
66
- return 0.65584461 * c3 + 1.0 / ( 4.16526551 + exp( -7.97291361 * sqrt( alpha ) + 6.33516894 ) );
67
-
68
- }
69
-
70
- float sheenAlbedoScaling( vec3 wo, vec3 wi, SurfaceRec surf ) {
71
-
72
- float alpha = max( surf.sheenRoughness, 0.07 );
73
- alpha = alpha * alpha;
74
-
75
- float maxSheenColor = max( max( surf.sheenColor.r, surf.sheenColor.g ), surf.sheenColor.b );
76
-
77
- float eWo = directionalAlbedoSheen( saturateCos( wo.z ), alpha );
78
- float eWi = directionalAlbedoSheen( saturateCos( wi.z ), alpha );
79
-
80
- return min( 1.0 - maxSheenColor * eWo, 1.0 - maxSheenColor * eWi );
81
-
82
- }
83
-
84
- // See Section 5, Layering, in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
85
- float sheenAlbedoScaling( vec3 wo, SurfaceRec surf ) {
86
-
87
- float alpha = max( surf.sheenRoughness, 0.07 );
88
- alpha = alpha * alpha;
89
-
90
- float maxSheenColor = max( max( surf.sheenColor.r, surf.sheenColor.g ), surf.sheenColor.b );
91
-
92
- float eWo = directionalAlbedoSheen( saturateCos( wo.z ), alpha );
93
-
94
- return 1.0 - maxSheenColor * eWo;
95
-
96
- }
97
-
98
- `;
1
+ export const shaderSheenFunctions = /* glsl */`
2
+
3
+ // See equation (2) in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
4
+ float velvetD( float cosThetaH, float roughness ) {
5
+
6
+ float alpha = max( roughness, 0.07 );
7
+ alpha = alpha * alpha;
8
+
9
+ float invAlpha = 1.0 / alpha;
10
+
11
+ float sqrCosThetaH = cosThetaH * cosThetaH;
12
+ float sinThetaH = max( 1.0 - sqrCosThetaH, 0.001 );
13
+
14
+ return ( 2.0 + invAlpha ) * pow( sinThetaH, 0.5 * invAlpha ) / ( 2.0 * PI );
15
+
16
+ }
17
+
18
+ float velvetParamsInterpolate( int i, float oneMinusAlphaSquared ) {
19
+
20
+ const float p0[5] = float[5]( 25.3245, 3.32435, 0.16801, -1.27393, -4.85967 );
21
+ const float p1[5] = float[5]( 21.5473, 3.82987, 0.19823, -1.97760, -4.32054 );
22
+
23
+ return mix( p1[i], p0[i], oneMinusAlphaSquared );
24
+
25
+ }
26
+
27
+ float velvetL( float x, float alpha ) {
28
+
29
+ float oneMinusAlpha = 1.0 - alpha;
30
+ float oneMinusAlphaSquared = oneMinusAlpha * oneMinusAlpha;
31
+
32
+ float a = velvetParamsInterpolate( 0, oneMinusAlphaSquared );
33
+ float b = velvetParamsInterpolate( 1, oneMinusAlphaSquared );
34
+ float c = velvetParamsInterpolate( 2, oneMinusAlphaSquared );
35
+ float d = velvetParamsInterpolate( 3, oneMinusAlphaSquared );
36
+ float e = velvetParamsInterpolate( 4, oneMinusAlphaSquared );
37
+
38
+ return a / ( 1.0 + b * pow( abs( x ), c ) ) + d * x + e;
39
+
40
+ }
41
+
42
+ // See equation (3) in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
43
+ float velvetLambda( float cosTheta, float alpha ) {
44
+
45
+ return abs( cosTheta ) < 0.5 ? exp( velvetL( cosTheta, alpha ) ) : exp( 2.0 * velvetL( 0.5, alpha ) - velvetL( 1.0 - cosTheta, alpha ) );
46
+
47
+ }
48
+
49
+ // See Section 3, Shadowing Term, in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
50
+ float velvetG( float cosThetaO, float cosThetaI, float roughness ) {
51
+
52
+ float alpha = max( roughness, 0.07 );
53
+ alpha = alpha * alpha;
54
+
55
+ return 1.0 / ( 1.0 + velvetLambda( cosThetaO, alpha ) + velvetLambda( cosThetaI, alpha ) );
56
+
57
+ }
58
+
59
+ float directionalAlbedoSheen( float cosTheta, float alpha ) {
60
+
61
+ cosTheta = saturate( cosTheta );
62
+
63
+ float c = 1.0 - cosTheta;
64
+ float c3 = c * c * c;
65
+
66
+ return 0.65584461 * c3 + 1.0 / ( 4.16526551 + exp( -7.97291361 * sqrt( alpha ) + 6.33516894 ) );
67
+
68
+ }
69
+
70
+ float sheenAlbedoScaling( vec3 wo, vec3 wi, SurfaceRec surf ) {
71
+
72
+ float alpha = max( surf.sheenRoughness, 0.07 );
73
+ alpha = alpha * alpha;
74
+
75
+ float maxSheenColor = max( max( surf.sheenColor.r, surf.sheenColor.g ), surf.sheenColor.b );
76
+
77
+ float eWo = directionalAlbedoSheen( saturateCos( wo.z ), alpha );
78
+ float eWi = directionalAlbedoSheen( saturateCos( wi.z ), alpha );
79
+
80
+ return min( 1.0 - maxSheenColor * eWo, 1.0 - maxSheenColor * eWi );
81
+
82
+ }
83
+
84
+ // See Section 5, Layering, in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
85
+ float sheenAlbedoScaling( vec3 wo, SurfaceRec surf ) {
86
+
87
+ float alpha = max( surf.sheenRoughness, 0.07 );
88
+ alpha = alpha * alpha;
89
+
90
+ float maxSheenColor = max( max( surf.sheenColor.r, surf.sheenColor.g ), surf.sheenColor.b );
91
+
92
+ float eWo = directionalAlbedoSheen( saturateCos( wo.z ), alpha );
93
+
94
+ return 1.0 - maxSheenColor * eWo;
95
+
96
+ }
97
+
98
+ `;