@meimu/mutracer 0.2.0 → 0.3.0

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 (211) hide show
  1. package/README.md +3 -0
  2. package/dist/assets/bvh.worker.js +1 -1
  3. package/dist/mutracer.umd.js +8949 -7915
  4. package/docs/api.md +42 -21
  5. package/docs/caustics.md +80 -0
  6. package/docs/materials.md +5 -4
  7. package/docs/progressive-rendering.md +50 -9
  8. package/docs/technical/continuous-spectrum.md +93 -0
  9. package/docs/updates.md +3 -1
  10. package/docs/viewer-checklist.md +65 -0
  11. package/docs/viewer.md +7 -5
  12. package/lib/Display.js +1 -1
  13. package/lib/Display.js.map +1 -1
  14. package/lib/Engine.d.ts +2 -0
  15. package/lib/Engine.js +47 -12
  16. package/lib/Engine.js.map +1 -1
  17. package/lib/Render.d.ts +61 -13
  18. package/lib/Render.js +169 -19
  19. package/lib/Render.js.map +1 -1
  20. package/lib/RenderLoop.d.ts +7 -3
  21. package/lib/RenderLoop.js +68 -44
  22. package/lib/RenderLoop.js.map +1 -1
  23. package/lib/main.d.ts +1 -1
  24. package/lib/main.js.map +1 -1
  25. package/lib/oidn.d.ts +1 -1
  26. package/lib/oidnBundledWeights.cdn.d.ts +2 -2
  27. package/lib/renderer/GPUTraceQueue.d.ts +2 -1
  28. package/lib/renderer/GPUTraceQueue.js +3 -1
  29. package/lib/renderer/GPUTraceQueue.js.map +1 -1
  30. package/lib/renderer/RenderingPipeline.d.ts +4 -0
  31. package/lib/renderer/RenderingPipeline.js.map +1 -1
  32. package/lib/renderer/WGPUCausticLightPass.d.ts +48 -0
  33. package/lib/renderer/WGPUCausticLightPass.js +217 -0
  34. package/lib/renderer/WGPUCausticLightPass.js.map +1 -0
  35. package/lib/renderer/WGPUEnvMapDistribution.js +18 -18
  36. package/lib/renderer/WGPUFullQuadPass.js +3 -3
  37. package/lib/renderer/WGPUPhotonMap.d.ts +37 -0
  38. package/lib/renderer/WGPUPhotonMap.js +191 -0
  39. package/lib/renderer/WGPUPhotonMap.js.map +1 -0
  40. package/lib/renderer/WGPURayTraceOutput.d.ts +13 -1
  41. package/lib/renderer/WGPURayTraceOutput.js +122 -28
  42. package/lib/renderer/WGPURayTraceOutput.js.map +1 -1
  43. package/lib/renderer/WGPURayTracePass.d.ts +48 -17
  44. package/lib/renderer/WGPURayTracePass.js +538 -340
  45. package/lib/renderer/WGPURayTracePass.js.map +1 -1
  46. package/lib/renderer/WGPURenderingPipeline.js +83 -47
  47. package/lib/renderer/WGPURenderingPipeline.js.map +1 -1
  48. package/lib/renderer/WebGLFullQuadPass.d.ts +2 -1
  49. package/lib/renderer/WebGLFullQuadPass.js +4 -0
  50. package/lib/renderer/WebGLFullQuadPass.js.map +1 -1
  51. package/lib/renderer/WebGLJNLMDenoiser.js +66 -66
  52. package/lib/renderer/WebGLRayTraceOutputPass.js +4 -4
  53. package/lib/renderer/WebGLRayTracePass.d.ts +6 -1
  54. package/lib/renderer/WebGLRayTracePass.js +43 -6
  55. package/lib/renderer/WebGLRayTracePass.js.map +1 -1
  56. package/lib/renderer/WebGLRenderingPipeline.js +10 -14
  57. package/lib/renderer/WebGLRenderingPipeline.js.map +1 -1
  58. package/lib/renderer/WebGLSkyBaker.js +60 -60
  59. package/lib/renderer/accumulationTarget.d.ts +2 -1
  60. package/lib/renderer/accumulationTarget.js.map +1 -1
  61. package/lib/renderer/causticDiagnostics.d.ts +31 -0
  62. package/lib/renderer/causticDiagnostics.js +5 -0
  63. package/lib/renderer/causticDiagnostics.js.map +1 -0
  64. package/lib/renderer/causticEmission.d.ts +10 -0
  65. package/lib/renderer/causticEmission.js +40 -0
  66. package/lib/renderer/causticEmission.js.map +1 -0
  67. package/lib/renderer/causticUniform.d.ts +12 -0
  68. package/lib/renderer/causticUniform.js +22 -0
  69. package/lib/renderer/causticUniform.js.map +1 -0
  70. package/lib/renderer/caustics.d.ts +16 -0
  71. package/lib/renderer/caustics.js +93 -0
  72. package/lib/renderer/caustics.js.map +1 -0
  73. package/lib/renderer/glsl/aovDisplay.frag.js +5 -5
  74. package/lib/renderer/glsl/aovReflectance.glsl.js +53 -53
  75. package/lib/renderer/glsl/aovReflectanceSamples.glsl.js +1 -1
  76. package/lib/renderer/glsl/aovTrace.frag.js +33 -33
  77. package/lib/renderer/glsl/chunks/cameraRay.glsl.js +9 -9
  78. package/lib/renderer/glsl/chunks/emissiveLight.glsl.d.ts +2 -0
  79. package/lib/renderer/glsl/chunks/emissiveLight.glsl.js +35 -0
  80. package/lib/renderer/glsl/chunks/emissiveLight.glsl.js.map +1 -0
  81. package/lib/renderer/glsl/chunks/envMap.glsl.js +73 -73
  82. package/lib/renderer/glsl/chunks/intersect.glsl.js +426 -428
  83. package/lib/renderer/glsl/chunks/intersect.glsl.js.map +1 -1
  84. package/lib/renderer/glsl/chunks/materialBuffer.glsl.d.ts +1 -0
  85. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +156 -153
  86. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js.map +1 -1
  87. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +771 -771
  88. package/lib/renderer/glsl/chunks/rand.glsl.js +3 -3
  89. package/lib/renderer/glsl/chunks/random.glsl.js +6 -6
  90. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.d.ts +1 -0
  91. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +68 -63
  92. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js.map +1 -1
  93. package/lib/renderer/glsl/chunks/sampleLight.glsl.js +94 -76
  94. package/lib/renderer/glsl/chunks/sampleLight.glsl.js.map +1 -1
  95. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.d.ts +1 -0
  96. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +140 -117
  97. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js.map +1 -1
  98. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +14 -14
  99. package/lib/renderer/glsl/chunks/sampling.glsl.js +89 -92
  100. package/lib/renderer/glsl/chunks/sampling.glsl.js.map +1 -1
  101. package/lib/renderer/glsl/chunks/sobol.glsl.js +79 -79
  102. package/lib/renderer/glsl/chunks/textureLinear.glsl.js +5 -5
  103. package/lib/renderer/glsl/chunks/uvProjection.glsl.js +11 -11
  104. package/lib/renderer/glsl/depthQuery.frag.js +2 -2
  105. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +10 -10
  106. package/lib/renderer/glsl/rayTrace.frag.d.ts +1 -1
  107. package/lib/renderer/glsl/rayTrace.frag.js +260 -237
  108. package/lib/renderer/glsl/rayTrace.frag.js.map +1 -1
  109. package/lib/renderer/glsl/shadowCatcher.frag.js +26 -26
  110. package/lib/renderer/glsl/shadowCatcher.frag.js.map +1 -1
  111. package/lib/renderer/glsl/webglPipeline.frag.js +59 -59
  112. package/lib/renderer/lightSampling.d.ts +3 -2
  113. package/lib/renderer/lightSampling.js +14 -8
  114. package/lib/renderer/lightSampling.js.map +1 -1
  115. package/lib/renderer/progressiveScheduler.js +4 -3
  116. package/lib/renderer/progressiveScheduler.js.map +1 -1
  117. package/lib/renderer/renderPipeline.d.ts +1 -0
  118. package/lib/renderer/renderPipeline.js.map +1 -1
  119. package/lib/renderer/researchTransport.d.ts +31 -0
  120. package/lib/renderer/researchTransport.js +5 -0
  121. package/lib/renderer/researchTransport.js.map +1 -0
  122. package/lib/renderer/sceneLayoutSchema.d.ts +1 -0
  123. package/lib/renderer/sceneLayoutSchema.js +2 -2
  124. package/lib/renderer/sceneLayoutSchema.js.map +1 -1
  125. package/lib/renderer/scratchSampling.js +6 -6
  126. package/lib/renderer/spectrum.d.ts +21 -0
  127. package/lib/renderer/spectrum.js +154 -0
  128. package/lib/renderer/spectrum.js.map +1 -0
  129. package/lib/renderer/webglLightSampling.d.ts +39 -0
  130. package/lib/renderer/webglLightSampling.js +15 -0
  131. package/lib/renderer/webglLightSampling.js.map +1 -0
  132. package/lib/renderer/wgpuBindlessSource.js +3 -3
  133. package/lib/renderer/wgpuShaderSource.d.ts +7 -0
  134. package/lib/renderer/wgpuShaderSource.js +2 -0
  135. package/lib/renderer/wgpuShaderSource.js.map +1 -1
  136. package/lib/renderer/wgsl/aovDisplay.wgsl.js +9 -9
  137. package/lib/renderer/wgsl/aovReflectance.wgsl.js +55 -55
  138. package/lib/renderer/wgsl/aovReflectanceSamples.wgsl.js +1 -1
  139. package/lib/renderer/wgsl/aovResolve.wgsl.js +2 -2
  140. package/lib/renderer/wgsl/aovSnapshot.wgsl.js +1 -1
  141. package/lib/renderer/wgsl/aovTrace.wgsl.js +33 -33
  142. package/lib/renderer/wgsl/bloom.wgsl.js +18 -18
  143. package/lib/renderer/wgsl/causticLight.compute.d.ts +6 -0
  144. package/lib/renderer/wgsl/causticLight.compute.js +537 -0
  145. package/lib/renderer/wgsl/causticLight.compute.js.map +1 -0
  146. package/lib/renderer/wgsl/chunks/background.wgsl.d.ts +2 -0
  147. package/lib/renderer/wgsl/chunks/background.wgsl.js +102 -0
  148. package/lib/renderer/wgsl/chunks/background.wgsl.js.map +1 -0
  149. package/lib/renderer/wgsl/chunks/causticAdjoint.wgsl.d.ts +2 -0
  150. package/lib/renderer/wgsl/chunks/causticAdjoint.wgsl.js +12 -0
  151. package/lib/renderer/wgsl/chunks/causticAdjoint.wgsl.js.map +1 -0
  152. package/lib/renderer/wgsl/chunks/causticAtomic.wgsl.d.ts +2 -0
  153. package/lib/renderer/wgsl/chunks/causticAtomic.wgsl.js +16 -0
  154. package/lib/renderer/wgsl/chunks/causticAtomic.wgsl.js.map +1 -0
  155. package/lib/renderer/wgsl/chunks/caustics.wgsl.d.ts +1 -0
  156. package/lib/renderer/wgsl/chunks/caustics.wgsl.js +62 -0
  157. package/lib/renderer/wgsl/chunks/caustics.wgsl.js.map +1 -0
  158. package/lib/renderer/wgsl/chunks/common.wgsl.js +4 -4
  159. package/lib/renderer/wgsl/chunks/envMap.wgsl.js +37 -37
  160. package/lib/renderer/wgsl/chunks/intersect.wgsl.js +598 -592
  161. package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -1
  162. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +14 -14
  163. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.d.ts +2 -1
  164. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +75 -73
  165. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js.map +1 -1
  166. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +794 -794
  167. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +139 -139
  168. package/lib/renderer/wgsl/chunks/rand.wgsl.js +3 -3
  169. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.d.ts +2 -1
  170. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +35 -25
  171. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js.map +1 -1
  172. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.d.ts +1 -1
  173. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +142 -138
  174. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js.map +1 -1
  175. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.d.ts +1 -1
  176. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +204 -187
  177. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js.map +1 -1
  178. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.d.ts +1 -1
  179. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +11 -11
  180. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js.map +1 -1
  181. package/lib/renderer/wgsl/chunks/sampling.wgsl.d.ts +1 -1
  182. package/lib/renderer/wgsl/chunks/sampling.wgsl.js +89 -93
  183. package/lib/renderer/wgsl/chunks/sampling.wgsl.js.map +1 -1
  184. package/lib/renderer/wgsl/chunks/sobol.wgsl.js +83 -83
  185. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +11 -11
  186. package/lib/renderer/wgsl/compose.frag.wgsl.js +98 -98
  187. package/lib/renderer/wgsl/customDenoise.wgsl.js +10 -10
  188. package/lib/renderer/wgsl/depthQuery.wgsl.js +2 -2
  189. package/lib/renderer/wgsl/jnlm.compute.js +74 -74
  190. package/lib/renderer/wgsl/offlineAdaptive.compute.js +25 -25
  191. package/lib/renderer/wgsl/oidnAuxiliary.wgsl.js +3 -3
  192. package/lib/renderer/wgsl/photonMap.compute.d.ts +29 -0
  193. package/lib/renderer/wgsl/photonMap.compute.js +352 -0
  194. package/lib/renderer/wgsl/photonMap.compute.js.map +1 -0
  195. package/lib/renderer/wgsl/proceduralSky.compute.js +64 -64
  196. package/lib/renderer/wgsl/rayTrace.compute.d.ts +9 -1
  197. package/lib/renderer/wgsl/rayTrace.compute.js +448 -522
  198. package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -1
  199. package/lib/scene/MaterialState.d.ts +2 -2
  200. package/lib/scene/MaterialState.js +2 -2
  201. package/lib/scene/MaterialState.js.map +1 -1
  202. package/lib/settings/render.d.ts +11 -0
  203. package/lib/settings/render.js +1 -0
  204. package/lib/settings/render.js.map +1 -1
  205. package/lib/util/fromTHREE.js +2 -2
  206. package/lib/util/fromTHREE.js.map +1 -1
  207. package/lib/version.d.ts +1 -1
  208. package/lib/version.js +1 -1
  209. package/lib/version.js.map +1 -1
  210. package/llms.txt +2 -1
  211. package/package.json +3 -3
@@ -4,71 +4,71 @@ export default glsl `
4
4
 
5
5
 
6
6
 
7
- vec3 aD(vec3 view, vec2 alpha, vec2 samplePoint) {
8
- vec3 sv = vec3(alpha, 1.0);
9
- vec3 cr = normalize(sv * view);
10
- float qP = min(cr.z, 1.0);
11
- float kh = 1.0 + qP;
12
- float kC = (1.0 - samplePoint.y) * kh;
13
- float sU = samplePoint.y * kh;
14
- float tY = kC + (1.0 - qP);
15
- float ex = sqrt(max(0.0, tY * sU));
7
+ vec3 aA(vec3 view, vec2 alpha, vec2 samplePoint) {
8
+ vec3 sn = vec3(alpha, 1.0);
9
+ vec3 ce = normalize(sn * view);
10
+ float qG = min(ce.z, 1.0);
11
+ float jN = 1.0 + qG;
12
+ float kf = (1.0 - samplePoint.y) * jN;
13
+ float sR = samplePoint.y * jN;
14
+ float ub = kf + (1.0 - qG);
15
+ float dr = sqrt(max(0.0, ub * sR));
16
16
  float azimuth = TWOPI * samplePoint.x;
17
- vec3 mr = vec3(
18
- cr.x + ex * cos(azimuth),
19
- cr.y + ex * sin(azimuth),
20
- kC
17
+ vec3 lX = vec3(
18
+ ce.x + dr * cos(azimuth),
19
+ ce.y + dr * sin(azimuth),
20
+ kf
21
21
  );
22
- return normalize(sv * mr);
22
+ return normalize(sn * lX);
23
23
  }
24
24
 
25
- float cW(vec3 pf, vec2 alpha) {
26
- vec3 hF = vec3(
27
- pf.x / alpha.x,
28
- pf.y / alpha.y,
29
- pf.z
25
+ float sampling_ggx_ndf(vec3 oU, vec2 alpha) {
26
+ vec3 hl = vec3(
27
+ oU.x / alpha.x,
28
+ oU.y / alpha.y,
29
+ oU.z
30
30
  );
31
- float aq = dot(hF, hF);
31
+ float ah = dot(hl, hl);
32
32
  return 1.0 / (
33
- PI * alpha.x * alpha.y * aq * aq
33
+ PI * alpha.x * alpha.y * ah * ah
34
34
  );
35
35
  }
36
36
 
37
- float aF(vec3 direction, vec2 alpha) {
38
- float eQ = abs(direction.z);
39
- if (eQ <= 1e-8) {
37
+ float aD(vec3 direction, vec2 alpha) {
38
+ float eB = abs(direction.z);
39
+ if (eB <= 1e-8) {
40
40
  return 0.0;
41
41
  }
42
- vec2 iE = alpha * direction.xy;
43
- float mt = dot(iE, iE)
44
- / (eQ * eQ);
45
- return 2.0 / (1.0 + sqrt(1.0 + mt));
42
+ vec2 hZ = alpha * direction.xy;
43
+ float lY = dot(hZ, hZ)
44
+ / (eB * eB);
45
+ return 2.0 / (1.0 + sqrt(1.0 + lY));
46
46
  }
47
47
 
48
- float aI(float cosine) {
49
- float dw = clamp(1.0 - cosine, 0.0, 1.0);
50
- return pow(dw, 5.0);
48
+ float aH(float cosine) {
49
+ float cY = clamp(1.0 - cosine, 0.0, 1.0);
50
+ return pow(cY, 5.0);
51
51
  }
52
52
 
53
- float cC(float J, float cR) {
54
- float iS = clamp(abs(J), 0.0, 1.0);
55
- float kQ = cR * cR
56
- * max(0.0, 1.0 - iS * iS);
57
- if (kQ >= 1.0) {
53
+ float sampling_dielectric_fresnel(float J, float cE) {
54
+ float iB = clamp(abs(J), 0.0, 1.0);
55
+ float kv = cE * cE
56
+ * max(0.0, 1.0 - iB * iB);
57
+ if (kv >= 1.0) {
58
58
  return 1.0;
59
59
  }
60
60
 
61
- float mD = sqrt(max(0.0, 1.0 - kQ));
62
- float bk = (iS - cR * mD)
63
- / max(iS + cR * mD, 1e-8);
64
- float qC = (cR * iS - mD)
65
- / max(cR * iS + mD, 1e-8);
61
+ float ml = sqrt(max(0.0, 1.0 - kv));
62
+ float bd = (iB - cE * ml)
63
+ / max(iB + cE * ml, 1e-8);
64
+ float qu = (cE * iB - ml)
65
+ / max(cE * iB + ml, 1e-8);
66
66
  return 0.5 * (
67
- bk * bk + qC * qC
67
+ bd * bd + qu * qu
68
68
  );
69
69
  }
70
70
 
71
- vec2 gy(vec2 samplePoint) {
71
+ vec2 gi(vec2 samplePoint) {
72
72
  vec2 offset = 2.0 * samplePoint - vec2(1.0);
73
73
  if (offset.x == 0.0 && offset.y == 0.0) {
74
74
  return vec2(0.0);
@@ -87,78 +87,75 @@ angle = 0.5 * PI - 0.25 * PI * (offset.x / offset.y);
87
87
  return radius * vec2(cos(angle), sin(angle));
88
88
  }
89
89
 
90
- vec3 aO(vec2 samplePoint) {
91
- vec2 lk = gy(samplePoint);
90
+ vec3 aM(vec2 samplePoint) {
91
+ vec2 kS = gi(samplePoint);
92
92
  return vec3(
93
- lk,
94
- sqrt(max(0.0, 1.0 - dot(lk, lk)))
93
+ kS,
94
+ sqrt(max(0.0, 1.0 - dot(kS, kS)))
95
95
  );
96
96
  }
97
97
 
98
- float aK(float qo, float oJ) {
99
- float scale = max(qo, oJ);
98
+ float aF(float firstPdf, float secondPdf) {
99
+ float scale = max(firstPdf, secondPdf);
100
100
  if (scale <= 0.0) {
101
101
  return 0.0;
102
102
  }
103
- vec2 normalized = vec2(qo, oJ) / scale;
104
- vec2 pL = normalized * normalized;
105
- return pL.x / (pL.x + pL.y);
103
+ vec2 normalized = vec2(firstPdf, secondPdf) / scale;
104
+ vec2 pq = normalized * normalized;
105
+ return pq.x / (pq.x + pq.y);
106
106
  }
107
107
 
108
- void aP(in vec3 normal, out vec3 tangent, out vec3 bitangent) {
109
- float iI = normal.z >= 0.0 ? 1.0 : -1.0;
110
- float cL = -1.0 / (iI + normal.z);
111
- float xy = normal.x * normal.y * cL;
108
+ void sampling_orthonormal_basis(in vec3 normal, out vec3 tangent, out vec3 bitangent) {
109
+ float ik = normal.z >= 0.0 ? 1.0 : -1.0;
110
+ float cv = -1.0 / (ik + normal.z);
111
+ float xy = normal.x * normal.y * cv;
112
112
  tangent = vec3(
113
- 1.0 + iI * normal.x * normal.x * cL,
114
- iI * xy,
115
- -iI * normal.x
113
+ 1.0 + ik * normal.x * normal.x * cv,
114
+ ik * xy,
115
+ -ik * normal.x
116
116
  );
117
117
  bitangent = vec3(
118
118
  xy,
119
- iI + normal.y * normal.y * cL,
119
+ ik + normal.y * normal.y * cv,
120
120
  -normal.y
121
121
  );
122
122
  }
123
123
 
124
- vec3 aj(vec3 rgb, float wavelength) {
125
- if (wavelength == 0.0) {
124
+ vec3 sampling_spectral_rgb_filter(vec3 rgb, int channel) {
125
+ if (channel == 0) {
126
126
  return rgb;
127
127
  }
128
- vec3 vk = wavelength > 600.0
129
- ? vec3(1.0, 0.0, 0.0)
130
- : wavelength > 500.0
131
- ? vec3(0.0, 1.0, 0.0)
132
- : vec3(0.0, 0.0, 1.0);
133
- return rgb * vk;
128
+ vec3 sZ = vec3(0.0);
129
+ sZ[channel - 1] = 1.0;
130
+ return rgb * sZ;
134
131
  }
135
132
 
136
- float ee(
133
+ float sampling_cauchy_ior(
137
134
  float wavelength,
138
- float hu,
139
- float hD,
140
- float rt
135
+ float ha,
136
+ float hk,
137
+ float rm
141
138
  ) {
142
- if (wavelength == 0.0 || hD <= 0.0) {
143
- return hu;
139
+ if (wavelength == 0.0 || hk <= 0.0) {
140
+ return ha;
144
141
  }
145
142
 
146
143
  const float FRAUNHOFER_C = 656.3;
147
144
  const float FRAUNHOFER_D = 587.6;
148
145
  const float FRAUNHOFER_F = 486.1;
149
- float kv = 1.0 / (
146
+ float jX = 1.0 / (
150
147
  1.0 / (FRAUNHOFER_F * FRAUNHOFER_F)
151
148
  - 1.0 / (FRAUNHOFER_C * FRAUNHOFER_C)
152
149
  );
153
- float oe = max(rt / hD, 1e-6);
154
- float rV = (hu - 1.0) * kv / oe;
155
- float uK = hu
156
- - rV / (FRAUNHOFER_D * FRAUNHOFER_D);
157
- return uK + rV / (wavelength * wavelength);
150
+ float nU = max(rm / hk, 1e-6);
151
+ float rR = (ha - 1.0) * jX / nU;
152
+ float uO = ha
153
+ - rR / (FRAUNHOFER_D * FRAUNHOFER_D);
154
+ return uO + rR / (wavelength * wavelength);
158
155
  }
159
156
 
160
- vec3 fH(
161
- vec3 gO,
157
+ vec3 fj(
158
+ vec3 gw,
162
159
  float anisotropy,
163
160
  vec2 samplePoint
164
161
  ) {
@@ -167,28 +164,28 @@ if (abs(anisotropy) < 0.001) {
167
164
  cosine = 1.0 - 2.0 * samplePoint.y;
168
165
  }
169
166
  else {
170
- float ju = (1.0 - anisotropy * anisotropy)
167
+ float iZ = (1.0 - anisotropy * anisotropy)
171
168
  / (1.0 + anisotropy - 2.0 * anisotropy * samplePoint.y);
172
169
  cosine = (
173
- ju * ju - 1.0 - anisotropy * anisotropy
170
+ iZ * iZ - 1.0 - anisotropy * anisotropy
174
171
  ) / (2.0 * anisotropy);
175
172
  }
176
173
 
177
- float vF = sqrt(max(0.0, 1.0 - cosine * cosine));
174
+ float uC = sqrt(max(0.0, 1.0 - cosine * cosine));
178
175
  float azimuth = TWOPI * samplePoint.x;
179
176
  vec3 tangent;
180
177
  vec3 bitangent;
181
- aP(gO, tangent, bitangent);
182
- return tangent * (vF * cos(azimuth))
183
- + bitangent * (vF * sin(azimuth))
184
- + gO * cosine;
178
+ sampling_orthonormal_basis(gw, tangent, bitangent);
179
+ return tangent * (uC * cos(azimuth))
180
+ + bitangent * (uC * sin(azimuth))
181
+ + gw * cosine;
185
182
  }
186
183
 
187
- float bL(float cosine, float anisotropy) {
188
- float aq = 1.0 + anisotropy * anisotropy
184
+ float bB(float cosine, float anisotropy) {
185
+ float ah = 1.0 + anisotropy * anisotropy
189
186
  + 2.0 * anisotropy * cosine;
190
187
  return INV4PI * (1.0 - anisotropy * anisotropy)
191
- / (aq * sqrt(aq));
188
+ / (ah * sqrt(ah));
192
189
  }
193
190
  `;
194
191
  //# sourceMappingURL=sampling.glsl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sampling.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/sampling.glsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+LlB,CAAC","sourcesContent":["import { glsl } from '../../shader.js';\n\nexport default glsl`\n// The GGX distribution and spherical-cap VNDF sampler are adapted from\n// adobe/openpbr-bsdf, Copyright 2026 Adobe, Apache-2.0. Other routines are\n// project implementations of their stated analytic distributions.\n\nvec3 sampling_ggx_visible_normal(vec3 view, vec2 alpha, vec2 samplePoint) {\n vec3 stretch = vec3(alpha, 1.0);\n vec3 sphericalView = normalize(stretch * view);\n float viewZ = min(sphericalView.z, 1.0);\n float capSpan = 1.0 + viewZ;\n float normalZ = (1.0 - samplePoint.y) * capSpan;\n float oneMinusZ = samplePoint.y * capSpan;\n float onePlusZ = normalZ + (1.0 - viewZ);\n float radial = sqrt(max(0.0, onePlusZ * oneMinusZ));\n float azimuth = TWOPI * samplePoint.x;\n vec3 sphericalNormal = vec3(\n sphericalView.x + radial * cos(azimuth),\n sphericalView.y + radial * sin(azimuth),\n normalZ\n );\n return normalize(stretch * sphericalNormal);\n}\n\nfloat sampling_ggx_ndf(vec3 halfway, vec2 alpha) {\n vec3 ellipsoidNormal = vec3(\n halfway.x / alpha.x,\n halfway.y / alpha.y,\n halfway.z\n );\n float denominator = dot(ellipsoidNormal, ellipsoidNormal);\n return 1.0 / (\n PI * alpha.x * alpha.y * denominator * denominator\n );\n}\n\nfloat sampling_ggx_smith_g1(vec3 direction, vec2 alpha) {\n float normalComponent = abs(direction.z);\n if (normalComponent <= 1e-8) {\n return 0.0;\n }\n vec2 roughDirection = alpha * direction.xy;\n float tanThetaSquared = dot(roughDirection, roughDirection)\n / (normalComponent * normalComponent);\n return 2.0 / (1.0 + sqrt(1.0 + tanThetaSquared));\n}\n\nfloat sampling_schlick_fifth_power(float cosine) {\n float complement = clamp(1.0 - cosine, 0.0, 1.0);\n return pow(complement, 5.0);\n}\n\nfloat sampling_dielectric_fresnel(float incidentCosine, float etaIOverEtaT) {\n float cosineI = clamp(abs(incidentCosine), 0.0, 1.0);\n float sineTSquared = etaIOverEtaT * etaIOverEtaT\n * max(0.0, 1.0 - cosineI * cosineI);\n if (sineTSquared >= 1.0) {\n return 1.0;\n }\n\n float cosineT = sqrt(max(0.0, 1.0 - sineTSquared));\n float perpendicular = (cosineI - etaIOverEtaT * cosineT)\n / max(cosineI + etaIOverEtaT * cosineT, 1e-8);\n float parallel = (etaIOverEtaT * cosineI - cosineT)\n / max(etaIOverEtaT * cosineI + cosineT, 1e-8);\n return 0.5 * (\n perpendicular * perpendicular + parallel * parallel\n );\n}\n\nvec2 sampling_concentric_disk(vec2 samplePoint) {\n vec2 offset = 2.0 * samplePoint - vec2(1.0);\n if (offset.x == 0.0 && offset.y == 0.0) {\n return vec2(0.0);\n }\n\n float radius;\n float angle;\n if (abs(offset.x) > abs(offset.y)) {\n radius = offset.x;\n angle = 0.25 * PI * (offset.y / offset.x);\n }\n else {\n radius = offset.y;\n angle = 0.5 * PI - 0.25 * PI * (offset.x / offset.y);\n }\n return radius * vec2(cos(angle), sin(angle));\n}\n\nvec3 sampling_cosine_hemisphere(vec2 samplePoint) {\n vec2 diskPoint = sampling_concentric_disk(samplePoint);\n return vec3(\n diskPoint,\n sqrt(max(0.0, 1.0 - dot(diskPoint, diskPoint)))\n );\n}\n\nfloat sampling_power_heuristic(float firstPdf, float secondPdf) {\n float scale = max(firstPdf, secondPdf);\n if (scale <= 0.0) {\n return 0.0;\n }\n vec2 normalized = vec2(firstPdf, secondPdf) / scale;\n vec2 squared = normalized * normalized;\n return squared.x / (squared.x + squared.y);\n}\n\nvoid sampling_orthonormal_basis(in vec3 normal, out vec3 tangent, out vec3 bitangent) {\n float signZ = normal.z >= 0.0 ? 1.0 : -1.0;\n float factor = -1.0 / (signZ + normal.z);\n float xy = normal.x * normal.y * factor;\n tangent = vec3(\n 1.0 + signZ * normal.x * normal.x * factor,\n signZ * xy,\n -signZ * normal.x\n );\n bitangent = vec3(\n xy,\n signZ + normal.y * normal.y * factor,\n -normal.y\n );\n}\n\nvec3 sampling_spectral_rgb_filter(vec3 rgb, float wavelength) {\n if (wavelength == 0.0) {\n return rgb;\n }\n vec3 channelMask = wavelength > 600.0\n ? vec3(1.0, 0.0, 0.0)\n : wavelength > 500.0\n ? vec3(0.0, 1.0, 0.0)\n : vec3(0.0, 0.0, 1.0);\n return rgb * channelMask;\n}\n\nfloat sampling_cauchy_ior(\n float wavelength,\n float referenceIor,\n float dispersionScale,\n float abbeNumber\n) {\n if (wavelength == 0.0 || dispersionScale <= 0.0) {\n return referenceIor;\n }\n\n const float FRAUNHOFER_C = 656.3;\n const float FRAUNHOFER_D = 587.6;\n const float FRAUNHOFER_F = 486.1;\n float inverseDifference = 1.0 / (\n 1.0 / (FRAUNHOFER_F * FRAUNHOFER_F)\n - 1.0 / (FRAUNHOFER_C * FRAUNHOFER_C)\n );\n float effectiveAbbe = max(abbeNumber / dispersionScale, 1e-6);\n float cauchyB = (referenceIor - 1.0) * inverseDifference / effectiveAbbe;\n float cauchyA = referenceIor\n - cauchyB / (FRAUNHOFER_D * FRAUNHOFER_D);\n return cauchyA + cauchyB / (wavelength * wavelength);\n}\n\nvec3 sampling_henyey_greenstein(\n vec3 forwardDirection,\n float anisotropy,\n vec2 samplePoint\n) {\n float cosine;\n if (abs(anisotropy) < 0.001) {\n cosine = 1.0 - 2.0 * samplePoint.y;\n }\n else {\n float ratio = (1.0 - anisotropy * anisotropy)\n / (1.0 + anisotropy - 2.0 * anisotropy * samplePoint.y);\n cosine = (\n ratio * ratio - 1.0 - anisotropy * anisotropy\n ) / (2.0 * anisotropy);\n }\n\n float sine = sqrt(max(0.0, 1.0 - cosine * cosine));\n float azimuth = TWOPI * samplePoint.x;\n vec3 tangent;\n vec3 bitangent;\n sampling_orthonormal_basis(forwardDirection, tangent, bitangent);\n return tangent * (sine * cos(azimuth))\n + bitangent * (sine * sin(azimuth))\n + forwardDirection * cosine;\n}\n\nfloat sampling_henyey_greenstein_phase(float cosine, float anisotropy) {\n float denominator = 1.0 + anisotropy * anisotropy\n + 2.0 * anisotropy * cosine;\n return INV4PI * (1.0 - anisotropy * anisotropy)\n / (denominator * sqrt(denominator));\n}\n`;\n"]}
1
+ {"version":3,"file":"sampling.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/sampling.glsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4LlB,CAAC","sourcesContent":["import { glsl } from '../../shader.js';\n\nexport default glsl`\n// The GGX distribution and spherical-cap VNDF sampler are adapted from\n// adobe/openpbr-bsdf, Copyright 2026 Adobe, Apache-2.0. Other routines are\n// project implementations of their stated analytic distributions.\n\nvec3 sampling_ggx_visible_normal(vec3 view, vec2 alpha, vec2 samplePoint) {\n vec3 stretch = vec3(alpha, 1.0);\n vec3 sphericalView = normalize(stretch * view);\n float viewZ = min(sphericalView.z, 1.0);\n float capSpan = 1.0 + viewZ;\n float normalZ = (1.0 - samplePoint.y) * capSpan;\n float oneMinusZ = samplePoint.y * capSpan;\n float onePlusZ = normalZ + (1.0 - viewZ);\n float radial = sqrt(max(0.0, onePlusZ * oneMinusZ));\n float azimuth = TWOPI * samplePoint.x;\n vec3 sphericalNormal = vec3(\n sphericalView.x + radial * cos(azimuth),\n sphericalView.y + radial * sin(azimuth),\n normalZ\n );\n return normalize(stretch * sphericalNormal);\n}\n\nfloat sampling_ggx_ndf(vec3 halfway, vec2 alpha) {\n vec3 ellipsoidNormal = vec3(\n halfway.x / alpha.x,\n halfway.y / alpha.y,\n halfway.z\n );\n float denominator = dot(ellipsoidNormal, ellipsoidNormal);\n return 1.0 / (\n PI * alpha.x * alpha.y * denominator * denominator\n );\n}\n\nfloat sampling_ggx_smith_g1(vec3 direction, vec2 alpha) {\n float normalComponent = abs(direction.z);\n if (normalComponent <= 1e-8) {\n return 0.0;\n }\n vec2 roughDirection = alpha * direction.xy;\n float tanThetaSquared = dot(roughDirection, roughDirection)\n / (normalComponent * normalComponent);\n return 2.0 / (1.0 + sqrt(1.0 + tanThetaSquared));\n}\n\nfloat sampling_schlick_fifth_power(float cosine) {\n float complement = clamp(1.0 - cosine, 0.0, 1.0);\n return pow(complement, 5.0);\n}\n\nfloat sampling_dielectric_fresnel(float incidentCosine, float etaIOverEtaT) {\n float cosineI = clamp(abs(incidentCosine), 0.0, 1.0);\n float sineTSquared = etaIOverEtaT * etaIOverEtaT\n * max(0.0, 1.0 - cosineI * cosineI);\n if (sineTSquared >= 1.0) {\n return 1.0;\n }\n\n float cosineT = sqrt(max(0.0, 1.0 - sineTSquared));\n float perpendicular = (cosineI - etaIOverEtaT * cosineT)\n / max(cosineI + etaIOverEtaT * cosineT, 1e-8);\n float parallel = (etaIOverEtaT * cosineI - cosineT)\n / max(etaIOverEtaT * cosineI + cosineT, 1e-8);\n return 0.5 * (\n perpendicular * perpendicular + parallel * parallel\n );\n}\n\nvec2 sampling_concentric_disk(vec2 samplePoint) {\n vec2 offset = 2.0 * samplePoint - vec2(1.0);\n if (offset.x == 0.0 && offset.y == 0.0) {\n return vec2(0.0);\n }\n\n float radius;\n float angle;\n if (abs(offset.x) > abs(offset.y)) {\n radius = offset.x;\n angle = 0.25 * PI * (offset.y / offset.x);\n }\n else {\n radius = offset.y;\n angle = 0.5 * PI - 0.25 * PI * (offset.x / offset.y);\n }\n return radius * vec2(cos(angle), sin(angle));\n}\n\nvec3 sampling_cosine_hemisphere(vec2 samplePoint) {\n vec2 diskPoint = sampling_concentric_disk(samplePoint);\n return vec3(\n diskPoint,\n sqrt(max(0.0, 1.0 - dot(diskPoint, diskPoint)))\n );\n}\n\nfloat sampling_power_heuristic(float firstPdf, float secondPdf) {\n float scale = max(firstPdf, secondPdf);\n if (scale <= 0.0) {\n return 0.0;\n }\n vec2 normalized = vec2(firstPdf, secondPdf) / scale;\n vec2 squared = normalized * normalized;\n return squared.x / (squared.x + squared.y);\n}\n\nvoid sampling_orthonormal_basis(in vec3 normal, out vec3 tangent, out vec3 bitangent) {\n float signZ = normal.z >= 0.0 ? 1.0 : -1.0;\n float factor = -1.0 / (signZ + normal.z);\n float xy = normal.x * normal.y * factor;\n tangent = vec3(\n 1.0 + signZ * normal.x * normal.x * factor,\n signZ * xy,\n -signZ * normal.x\n );\n bitangent = vec3(\n xy,\n signZ + normal.y * normal.y * factor,\n -normal.y\n );\n}\n\nvec3 sampling_spectral_rgb_filter(vec3 rgb, int channel) {\n if (channel == 0) {\n return rgb;\n }\n vec3 channelMask = vec3(0.0);\n channelMask[channel - 1] = 1.0;\n return rgb * channelMask;\n}\n\nfloat sampling_cauchy_ior(\n float wavelength,\n float referenceIor,\n float dispersionScale,\n float abbeNumber\n) {\n if (wavelength == 0.0 || dispersionScale <= 0.0) {\n return referenceIor;\n }\n\n const float FRAUNHOFER_C = 656.3;\n const float FRAUNHOFER_D = 587.6;\n const float FRAUNHOFER_F = 486.1;\n float inverseDifference = 1.0 / (\n 1.0 / (FRAUNHOFER_F * FRAUNHOFER_F)\n - 1.0 / (FRAUNHOFER_C * FRAUNHOFER_C)\n );\n float effectiveAbbe = max(abbeNumber / dispersionScale, 1e-6);\n float cauchyB = (referenceIor - 1.0) * inverseDifference / effectiveAbbe;\n float cauchyA = referenceIor\n - cauchyB / (FRAUNHOFER_D * FRAUNHOFER_D);\n return cauchyA + cauchyB / (wavelength * wavelength);\n}\n\nvec3 sampling_henyey_greenstein(\n vec3 forwardDirection,\n float anisotropy,\n vec2 samplePoint\n) {\n float cosine;\n if (abs(anisotropy) < 0.001) {\n cosine = 1.0 - 2.0 * samplePoint.y;\n }\n else {\n float ratio = (1.0 - anisotropy * anisotropy)\n / (1.0 + anisotropy - 2.0 * anisotropy * samplePoint.y);\n cosine = (\n ratio * ratio - 1.0 - anisotropy * anisotropy\n ) / (2.0 * anisotropy);\n }\n\n float sine = sqrt(max(0.0, 1.0 - cosine * cosine));\n float azimuth = TWOPI * samplePoint.x;\n vec3 tangent;\n vec3 bitangent;\n sampling_orthonormal_basis(forwardDirection, tangent, bitangent);\n return tangent * (sine * cos(azimuth))\n + bitangent * (sine * sin(azimuth))\n + forwardDirection * cosine;\n}\n\nfloat sampling_henyey_greenstein_phase(float cosine, float anisotropy) {\n float denominator = 1.0 + anisotropy * anisotropy\n + 2.0 * anisotropy * cosine;\n return INV4PI * (1.0 - anisotropy * anisotropy)\n / (denominator * sqrt(denominator));\n}\n`;\n"]}
@@ -24,41 +24,41 @@ const uint BOUNCE_STRIDE = 64u;
24
24
 
25
25
 
26
26
 
27
- uvec2 aZ;
28
- uint aQ;
29
- uint bT = 0u;
30
- uint cP = 0u;
31
- uint dG(uint kW) {
32
- uint x = kW;
27
+ uvec2 aI;
28
+ uint aC;
29
+ uint samplingBounce = 0u;
30
+ uint ca = 0u;
31
+ uint cB(uint kC) {
32
+ uint x = kC;
33
33
  x ^= x >> 16u; x *= 0x7feb352du;
34
34
  x ^= x >> 15u; x *= 0x846ca68bu;
35
35
  return x ^ (x >> 16u);
36
36
  }
37
- uint ar(uint a, uint b) {
38
- return dG(a ^ dG(b + 0x9e3779b9u));
37
+ uint ak(uint a, uint b) {
38
+ return cB(a ^ cB(b + 0x9e3779b9u));
39
39
  }
40
- uint iV(uint kW, uint seed) {
41
- uint x = kW + seed;
40
+ uint iD(uint kC, uint seed) {
41
+ uint x = kC + seed;
42
42
  x ^= x * 0x6c50b47cu; x ^= x * 0xb82f1e52u;
43
43
  x ^= x * 0xc7afe638u; x ^= x * 0x8d22f6e6u;
44
44
  return x;
45
45
  }
46
- uint ua(uint x, uint seed) {
47
- return reverseBits(iV(reverseBits(x), seed));
46
+ uint ud(uint x, uint seed) {
47
+ return reverseBits(iD(reverseBits(x), seed));
48
48
  }
49
49
 
50
- uint su(uint kW) {
51
- uint r = reverseBits(kW);
50
+ uint sm(uint kC) {
51
+ uint r = reverseBits(kC);
52
52
  ${sobolD1Steps.map(([shift, mask]) => `r ^= (r << ${shift}u) & 0x${mask.toString(16)}u;`).join("\n ")}
53
53
  return r;
54
54
  }
55
- vec2 xE(uint index, uint seed) {
56
- uint i = ua(index, ar(seed, 0u));
57
- uint x = reverseBits(iV(i, ar(seed, 1u)));
58
- uint y = ua(su(i), ar(seed, 2u));
55
+ vec2 yf(uint index, uint seed) {
56
+ uint i = ud(index, ak(seed, 0u));
57
+ uint x = reverseBits(iD(i, ak(seed, 1u)));
58
+ uint y = ud(sm(i), ak(seed, 2u));
59
59
  return vec2(float(x >> 8u), float(y >> 8u)) * (1.0 / 16777216.0);
60
60
  }
61
- uint uR(uvec2 p) {
61
+ uint uX(uvec2 p) {
62
62
  uvec2 v = p & uvec2(255u);
63
63
  v = (v | (v << uvec2(4u))) & uvec2(0x0f0fu);
64
64
  v = (v | (v << uvec2(2u))) & uvec2(0x3333u);
@@ -66,104 +66,104 @@ v = (v | (v << uvec2(1u))) & uvec2(0x5555u);
66
66
  return v.x | (v.y << 1u);
67
67
  }
68
68
  ${zSobolPackedPermutations.map((v, i) => `const uint Z_PERM_${i} = ${v}u;`).join("\n")}
69
- uint la(uint uU) {
70
- uint group = uU >> 2u;
69
+ uint kG(uint va) {
70
+ uint group = va >> 2u;
71
71
  uint word = Z_PERM_5;
72
72
  ${[0, 1, 2, 3, 4].map(i => `word = group == ${i}u ? Z_PERM_${i} : word;`).join("\n ")}
73
- return (word >> ((uU & 3u) * 8u)) & 255u;
73
+ return (word >> ((va & 3u) * 8u)) & 255u;
74
74
  }
75
- uint qS(uint lu, uint dim, uint logSPP) {
75
+ uint qJ(uint kY, uint dim, uint logSPP) {
76
76
  uint odd = logSPP & 1u;
77
- uint vN = 8u + ((logSPP + 1u) >> 1u);
77
+ uint wb = 8u + ((logSPP + 1u) >> 1u);
78
78
  uint result = 0u;
79
- for (int digit = int(vN) - 1; digit >= int(odd); digit--) {
79
+ for (int digit = int(wb) - 1; digit >= int(odd); digit--) {
80
80
  uint shift = 2u*uint(digit) - odd;
81
81
 
82
- uint tL = 0u;
83
- if (shift < 30u) { tL = lu >> (shift + 2u); }
84
- uint uU = (dG(tL ^ (0x55555555u * dim)) >> 24u) % 24u;
85
- uint d = (lu >> shift) & 3u;
86
- result |= ((la(uU) >> (2u*d)) & 3u) << shift;
82
+ uint tN = 0u;
83
+ if (shift < 30u) { tN = kY >> (shift + 2u); }
84
+ uint va = (cB(tN ^ (0x55555555u * dim)) >> 24u) % 24u;
85
+ uint d = (kY >> shift) & 3u;
86
+ result |= ((kG(va) >> (2u*d)) & 3u) << shift;
87
87
  }
88
88
  if (odd != 0u) {
89
- result |= (lu & 1u) ^ (dG((lu >> 1u) ^ (0x55555555u * dim)) & 1u);
89
+ result |= (kY & 1u) ^ (cB((kY >> 1u) ^ (0x55555555u * dim)) & 1u);
90
90
  }
91
91
  return result;
92
92
  }
93
93
 
94
94
 
95
95
 
96
- uint cE(uint slot) {
97
- return CAMERA_BEVEL_BASE + uint(BEVEL_SAMPLES) + bT * BOUNCE_STRIDE + slot;
96
+ uint bE(uint slot) {
97
+ return CAMERA_BEVEL_BASE + uint(BEVEL_SAMPLES) + samplingBounce * BOUNCE_STRIDE + slot;
98
98
  }
99
99
 
100
- uvec4 hA;
101
- uint hB;
102
- bool fQ = false;
103
- bool dv = false;
104
- uint dQ;
105
- uint gK;
106
- vec2 fa;
107
- void dN(uint dim) {
100
+ uvec4 hg;
101
+ uint hh;
102
+ bool fA = false;
103
+ bool cX = false;
104
+ uint dD;
105
+ uint gt;
106
+ vec2 eJ;
107
+ void dm(uint dim) {
108
108
 
109
- uint kI = aZ.x + aZ.y * uint(round(1.0 / pixelSize.x));
110
- uvec4 key = uvec4(dim, aQ, kI, uint(sequenceSeed));
111
- if (fQ && all(equal(hA, key)) && hB == uint(zSobolLogSPP)) { return; }
112
- hA = key; hB = uint(zSobolLogSPP);
113
- fQ = true; dv = false;
114
- uint seed = ar(ar(kI, dim), uint(sequenceSeed));
115
- uint index = aQ;
109
+ uint kl = aI.x + aI.y * uint(round(1.0 / pixelSize.x));
110
+ uvec4 key = uvec4(dim, aC, kl, uint(sequenceSeed));
111
+ if (fA && all(equal(hg, key)) && hh == uint(zSobolLogSPP)) { return; }
112
+ hg = key; hh = uint(zSobolLogSPP);
113
+ fA = true; cX = false;
114
+ uint seed = ak(ak(kl, dim), uint(sequenceSeed));
115
+ uint index = aC;
116
116
  if (samplingPattern == 1) {
117
117
  uint logSPP = uint(zSobolLogSPP);
118
118
  if (index == 0u) { logSPP = 0u; }
119
119
  else { index -= 1u; }
120
120
 
121
- uint jw = index >> logSPP;
121
+ uint jd = index >> logSPP;
122
122
  uint mask = (1u << logSPP) - 1u;
123
- uint lu = (uR(aZ) << logSPP) | (index & mask);
124
- index = qS(lu, dim, logSPP);
125
- uvec2 tile = aZ >> uvec2(8u);
126
- seed = ar(ar(dim, uint(sequenceSeed)), ar(tile.x, tile.y));
123
+ uint kY = (uX(aI) << logSPP) | (index & mask);
124
+ index = qJ(kY, dim, logSPP);
125
+ uvec2 tile = aI >> uvec2(8u);
126
+ seed = ak(ak(dim, uint(sequenceSeed)), ak(tile.x, tile.y));
127
127
 
128
- if (aQ != 0u) { jw += 1u; }
129
- seed = ar(seed, jw);
128
+ if (aC != 0u) { jd += 1u; }
129
+ seed = ak(seed, jd);
130
130
  }
131
- dQ = ua(index, ar(seed, 0u));
132
- gK = seed;
133
- uint x = reverseBits(iV(dQ, ar(seed, 1u)));
134
- fa.x = float(x >> 8u) * (1.0 / 16777216.0);
131
+ dD = ud(index, ak(seed, 0u));
132
+ gt = seed;
133
+ uint x = reverseBits(iD(dD, ak(seed, 1u)));
134
+ eJ.x = float(x >> 8u) * (1.0 / 16777216.0);
135
135
  }
136
- vec2 lC(uint dim) {
137
- dN(dim);
138
- if (!dv) {
139
- uint y = ua(su(dQ), ar(gK, 2u));
140
- fa.y = float(y >> 8u) * (1.0 / 16777216.0);
141
- dv = true;
136
+ vec2 le(uint dim) {
137
+ dm(dim);
138
+ if (!cX) {
139
+ uint y = ud(sm(dD), ak(gt, 2u));
140
+ eJ.y = float(y >> 8u) * (1.0 / 16777216.0);
141
+ cX = true;
142
142
  }
143
- return EPS + (1.0 - 2.0*EPS) * fa;
143
+ return EPS + (1.0 - 2.0*EPS) * eJ;
144
144
  }
145
- float dp(uint dim) {
145
+ float sample1D(uint dim) {
146
146
  if (samplingPattern == 2) { return EPS + (1.0 - 2.0*EPS)*rand(); }
147
- dN(dim);
148
- return EPS + (1.0 - 2.0*EPS) * fa.x;
147
+ dm(dim);
148
+ return EPS + (1.0 - 2.0*EPS) * eJ.x;
149
149
  }
150
- vec2 dZ(uint dim) {
150
+ vec2 sample2D(uint dim) {
151
151
  if (samplingPattern == 2) {
152
- float x = dp(dim); float y = dp(dim);
152
+ float x = sample1D(dim); float y = sample1D(dim);
153
153
  return vec2(x,y);
154
154
  }
155
- return lC(dim);
155
+ return le(dim);
156
156
  }
157
157
 
158
- float eC(uint slot) {
159
- uint dim = ar(ar(bT, slot), cP) | 0x80000000u;
160
- cP += 1u;
158
+ float ek(uint slot) {
159
+ uint dim = ak(ak(samplingBounce, slot), ca) | 0x80000000u;
160
+ ca += 1u;
161
161
  if (samplingPattern == 2) { return EPS + (1.0 - 2.0*EPS)*rand(); }
162
162
 
163
- uint kI = aZ.x + aZ.y * uint(round(1.0 / pixelSize.x));
164
- uint seed = ar(ar(kI, dim), uint(sequenceSeed));
165
- uint i = ua(aQ, ar(seed, 0u));
166
- uint x = reverseBits(iV(i, ar(seed, 1u)));
163
+ uint kl = aI.x + aI.y * uint(round(1.0 / pixelSize.x));
164
+ uint seed = ak(ak(kl, dim), uint(sequenceSeed));
165
+ uint i = ud(aC, ak(seed, 0u));
166
+ uint x = reverseBits(iD(i, ak(seed, 1u)));
167
167
  return EPS + (1.0 - 2.0*EPS) * (float(x >> 8u) * (1.0 / 16777216.0));
168
168
  }
169
169
  `;
@@ -9,16 +9,16 @@ vec4 textureLinear(sampler2D map, vec2 uv) {
9
9
  return texture(map, uv);
10
10
  #else
11
11
  vec2 size = vec2(textureSize(map, 0));
12
- vec2 qX = 1.0 / size;
12
+ vec2 qQ = 1.0 / size;
13
13
 
14
14
  uv = uv * size - 0.5;
15
15
  vec2 f = fract(uv);
16
16
  uv = floor(uv) + 0.5;
17
17
 
18
- vec4 s1 = texture(map, (uv + vec2(0, 0)) * qX);
19
- vec4 s2 = texture(map, (uv + vec2(1, 0)) * qX);
20
- vec4 s3 = texture(map, (uv + vec2(0, 1)) * qX);
21
- vec4 s4 = texture(map, (uv + vec2(1, 1)) * qX);
18
+ vec4 s1 = texture(map, (uv + vec2(0, 0)) * qQ);
19
+ vec4 s2 = texture(map, (uv + vec2(1, 0)) * qQ);
20
+ vec4 s3 = texture(map, (uv + vec2(0, 1)) * qQ);
21
+ vec4 s4 = texture(map, (uv + vec2(1, 1)) * qQ);
22
22
 
23
23
  return mix(mix(s1, s2, f.x), mix(s3, s4, f.x), f.y);
24
24
  #endif
@@ -8,12 +8,12 @@ float phi = acos(n.y) / PI;
8
8
  return vec2(theta, 1.0 - phi);
9
9
  }
10
10
 
11
- vec2 jh(vec3 pos, vec3 normal, vec2 uvScale) {
12
- vec3 dI = abs(normal);
11
+ vec2 iO(vec3 pos, vec3 normal, vec2 uvScale) {
12
+ vec3 dg = abs(normal);
13
13
  vec2 uv = vec2(0.0);
14
- if (dI.x > dI.y && dI.x > dI.z) {
14
+ if (dg.x > dg.y && dg.x > dg.z) {
15
15
  uv = pos.yz;
16
- } else if (dI.y > dI.x && dI.y > dI.z) {
16
+ } else if (dg.y > dg.x && dg.y > dg.z) {
17
17
  uv = pos.xz;
18
18
  } else {
19
19
  uv = pos.xy;
@@ -53,18 +53,18 @@ return fract(uv * uvScale);
53
53
 
54
54
 
55
55
 
56
- vec2 hT(vec3 pos, vec3 normal) {
56
+ vec2 hA(vec3 pos, vec3 normal) {
57
57
  float theta = atan(pos.z, pos.x) / (2.0 * PI) + 0.5;
58
58
  return vec2(theta, pos.y);
59
59
  }
60
60
 
61
- vec2 gU(int fE, vec3 pos, vec3 normal, vec2 uvScale) {
62
- if (fE == ${uvProjectionConstants.triplanar + ''}) {
63
- return jh(pos, normal, uvScale);
64
- } else if (fE == ${uvProjectionConstants.spherical + ''}) {
61
+ vec2 gE(int fg, vec3 pos, vec3 normal, vec2 uvScale) {
62
+ if (fg == ${uvProjectionConstants.triplanar + ''}) {
63
+ return iO(pos, normal, uvScale);
64
+ } else if (fg == ${uvProjectionConstants.spherical + ''}) {
65
65
  return sphericalProjection(pos) * uvScale;
66
- } else if (fE == ${uvProjectionConstants.cylindrical + ''}) {
67
- return hT(pos, normal) * uvScale;
66
+ } else if (fg == ${uvProjectionConstants.cylindrical + ''}) {
67
+ return hA(pos, normal) * uvScale;
68
68
  }
69
69
  return vec2(0.0);
70
70
  }
@@ -33,7 +33,7 @@ if (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0)))) return;
33
33
  vec4 origin = viewProjectionInv * vec4(uv * 2.0 - 1.0, -1.0, 1.0);
34
34
  vec4 target = viewProjectionInv * vec4(uv * 2.0 - 1.0, 1.0, 1.0);
35
35
  Ray ray;
36
- gC(ray, origin.xyz / origin.w, normalize(target.xyz * origin.w - origin.xyz * target.w));
36
+ initRay(ray, origin.xyz / origin.w, normalize(target.xyz * origin.w - origin.xyz * target.w));
37
37
  vec3 eye = viewInv[3].xyz;
38
38
  vec3 forward = -normalize(viewInv[2].xyz);
39
39
  SurfaceInteraction si;
@@ -42,7 +42,7 @@ for (int layer = 0; layer < 32; layer++) {
42
42
  intersectScene(ray, si, false);
43
43
  if (!si.hit) return;
44
44
  OpenPbrResolvedMaterial material;
45
- dg(material, si.materialIndex, si.uv, si.uv1, si.instanceIndex, si.vertexColor);
45
+ getMaterial(material, si.materialIndex, si.uv, si.uv1, si.instanceIndex, si.vertexColor);
46
46
  if (material.materialType != SHADOW_CATCHER && material.alpha > 0.0) {
47
47
  out_depth.r = max(dot(si.position - eye, forward), 0.0);
48
48
  return;
@@ -17,29 +17,29 @@ const normalizeRayTraceOutput = new FragmentShader({
17
17
  main: glsl `
18
18
  void main() {
19
19
  vec2 uv = lightScale * v_Texcoord;
20
- vec4 tb = sample_albedoTex(uv);
21
- float hit = tb.a;
22
- vec4 tf = sample_normalTex(uv);
20
+ vec4 sY = sample_albedoTex(uv);
21
+ float hit = sY.a;
22
+ vec4 td = sample_normalTex(uv);
23
23
 
24
24
 
25
25
 
26
- float tK = max(tf.a, 1.0);
27
- vec3 albedo = tb.rgb / tK;
28
- vec3 normal = tf.rgb / tK;
26
+ float tL = max(td.a, 1.0);
27
+ vec3 albedo = sY.rgb / tL;
28
+ vec3 normal = td.rgb / tL;
29
29
  vec4 shadowCatcher = sample_shadowCatcherTex(uv);
30
30
 
31
31
 
32
32
 
33
- float tj = sample_catcherMomentsTex(uv).w;
34
- float opacity = tj > 0.0 ? shadowCatcher.a / tj : 0.0;
33
+ float th = sample_catcherMomentsTex(uv).w;
34
+ float opacity = th > 0.0 ? shadowCatcher.a / th : 0.0;
35
35
  shadowCatcher /= sampleCount;
36
36
  shadowCatcher.a = 1.0 - shadowCatcher.r * opacity;
37
- vec4 tQ = sample_colorTex(uv);
37
+ vec4 tT = sample_colorTex(uv);
38
38
 
39
39
 
40
40
 
41
41
 
42
- vec4 light = vec4(tQ.rgb / (hit > 0.0 ? hit : sampleCount), tQ.a / sampleCount);
42
+ vec4 light = vec4(tT.rgb / (hit > 0.0 ? hit : sampleCount), tT.a / sampleCount);
43
43
 
44
44
 
45
45
 
@@ -1,2 +1,2 @@
1
1
  import { FragmentShader } from '../shader.js';
2
- export default function createRayTraceFragmentShader(): FragmentShader<Record<string, import("../shader.js").ShaderDefineValue>, Record<string, import("../shader.js").ShaderUniform<unknown>>>;
2
+ export default function createRayTraceFragmentShader(...options: unknown[]): FragmentShader<Record<string, import("../shader.js").ShaderDefineValue>, Record<string, import("../shader.js").ShaderUniform<unknown>>>;