@meimu/mutracer 0.1.3 → 0.1.4

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 (118) hide show
  1. package/dist/assets/bvh.worker.js +1 -1
  2. package/dist/mutracer.umd.js +4114 -4015
  3. package/docs/api.md +11 -9
  4. package/docs/threejs.md +30 -4
  5. package/lib/Engine.js +18 -1
  6. package/lib/Engine.js.map +1 -1
  7. package/lib/main.d.ts +1 -1
  8. package/lib/main.js.map +1 -1
  9. package/lib/oidn.d.ts +1 -1
  10. package/lib/oidnBundledWeights.cdn.d.ts +2 -2
  11. package/lib/renderer/MaterialTable.d.ts +1 -0
  12. package/lib/renderer/MaterialTable.js +10 -4
  13. package/lib/renderer/MaterialTable.js.map +1 -1
  14. package/lib/renderer/WGPUBloomPass.js +18 -18
  15. package/lib/renderer/WGPUFullQuadPass.js +6 -6
  16. package/lib/renderer/WGPUJNLMDenoiser.js +69 -69
  17. package/lib/renderer/WGPURayTraceOutput.js +14 -14
  18. package/lib/renderer/WGPURayTracePass.d.ts +2 -0
  19. package/lib/renderer/WGPURayTracePass.js +12 -6
  20. package/lib/renderer/WGPURayTracePass.js.map +1 -1
  21. package/lib/renderer/WGPURenderingPipeline.js +15 -15
  22. package/lib/renderer/WebGLJNLMDenoiser.js +69 -69
  23. package/lib/renderer/WebGLRayTraceOutputPass.js +4 -4
  24. package/lib/renderer/WebGLRayTracePass.d.ts +1 -0
  25. package/lib/renderer/WebGLRayTracePass.js +7 -1
  26. package/lib/renderer/WebGLRayTracePass.js.map +1 -1
  27. package/lib/renderer/envMapCreation.d.ts +5 -1
  28. package/lib/renderer/envMapCreation.js +42 -5
  29. package/lib/renderer/envMapCreation.js.map +1 -1
  30. package/lib/renderer/geometryUpdates.js +1 -1
  31. package/lib/renderer/geometryUpdates.js.map +1 -1
  32. package/lib/renderer/glsl/chunks/cameraRay.glsl.js +12 -12
  33. package/lib/renderer/glsl/chunks/envMap.glsl.js +66 -54
  34. package/lib/renderer/glsl/chunks/envMap.glsl.js.map +1 -1
  35. package/lib/renderer/glsl/chunks/intersect.glsl.js +316 -310
  36. package/lib/renderer/glsl/chunks/intersect.glsl.js.map +1 -1
  37. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +151 -119
  38. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js.map +1 -1
  39. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +414 -414
  40. package/lib/renderer/glsl/chunks/rand.glsl.js +3 -3
  41. package/lib/renderer/glsl/chunks/random.glsl.js +3 -3
  42. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +40 -39
  43. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js.map +1 -1
  44. package/lib/renderer/glsl/chunks/sampleLight.glsl.js +69 -69
  45. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +78 -78
  46. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +12 -12
  47. package/lib/renderer/glsl/chunks/sampling.glsl.js +75 -75
  48. package/lib/renderer/glsl/chunks/sobol.glsl.js +61 -61
  49. package/lib/renderer/glsl/chunks/textureLinear.glsl.js +5 -5
  50. package/lib/renderer/glsl/chunks/uvProjection.glsl.js +11 -11
  51. package/lib/renderer/glsl/depthQuery.frag.js +5 -5
  52. package/lib/renderer/glsl/depthQuery.frag.js.map +1 -1
  53. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +8 -8
  54. package/lib/renderer/glsl/rayTrace.frag.js +133 -133
  55. package/lib/renderer/glsl/rayTrace.frag.js.map +1 -1
  56. package/lib/renderer/glsl/shadowCatcher.frag.js +9 -9
  57. package/lib/renderer/glsl/shadowCatcher.frag.js.map +1 -1
  58. package/lib/renderer/glsl/webglPipeline.frag.js +52 -52
  59. package/lib/renderer/lightsUtil.js +6 -4
  60. package/lib/renderer/lightsUtil.js.map +1 -1
  61. package/lib/renderer/materialChanges.js +1 -1
  62. package/lib/renderer/materialChanges.js.map +1 -1
  63. package/lib/renderer/materialComparison.generated.js +36 -18
  64. package/lib/renderer/materialComparison.generated.js.map +1 -1
  65. package/lib/renderer/prepareMeshBVH.js +2 -2
  66. package/lib/renderer/prepareMeshBVH.js.map +1 -1
  67. package/lib/renderer/sceneChangeDetector.js +4 -1
  68. package/lib/renderer/sceneChangeDetector.js.map +1 -1
  69. package/lib/renderer/sceneLightChanges.js +3 -2
  70. package/lib/renderer/sceneLightChanges.js.map +1 -1
  71. package/lib/renderer/scratchSampling.js +18 -18
  72. package/lib/renderer/wgsl/chunks/common.wgsl.js +4 -4
  73. package/lib/renderer/wgsl/chunks/envMap.wgsl.d.ts +1 -1
  74. package/lib/renderer/wgsl/chunks/envMap.wgsl.js +39 -31
  75. package/lib/renderer/wgsl/chunks/envMap.wgsl.js.map +1 -1
  76. package/lib/renderer/wgsl/chunks/intersect.wgsl.js +475 -469
  77. package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -1
  78. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +8 -8
  79. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +93 -59
  80. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js.map +1 -1
  81. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +469 -469
  82. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.d.ts +1 -1
  83. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +117 -120
  84. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js.map +1 -1
  85. package/lib/renderer/wgsl/chunks/rand.wgsl.js +3 -3
  86. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +25 -22
  87. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js.map +1 -1
  88. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +127 -127
  89. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +136 -136
  90. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +6 -6
  91. package/lib/renderer/wgsl/chunks/sampling.wgsl.js +73 -73
  92. package/lib/renderer/wgsl/chunks/sobol.wgsl.js +62 -62
  93. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +11 -11
  94. package/lib/renderer/wgsl/compose.frag.wgsl.js +105 -105
  95. package/lib/renderer/wgsl/customDenoise.wgsl.js +10 -10
  96. package/lib/renderer/wgsl/depthQuery.wgsl.d.ts +1 -1
  97. package/lib/renderer/wgsl/depthQuery.wgsl.js +5 -5
  98. package/lib/renderer/wgsl/depthQuery.wgsl.js.map +1 -1
  99. package/lib/renderer/wgsl/offlineAdaptive.compute.js +28 -28
  100. package/lib/renderer/wgsl/rayTrace.compute.js +251 -248
  101. package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -1
  102. package/lib/scene/EnvironmentLight.d.ts +9 -3
  103. package/lib/scene/EnvironmentLight.js +9 -2
  104. package/lib/scene/EnvironmentLight.js.map +1 -1
  105. package/lib/scene/Scene.d.ts +4 -0
  106. package/lib/scene/Scene.js.map +1 -1
  107. package/lib/scene/SpotLight.d.ts +2 -2
  108. package/lib/scene/SpotLight.js +1 -1
  109. package/lib/scene/SpotLight.js.map +1 -1
  110. package/lib/scene/Texture.d.ts +17 -6
  111. package/lib/scene/Texture.js +13 -4
  112. package/lib/scene/Texture.js.map +1 -1
  113. package/lib/util/fromTHREE.js +151 -29
  114. package/lib/util/fromTHREE.js.map +1 -1
  115. package/lib/version.d.ts +1 -1
  116. package/lib/version.js +1 -1
  117. package/lib/version.js.map +1 -1
  118. package/package.json +1 -1
@@ -5,13 +5,13 @@ import { glsl } from '../../shader.js';
5
5
  export default glsl `
6
6
  uvec4 s0;
7
7
 
8
- void ka(vec2 p, int frame) {
8
+ void kh(vec2 p, int frame) {
9
9
 
10
10
  s0 = uvec4(p, uint(frame), uint(p.x) + uint(p.y));
11
11
  }
12
12
 
13
13
 
14
- void vo(inout uvec4 v) {
14
+ void vx(inout uvec4 v) {
15
15
  v = v * 1664525u + 1013904223u;
16
16
  v.x += v.y*v.w; v.y += v.z*v.x; v.z += v.x*v.y; v.w += v.y*v.z;
17
17
  v = v ^ (v>>16u);
@@ -19,7 +19,7 @@ v.x += v.y*v.w; v.y += v.z*v.x; v.z += v.x*v.y; v.w += v.y*v.z;
19
19
  }
20
20
 
21
21
  float rand() {
22
- vo(s0); return float(s0.x)/float(0xffffffffu);
22
+ vx(s0); return float(s0.x)/float(0xffffffffu);
23
23
  }
24
24
 
25
25
  `;
@@ -10,15 +10,15 @@ export default createShaderMixin({
10
10
 
11
11
  ${sobol}
12
12
 
13
- void sk() {
13
+ void su() {
14
14
  bc = uvec2(v_Texcoord / pixelSize);
15
15
  bd = uint(sampleCount);
16
16
  cF = 0u; em = 0u;
17
17
  }
18
18
 
19
- vec2 rS() {
19
+ vec2 sa() {
20
20
  if (samplingPattern == 0 || samplingPattern == 1) {
21
- return (fk(CAMERA_PIXEL) - 0.5) * pixelSize;
21
+ return (fo(CAMERA_PIXEL) - 0.5) * pixelSize;
22
22
  }
23
23
  return jitter;
24
24
  }
@@ -23,7 +23,7 @@ export default createShaderMixin({
23
23
  main: glsl `
24
24
 
25
25
  const vec3 luminance = vec3(0.2126, 0.7152, 0.0722);
26
- const int vw = 8;
26
+ const int vE = 8;
27
27
 
28
28
  #define RAY_MAX_DISTANCE 9999.0
29
29
 
@@ -48,6 +48,7 @@ vec3 shadowOffset;
48
48
 
49
49
  vec2 uv;
50
50
  vec2 uv1;
51
+ vec3 vertexColor;
51
52
 
52
53
  #ifdef USE_TANGENT
53
54
  vec3 tangent;
@@ -156,26 +157,26 @@ float selectionCdf;
156
157
  vec3 iesReference;
157
158
  };
158
159
 
159
- void iw(inout Ray ray, vec3 origin, vec3 direction) {
160
+ void iC(inout Ray ray, vec3 origin, vec3 direction) {
160
161
  ray.o = origin;
161
162
  ray.d = direction;
162
163
  ray.tMax = RAY_MAX_DISTANCE;
163
164
  }
164
165
 
165
166
 
166
- ivec2 gM(int i, int jt) {
167
+ ivec2 gQ(int i, int jz) {
167
168
  ivec2 u;
168
- u.y = i >> jt;
169
- u.x = i - (u.y << jt);
169
+ u.y = i >> jz;
170
+ u.x = i - (u.y << jz);
170
171
  return u;
171
172
  }
172
173
 
173
- vec4 ky(sampler2D s, int i, int jt) {
174
- return texelFetch(s, gM(i, jt), 0);
174
+ vec4 kG(sampler2D s, int i, int jz) {
175
+ return texelFetch(s, gQ(i, jz), 0);
175
176
  }
176
177
 
177
- ivec4 ky(highp isampler2D s, int i, int jt) {
178
- return texelFetch(s, gM(i, jt), 0);
178
+ ivec4 kG(highp isampler2D s, int i, int jz) {
179
+ return texelFetch(s, gQ(i, jz), 0);
179
180
  }
180
181
 
181
182
  struct Path {
@@ -200,24 +201,24 @@ bool isDelta;
200
201
  };
201
202
 
202
203
 
203
- Light qp(int i) {
204
+ Light qx(int i) {
204
205
  int firstTexel = i * 6;
205
- vec4 pG = texelFetch(
206
+ vec4 pO = texelFetch(
206
207
  lightsTex,
207
208
  ivec2(firstTexel, 0),
208
209
  0
209
210
  );
210
- vec4 pf = texelFetch(
211
+ vec4 po = texelFetch(
211
212
  lightsTex,
212
213
  ivec2(firstTexel + 1, 0),
213
214
  0
214
215
  );
215
- vec4 nF = texelFetch(
216
+ vec4 nQ = texelFetch(
216
217
  lightsTex,
217
218
  ivec2(firstTexel + 2, 0),
218
219
  0
219
220
  );
220
- vec4 lD = texelFetch(
221
+ vec4 lN = texelFetch(
221
222
  lightsTex,
222
223
  ivec2(firstTexel + 3, 0),
223
224
  0
@@ -228,36 +229,36 @@ ivec2(firstTexel + 4, 0),
228
229
  0
229
230
  );
230
231
  return Light(
231
- pG.xyz,
232
- pf.xyz,
233
- nF.xyz,
234
- lD.xyz,
232
+ pO.xyz,
233
+ po.xyz,
234
+ nQ.xyz,
235
+ lN.xyz,
235
236
  shape.x,
236
237
  shape.y,
237
238
  shape.z,
238
- int(lD.w),
239
- nF.w,
240
- pG.w,
241
- pf.w,
239
+ int(lN.w),
240
+ nQ.w,
241
+ pO.w,
242
+ po.w,
242
243
  texelFetch(lightsTex, ivec2(firstTexel + 5, 0), 0).xyz
243
244
  );
244
245
  }
245
246
 
246
- float cL(int dV, int lh) {
247
- int ih = dV + lh / 4;
247
+ float cL(int dV, int ls) {
248
+ int im = dV + ls / 4;
248
249
  vec4 packed = texelFetch(
249
250
  iesProfileData,
250
- ivec2(ih % iesProfileColumns, ih / iesProfileColumns),
251
+ ivec2(im % iesProfileColumns, im / iesProfileColumns),
251
252
  0
252
253
  );
253
- return packed[lh % 4];
254
+ return packed[ls % 4];
254
255
  }
255
256
 
256
- float kI(int dV, vec2 uv) {
257
+ float kR(int dV, vec2 uv) {
257
258
  if (dV < 0) return 1.0;
258
- vec2 fM = fract(uv) * 128.0 - 0.5;
259
- ivec2 p0 = ivec2(floor(fM));
260
- vec2 f = fract(fM);
259
+ vec2 fP = fract(uv) * 128.0 - 0.5;
260
+ ivec2 p0 = ivec2(floor(fP));
261
+ vec2 f = fract(fP);
261
262
  int xa = p0.x < 0 ? 127 : p0.x;
262
263
  int xb = p0.x >= 127 ? 0 : p0.x + 1;
263
264
  int ya = p0.y < 0 ? 127 : p0.y;
@@ -269,18 +270,18 @@ float d = cL(dV, yb * 128 + xb);
269
270
  return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
270
271
  }
271
272
 
272
- float bL(Light light, vec3 dJ) {
273
+ float bL(Light light, vec3 dK) {
273
274
  vec3 axis = normalize(light.u);
274
- float cc = dot(axis, dJ);
275
- float tI = light.v.y > 1e-6
276
- ? smoothstep(light.v.x, light.v.x + light.v.y, cc)
275
+ float cc = dot(axis, dK);
276
+ float tP = light.v.y > light.v.x + 1e-6
277
+ ? smoothstep(light.v.x, light.v.y, cc)
277
278
  : step(light.v.x, cc);
278
- if (tI <= 0.0 || light.textureIndex < 0) return tI;
279
- vec3 uc = light.iesReference;
280
- vec3 vu = cross(axis, uc);
279
+ if (tP <= 0.0 || light.textureIndex < 0) return tP;
280
+ vec3 uj = light.iesReference;
281
+ vec3 vD = cross(axis, uj);
281
282
  float vertical = acos(clamp(cc, -1.0, 1.0));
282
- float horizontal = atan(dot(dJ, vu), dot(dJ, uc));
283
- return tI * kI(light.textureIndex, vec2(vertical / PI, horizontal / TWOPI + 0.5));
283
+ float horizontal = atan(dot(dK, vD), dot(dK, uj));
284
+ return tP * kR(light.textureIndex, vec2(vertical / PI, horizontal / TWOPI + 0.5));
284
285
  }
285
286
  `
286
287
  });
@@ -1 +1 @@
1
- {"version":3,"file":"rayTraceCore.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/rayTraceCore.glsl.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,sDAAsD;AACtD,kFAAkF;AAElF,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,eAAe,iBAAiB,CAAC;IAC/B,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;QACtC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;QAC3C,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3C,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAClC,oBAAoB,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;KACjD;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,aAAa;QACpB,cAAc,EAAE,qBAAqB;QACrC,UAAU,EAAE,mBAAmB;KAChC;IACD,IAAI,EAAE,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsQX;CACA,CAAC,CAAC","sourcesContent":["// Portions adapted from ray-tracing-renderer@0.10.15\n// (https://github.com/hoverinc/ray-tracing-renderer).\n// Copyright (c) 2019 HOVER, MIT license; see LICENSES/RayTracingRenderer-MIT.txt.\n\nimport { createShaderMixin, glsl, Shader } from '../../shader.js';\nimport { ShadowCatcherMaterial, UnlitMaterial } from '../../../constants.js';\nimport { CONSTANT_SPOT_LIGHT } from '../../lightsUtil.js';\n\nexport default createShaderMixin({\n uniforms: {\n lightsTex: Shader.uniform('sampler2D'),\n iesProfileData: Shader.uniform('sampler2D'),\n iesProfileColumns: Shader.uniform('int', 1),\n pixelSize: Shader.uniform('vec2'),\n jitter: Shader.uniform('vec2'),\n sampleCount: Shader.uniform('int'),\n envLightSelectionPmf: Shader.uniform('float', 0)\n },\n defines: {\n STANDARD: 0,\n UNLIT: UnlitMaterial,\n SHADOW_CATCHER: ShadowCatcherMaterial,\n SPOT_LIGHT: CONSTANT_SPOT_LIGHT\n },\n main: glsl`\n// https://www.w3.org/WAI/GL/wiki/Relative_luminance\nconst vec3 luminance = vec3(0.2126, 0.7152, 0.0722);\nconst int bounceSamples = 8;\n\n#define RAY_MAX_DISTANCE 9999.0\n\n#define NO_UNROLL(X) (X + min(0, sampleCount))\n#define NO_UNROLLU(X) (X + uint(min(0, sampleCount)))\n\nstruct Ray {\n vec3 o;\n vec3 d;\n float tMax;\n};\n\nstruct SurfaceInteraction {\n bool hit;\n vec3 position;\n vec3 normal; // material shading normal\n#ifdef NUM_COAT_NORMAL_MAPS\n vec3 coatNormal;\n#endif\n vec3 vertexNormal; // interpolated mesh normal before normal mapping\n vec3 shadowOffset; // smooth-surface offset used by direct-light shadow rays\n \n vec2 uv;\n vec2 uv1;\n\n#ifdef USE_TANGENT\n vec3 tangent;\n#endif\n vec3 directionTangent;\n vec3 directionBitangent;\n vec3 geometryTangent;\n vec3 geometryBitangent;\n vec3 faceNormal; // normal of the triangle\n\n bool isTransparency;\n // For perfect specular or transmission surface\n // We use the albedo and normal of first diffuse or glossy surface hit instead for denoising\n // See albedo section in https://www.openimagedenoise.org/documentation.html\n bool albedoSampled;\n\n int triangleIndex;\n int instanceIndex;\n int materialIndex;\n\n int mediumType;\n vec3 mediumExtinction;\n vec3 mediumScattering;\n float mediumAnisotropy;\n};\n\n// Texture-resolved OpenPBR inputs used by the surface integrator. The storage\n// buffer keeps its compact legacy layout; getMaterial() is the compatibility\n// boundary that maps it to these canonical names.\nstruct OpenPbrResolvedMaterial {\n int materialType;\n\n float specularRoughness;\n float baseMetalness;\n vec3 baseColor;\n float specularIor;\n vec3 emission;\n float transmissionWeight;\n bool thinWalled;\n float specularAnisotropy;\n float alpha;\n\n float transmissionDispersionScale;\n float dispersionAbbeNumber;\n float thinFilmThickness;\n float thinFilmIor;\n float thinFilmWeight;\n\n // Medium\n int mediumType;\n vec3 mediumExtinction;\n vec3 mediumScattering;\n float mediumAnisotropy;\n\n float baseWeight;\n float diffuseRoughness;\n float specularWeight;\n vec3 specularColor;\n float subsurfaceWeight;\n vec3 subsurfaceColor;\n vec3 transmissionColor;\n float fuzzWeight;\n vec3 fuzzColor;\n float fuzzRoughness;\n float coatWeight;\n vec3 coatColor;\n float coatRoughness;\n float coatAnisotropy;\n vec2 anisotropyDirection;\n bool anisotropyDirectionEnabled;\n float coatAnisotropyRotation;\n vec3 directionTangent;\n vec3 directionBitangent;\n vec3 geometryTangent;\n vec3 geometryBitangent;\n#ifdef NUM_COAT_NORMAL_MAPS\n vec3 coatNormal;\n bool coatNormalEnabled;\n vec3 geometricNormal;\n#endif\n float coatIor;\n float coatDarkening;\n\n float bevel;\n\n // Calculated\n float relativeIor;\n bool inside;\n float alphaX;\n float alphaY;\n};\n\n\nstruct Light {\n vec3 position;\n vec3 emission;\n vec3 u;\n vec3 v;\n float radius;\n float area;\n float type;\n int textureIndex;\n float spread;\n float selectionPmf;\n float selectionCdf;\n vec3 iesReference;\n};\n\nvoid initRay(inout Ray ray, vec3 origin, vec3 direction) {\n ray.o = origin;\n ray.d = direction;\n ray.tMax = RAY_MAX_DISTANCE;\n}\n\n// given the index from a 1D array, retrieve corresponding position from packed 2D texture\nivec2 unpackTexel(int i, int columnsLog2) {\n ivec2 u;\n u.y = i >> columnsLog2; // equivalent to (i / 2^columnsLog2)\n u.x = i - (u.y << columnsLog2); // equivalent to (i % 2^columnsLog2)\n return u;\n}\n\nvec4 fetchData(sampler2D s, int i, int columnsLog2) {\n return texelFetch(s, unpackTexel(i, columnsLog2), 0);\n}\n\nivec4 fetchData(highp isampler2D s, int i, int columnsLog2) {\n return texelFetch(s, unpackTexel(i, columnsLog2), 0);\n}\n\nstruct Path {\n Ray ray;\n vec3 li;\n float alpha;\n vec3 beta;\n bool fromEye;\n bool abort;\n float scatteringPdf;\n bool scatteringIsDelta;\n bool isNextRefraction;\n};\n\nstruct LightSampleRec {\n vec3 normal;\n vec3 emission;\n vec3 direction;\n float dist;\n float pdf;\n bool isDelta;\n};\n\n\nLight fetchLight(int i) {\n int firstTexel = i * 6;\n vec4 positionAndPmf = texelFetch(\n lightsTex,\n ivec2(firstTexel, 0),\n 0\n );\n vec4 emissionAndCdf = texelFetch(\n lightsTex,\n ivec2(firstTexel + 1, 0),\n 0\n );\n vec4 tangentAndSpread = texelFetch(\n lightsTex,\n ivec2(firstTexel + 2, 0),\n 0\n );\n vec4 bitangentAndTexture = texelFetch(\n lightsTex,\n ivec2(firstTexel + 3, 0),\n 0\n );\n vec4 shape = texelFetch(\n lightsTex,\n ivec2(firstTexel + 4, 0),\n 0\n );\n return Light(\n positionAndPmf.xyz,\n emissionAndCdf.xyz,\n tangentAndSpread.xyz,\n bitangentAndTexture.xyz,\n shape.x,\n shape.y,\n shape.z,\n int(bitangentAndTexture.w),\n tangentAndSpread.w,\n positionAndPmf.w,\n emissionAndCdf.w,\n texelFetch(lightsTex, ivec2(firstTexel + 5, 0), 0).xyz\n );\n}\n\nfloat iesProfileScalar(int baseTexel, int scalarIndex) {\n int texelIndex = baseTexel + scalarIndex / 4;\n vec4 packed = texelFetch(\n iesProfileData,\n ivec2(texelIndex % iesProfileColumns, texelIndex / iesProfileColumns),\n 0\n );\n return packed[scalarIndex % 4];\n}\n\nfloat sampleIESProfile(int baseTexel, vec2 uv) {\n if (baseTexel < 0) return 1.0;\n vec2 pixel = fract(uv) * 128.0 - 0.5;\n ivec2 p0 = ivec2(floor(pixel));\n vec2 f = fract(pixel);\n int xa = p0.x < 0 ? 127 : p0.x;\n int xb = p0.x >= 127 ? 0 : p0.x + 1;\n int ya = p0.y < 0 ? 127 : p0.y;\n int yb = p0.y >= 127 ? 0 : p0.y + 1;\n float a = iesProfileScalar(baseTexel, ya * 128 + xa);\n float b = iesProfileScalar(baseTexel, ya * 128 + xb);\n float c = iesProfileScalar(baseTexel, yb * 128 + xa);\n float d = iesProfileScalar(baseTexel, yb * 128 + xb);\n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n}\n\nfloat evaluateSpotEmissionMultiplier(Light light, vec3 lightToSurface) {\n vec3 axis = normalize(light.u);\n float cosTheta = dot(axis, lightToSurface);\n float cone = light.v.y > 1e-6\n ? smoothstep(light.v.x, light.v.x + light.v.y, cosTheta)\n : step(light.v.x, cosTheta);\n if (cone <= 0.0 || light.textureIndex < 0) return cone;\n vec3 xAxis = light.iesReference;\n vec3 yAxis = cross(axis, xAxis);\n float vertical = acos(clamp(cosTheta, -1.0, 1.0));\n float horizontal = atan(dot(lightToSurface, yAxis), dot(lightToSurface, xAxis));\n return cone * sampleIESProfile(light.textureIndex, vec2(vertical / PI, horizontal / TWOPI + 0.5));\n}\n`\n});\n"]}
1
+ {"version":3,"file":"rayTraceCore.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/rayTraceCore.glsl.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,sDAAsD;AACtD,kFAAkF;AAElF,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,eAAe,iBAAiB,CAAC;IAC/B,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;QACtC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;QAC3C,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3C,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAClC,oBAAoB,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;KACjD;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,aAAa;QACpB,cAAc,EAAE,qBAAqB;QACrC,UAAU,EAAE,mBAAmB;KAChC;IACD,IAAI,EAAE,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuQX;CACA,CAAC,CAAC","sourcesContent":["// Portions adapted from ray-tracing-renderer@0.10.15\n// (https://github.com/hoverinc/ray-tracing-renderer).\n// Copyright (c) 2019 HOVER, MIT license; see LICENSES/RayTracingRenderer-MIT.txt.\n\nimport { createShaderMixin, glsl, Shader } from '../../shader.js';\nimport { ShadowCatcherMaterial, UnlitMaterial } from '../../../constants.js';\nimport { CONSTANT_SPOT_LIGHT } from '../../lightsUtil.js';\n\nexport default createShaderMixin({\n uniforms: {\n lightsTex: Shader.uniform('sampler2D'),\n iesProfileData: Shader.uniform('sampler2D'),\n iesProfileColumns: Shader.uniform('int', 1),\n pixelSize: Shader.uniform('vec2'),\n jitter: Shader.uniform('vec2'),\n sampleCount: Shader.uniform('int'),\n envLightSelectionPmf: Shader.uniform('float', 0)\n },\n defines: {\n STANDARD: 0,\n UNLIT: UnlitMaterial,\n SHADOW_CATCHER: ShadowCatcherMaterial,\n SPOT_LIGHT: CONSTANT_SPOT_LIGHT\n },\n main: glsl`\n// https://www.w3.org/WAI/GL/wiki/Relative_luminance\nconst vec3 luminance = vec3(0.2126, 0.7152, 0.0722);\nconst int bounceSamples = 8;\n\n#define RAY_MAX_DISTANCE 9999.0\n\n#define NO_UNROLL(X) (X + min(0, sampleCount))\n#define NO_UNROLLU(X) (X + uint(min(0, sampleCount)))\n\nstruct Ray {\n vec3 o;\n vec3 d;\n float tMax;\n};\n\nstruct SurfaceInteraction {\n bool hit;\n vec3 position;\n vec3 normal; // material shading normal\n#ifdef NUM_COAT_NORMAL_MAPS\n vec3 coatNormal;\n#endif\n vec3 vertexNormal; // interpolated mesh normal before normal mapping\n vec3 shadowOffset; // smooth-surface offset used by direct-light shadow rays\n \n vec2 uv;\n vec2 uv1;\n vec3 vertexColor;\n\n#ifdef USE_TANGENT\n vec3 tangent;\n#endif\n vec3 directionTangent;\n vec3 directionBitangent;\n vec3 geometryTangent;\n vec3 geometryBitangent;\n vec3 faceNormal; // normal of the triangle\n\n bool isTransparency;\n // For perfect specular or transmission surface\n // We use the albedo and normal of first diffuse or glossy surface hit instead for denoising\n // See albedo section in https://www.openimagedenoise.org/documentation.html\n bool albedoSampled;\n\n int triangleIndex;\n int instanceIndex;\n int materialIndex;\n\n int mediumType;\n vec3 mediumExtinction;\n vec3 mediumScattering;\n float mediumAnisotropy;\n};\n\n// Texture-resolved OpenPBR inputs used by the surface integrator. The storage\n// buffer keeps its compact legacy layout; getMaterial() is the compatibility\n// boundary that maps it to these canonical names.\nstruct OpenPbrResolvedMaterial {\n int materialType;\n\n float specularRoughness;\n float baseMetalness;\n vec3 baseColor;\n float specularIor;\n vec3 emission;\n float transmissionWeight;\n bool thinWalled;\n float specularAnisotropy;\n float alpha;\n\n float transmissionDispersionScale;\n float dispersionAbbeNumber;\n float thinFilmThickness;\n float thinFilmIor;\n float thinFilmWeight;\n\n // Medium\n int mediumType;\n vec3 mediumExtinction;\n vec3 mediumScattering;\n float mediumAnisotropy;\n\n float baseWeight;\n float diffuseRoughness;\n float specularWeight;\n vec3 specularColor;\n float subsurfaceWeight;\n vec3 subsurfaceColor;\n vec3 transmissionColor;\n float fuzzWeight;\n vec3 fuzzColor;\n float fuzzRoughness;\n float coatWeight;\n vec3 coatColor;\n float coatRoughness;\n float coatAnisotropy;\n vec2 anisotropyDirection;\n bool anisotropyDirectionEnabled;\n float coatAnisotropyRotation;\n vec3 directionTangent;\n vec3 directionBitangent;\n vec3 geometryTangent;\n vec3 geometryBitangent;\n#ifdef NUM_COAT_NORMAL_MAPS\n vec3 coatNormal;\n bool coatNormalEnabled;\n vec3 geometricNormal;\n#endif\n float coatIor;\n float coatDarkening;\n\n float bevel;\n\n // Calculated\n float relativeIor;\n bool inside;\n float alphaX;\n float alphaY;\n};\n\n\nstruct Light {\n vec3 position;\n vec3 emission;\n vec3 u;\n vec3 v;\n float radius;\n float area;\n float type;\n int textureIndex;\n float spread;\n float selectionPmf;\n float selectionCdf;\n vec3 iesReference;\n};\n\nvoid initRay(inout Ray ray, vec3 origin, vec3 direction) {\n ray.o = origin;\n ray.d = direction;\n ray.tMax = RAY_MAX_DISTANCE;\n}\n\n// given the index from a 1D array, retrieve corresponding position from packed 2D texture\nivec2 unpackTexel(int i, int columnsLog2) {\n ivec2 u;\n u.y = i >> columnsLog2; // equivalent to (i / 2^columnsLog2)\n u.x = i - (u.y << columnsLog2); // equivalent to (i % 2^columnsLog2)\n return u;\n}\n\nvec4 fetchData(sampler2D s, int i, int columnsLog2) {\n return texelFetch(s, unpackTexel(i, columnsLog2), 0);\n}\n\nivec4 fetchData(highp isampler2D s, int i, int columnsLog2) {\n return texelFetch(s, unpackTexel(i, columnsLog2), 0);\n}\n\nstruct Path {\n Ray ray;\n vec3 li;\n float alpha;\n vec3 beta;\n bool fromEye;\n bool abort;\n float scatteringPdf;\n bool scatteringIsDelta;\n bool isNextRefraction;\n};\n\nstruct LightSampleRec {\n vec3 normal;\n vec3 emission;\n vec3 direction;\n float dist;\n float pdf;\n bool isDelta;\n};\n\n\nLight fetchLight(int i) {\n int firstTexel = i * 6;\n vec4 positionAndPmf = texelFetch(\n lightsTex,\n ivec2(firstTexel, 0),\n 0\n );\n vec4 emissionAndCdf = texelFetch(\n lightsTex,\n ivec2(firstTexel + 1, 0),\n 0\n );\n vec4 tangentAndSpread = texelFetch(\n lightsTex,\n ivec2(firstTexel + 2, 0),\n 0\n );\n vec4 bitangentAndTexture = texelFetch(\n lightsTex,\n ivec2(firstTexel + 3, 0),\n 0\n );\n vec4 shape = texelFetch(\n lightsTex,\n ivec2(firstTexel + 4, 0),\n 0\n );\n return Light(\n positionAndPmf.xyz,\n emissionAndCdf.xyz,\n tangentAndSpread.xyz,\n bitangentAndTexture.xyz,\n shape.x,\n shape.y,\n shape.z,\n int(bitangentAndTexture.w),\n tangentAndSpread.w,\n positionAndPmf.w,\n emissionAndCdf.w,\n texelFetch(lightsTex, ivec2(firstTexel + 5, 0), 0).xyz\n );\n}\n\nfloat iesProfileScalar(int baseTexel, int scalarIndex) {\n int texelIndex = baseTexel + scalarIndex / 4;\n vec4 packed = texelFetch(\n iesProfileData,\n ivec2(texelIndex % iesProfileColumns, texelIndex / iesProfileColumns),\n 0\n );\n return packed[scalarIndex % 4];\n}\n\nfloat sampleIESProfile(int baseTexel, vec2 uv) {\n if (baseTexel < 0) return 1.0;\n vec2 pixel = fract(uv) * 128.0 - 0.5;\n ivec2 p0 = ivec2(floor(pixel));\n vec2 f = fract(pixel);\n int xa = p0.x < 0 ? 127 : p0.x;\n int xb = p0.x >= 127 ? 0 : p0.x + 1;\n int ya = p0.y < 0 ? 127 : p0.y;\n int yb = p0.y >= 127 ? 0 : p0.y + 1;\n float a = iesProfileScalar(baseTexel, ya * 128 + xa);\n float b = iesProfileScalar(baseTexel, ya * 128 + xb);\n float c = iesProfileScalar(baseTexel, yb * 128 + xa);\n float d = iesProfileScalar(baseTexel, yb * 128 + xb);\n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n}\n\nfloat evaluateSpotEmissionMultiplier(Light light, vec3 lightToSurface) {\n vec3 axis = normalize(light.u);\n float cosTheta = dot(axis, lightToSurface);\n float cone = light.v.y > light.v.x + 1e-6\n ? smoothstep(light.v.x, light.v.y, cosTheta)\n : step(light.v.x, cosTheta);\n if (cone <= 0.0 || light.textureIndex < 0) return cone;\n vec3 xAxis = light.iesReference;\n vec3 yAxis = cross(axis, xAxis);\n float vertical = acos(clamp(cosTheta, -1.0, 1.0));\n float horizontal = atan(dot(lightToSurface, yAxis), dot(lightToSurface, xAxis));\n return cone * sampleIESProfile(light.textureIndex, vec2(vertical / PI, horizontal / TWOPI + 0.5));\n}\n`\n});\n"]}
@@ -1,14 +1,14 @@
1
1
  import { glsl } from '../../shader.js';
2
2
  export default glsl `
3
3
  #ifdef NUM_LIGHTS
4
- void eJ(
4
+ void eM(
5
5
  in Light light,
6
6
  in vec3 shadingPoint,
7
7
  in vec2 samplePoint,
8
8
  inout LightSampleRec result
9
9
  ) {
10
- vec3 nH = light.position - shadingPoint;
11
- float aj = length(nH);
10
+ vec3 nS = light.position - shadingPoint;
11
+ float aj = length(nS);
12
12
  if (light.radius <= 0.0) {
13
13
  if (aj <= 1e-6) {
14
14
  result.direction = vec3(0.0, 0.0, 1.0);
@@ -19,7 +19,7 @@ result.emission = vec3(0.0);
19
19
  result.isDelta = true;
20
20
  return;
21
21
  }
22
- result.direction = nH / aj;
22
+ result.direction = nS / aj;
23
23
  result.normal = -result.direction;
24
24
  result.dist = aj;
25
25
  result.pdf = 1.0;
@@ -33,36 +33,36 @@ vec3 direction;
33
33
 
34
34
  if (aj <= radius) {
35
35
  float z = 1.0 - 2.0 * samplePoint.x;
36
- float fi = sqrt(max(0.0, 1.0 - z * z));
36
+ float fl = sqrt(max(0.0, 1.0 - z * z));
37
37
  float br = TWOPI * samplePoint.y;
38
- direction = vec3(fi * cos(br), fi * sin(br), z);
38
+ direction = vec3(fl * cos(br), fl * sin(br), z);
39
39
  result.pdf = INV4PI;
40
40
  }
41
41
  else {
42
- vec3 axis = nH / aj;
43
- float rL = min(
42
+ vec3 axis = nS / aj;
43
+ float rT = min(
44
44
  1.0,
45
45
  radius * radius / (aj * aj)
46
46
  );
47
- float rO = sqrt(max(0.0, 1.0 - rL));
48
- float au = mix(1.0, rO, samplePoint.x);
49
- float tW = sqrt(max(0.0, 1.0 - au * au));
47
+ float rW = sqrt(max(0.0, 1.0 - rT));
48
+ float au = mix(1.0, rW, samplePoint.x);
49
+ float ud = sqrt(max(0.0, 1.0 - au * au));
50
50
  float br = TWOPI * samplePoint.y;
51
51
  vec3 tangent;
52
52
  vec3 bitangent;
53
53
  aL(axis, tangent, bitangent);
54
54
  direction = axis * au
55
- + tangent * (tW * cos(br))
56
- + bitangent * (tW * sin(br));
57
- result.pdf = 1.0 / max(TWOPI * (1.0 - rO), 1e-8);
55
+ + tangent * (ud * cos(br))
56
+ + bitangent * (ud * sin(br));
57
+ result.pdf = 1.0 / max(TWOPI * (1.0 - rW), 1e-8);
58
58
  }
59
59
 
60
- float jb = dot(direction, nH);
61
- float ej = jb * jb
62
- - dot(nH, nH) + radius * radius;
63
- float wB = sqrt(max(0.0, ej));
64
- float cN = jb - wB;
65
- float cC = jb + wB;
60
+ float jf = dot(direction, nS);
61
+ float ej = jf * jf
62
+ - dot(nS, nS) + radius * radius;
63
+ float wK = sqrt(max(0.0, ej));
64
+ float cN = jf - wK;
65
+ float cC = jf + wK;
66
66
  result.dist = cN > 1e-6 ? cN : cC;
67
67
  result.direction = direction;
68
68
  vec3 surfacePoint = shadingPoint + direction * result.dist;
@@ -70,7 +70,7 @@ result.normal = normalize(surfacePoint - light.position);
70
70
  result.emission = light.emission;
71
71
  }
72
72
 
73
- void cZ(
73
+ void da(
74
74
  in Light light,
75
75
  in vec3 surfacePoint,
76
76
  in vec3 lowerLeft,
@@ -80,17 +80,17 @@ inout LightSampleRec result
80
80
  if (light.textureIndex >= 0) {
81
81
  float width = length(light.u);
82
82
  float height = length(light.v);
83
- vec3 hX = surfacePoint - lowerLeft;
83
+ vec3 ib = surfacePoint - lowerLeft;
84
84
  vec2 uv = vec2(
85
- dot(hX, light.u / width) / width,
86
- dot(hX, light.v / height) / height
85
+ dot(ib, light.u / width) / width,
86
+ dot(ib, light.v / height) / height
87
87
  );
88
88
  result.emission *= sampleMap(light.textureIndex, uv).rgb;
89
89
  }
90
90
  #endif
91
91
  }
92
92
 
93
- void jL(
93
+ void jS(
94
94
  in Light light,
95
95
  in vec3 shadingPoint,
96
96
  in vec2 samplePoint,
@@ -101,28 +101,28 @@ vec3 lowerLeft = light.position - 0.5 * (light.u + light.v);
101
101
  float spread = clamp(light.spread, 0.0, 1.0);
102
102
 
103
103
  if (spread <= 0.001) {
104
- float gb = dot(normal, shadingPoint - light.position);
105
- vec3 surfacePoint = shadingPoint - normal * gb;
106
- vec3 hX = surfacePoint - lowerLeft;
104
+ float gf = dot(normal, shadingPoint - light.position);
105
+ vec3 surfacePoint = shadingPoint - normal * gf;
106
+ vec3 ib = surfacePoint - lowerLeft;
107
107
  float width = length(light.u);
108
108
  float height = length(light.v);
109
109
  vec2 uv = vec2(
110
- dot(hX, light.u / width) / width,
111
- dot(hX, light.v / height) / height
110
+ dot(ib, light.u / width) / width,
111
+ dot(ib, light.v / height) / height
112
112
  );
113
- if (gb <= 0.0 || any(lessThan(uv, vec2(0.0)))
113
+ if (gf <= 0.0 || any(lessThan(uv, vec2(0.0)))
114
114
  || any(greaterThan(uv, vec2(1.0)))) {
115
115
  result.emission = vec3(0.0);
116
116
  result.pdf = 0.0;
117
117
  return;
118
118
  }
119
119
  result.direction = -normal;
120
- result.dist = gb;
120
+ result.dist = gf;
121
121
  result.normal = normal;
122
122
  result.emission = light.emission;
123
123
  result.pdf = 1.0;
124
124
  result.isDelta = true;
125
- cZ(light, surfacePoint, lowerLeft, result);
125
+ da(light, surfacePoint, lowerLeft, result);
126
126
  return;
127
127
  }
128
128
 
@@ -130,23 +130,23 @@ vec3 surfacePoint = lowerLeft
130
130
  + light.u * samplePoint.x
131
131
  + light.v * samplePoint.y;
132
132
  vec3 offset = surfacePoint - shadingPoint;
133
- float hl = dot(offset, offset);
134
- result.dist = sqrt(hl);
133
+ float hq = dot(offset, offset);
134
+ result.dist = sqrt(hq);
135
135
  result.direction = offset / result.dist;
136
136
  result.normal = normal;
137
- float fV = dot(-result.direction, normal);
138
- float oF = cos(0.5 * PI * spread);
139
- if (fV <= 0.0 || fV < oF) {
137
+ float fZ = dot(-result.direction, normal);
138
+ float oO = cos(0.5 * PI * spread);
139
+ if (fZ <= 0.0 || fZ < oO) {
140
140
  result.emission = vec3(0.0);
141
141
  result.pdf = 0.0;
142
142
  return;
143
143
  }
144
144
  result.emission = light.emission;
145
- result.pdf = hl / max(light.area * fV, 1e-8);
146
- cZ(light, surfacePoint, lowerLeft, result);
145
+ result.pdf = hq / max(light.area * fZ, 1e-8);
146
+ da(light, surfacePoint, lowerLeft, result);
147
147
  }
148
148
 
149
- void fY(
149
+ void gc(
150
150
  in Light light,
151
151
  in vec3 shadingPoint,
152
152
  inout LightSampleRec result
@@ -159,13 +159,13 @@ result.pdf = 1.0;
159
159
  result.isDelta = true;
160
160
  }
161
161
 
162
- void jM(
162
+ void jT(
163
163
  in Light light,
164
164
  in vec3 shadingPoint,
165
165
  in vec2 samplePoint,
166
166
  inout LightSampleRec result
167
167
  ) {
168
- eJ(light, shadingPoint, samplePoint, result);
168
+ eM(light, shadingPoint, samplePoint, result);
169
169
  vec3 surfacePoint = shadingPoint + result.direction * result.dist;
170
170
  result.emission *= bL(
171
171
  light,
@@ -173,42 +173,42 @@ normalize(shadingPoint - surfacePoint)
173
173
  );
174
174
  }
175
175
 
176
- void iL(
176
+ void iQ(
177
177
  in Light light,
178
178
  in vec3 shadingPoint,
179
179
  in vec2 samplePoint,
180
180
  inout LightSampleRec result
181
181
  ) {
182
- int dO = int(light.type);
182
+ int dP = int(light.type);
183
183
  #ifdef HAS_RECT_LIGHTS
184
- if (dO == RECT_LIGHT) {
185
- jL(light, shadingPoint, samplePoint, result);
184
+ if (dP == RECT_LIGHT) {
185
+ jS(light, shadingPoint, samplePoint, result);
186
186
  return;
187
187
  }
188
188
  #endif
189
189
  #ifdef HAS_SPHERE_LIGHTS
190
- if (dO == SPHERE_LIGHT) {
191
- eJ(light, shadingPoint, samplePoint, result);
190
+ if (dP == SPHERE_LIGHT) {
191
+ eM(light, shadingPoint, samplePoint, result);
192
192
  return;
193
193
  }
194
194
  #endif
195
195
  #ifdef HAS_SPOT_LIGHTS
196
- if (dO == SPOT_LIGHT) {
197
- jM(light, shadingPoint, samplePoint, result);
196
+ if (dP == SPOT_LIGHT) {
197
+ jT(light, shadingPoint, samplePoint, result);
198
198
  return;
199
199
  }
200
200
  #endif
201
201
  #ifdef HAS_DIRECTIONAL_LIGHTS
202
- if (dO == DIRECTIONAL_LIGHT) {
203
- fY(light, shadingPoint, result);
202
+ if (dP == DIRECTIONAL_LIGHT) {
203
+ gc(light, shadingPoint, result);
204
204
  }
205
205
  #endif
206
206
  }
207
207
  #endif
208
208
 
209
- void mx(in vec2 samplePoint, inout LightSampleRec result) {
209
+ void mH(in vec2 samplePoint, inout LightSampleRec result) {
210
210
  vec2 uv;
211
- result.direction = oD(samplePoint, uv, result.pdf);
211
+ result.direction = oM(samplePoint, uv, result.pdf);
212
212
  result.emission = textureLinear(envMap, uv).rgb;
213
213
  result.dist = INF;
214
214
  }
@@ -217,36 +217,36 @@ void sampleLight(
217
217
  in vec3 shadingPoint,
218
218
  in vec3 randomSampleValue,
219
219
  inout LightSampleRec result,
220
- bool rU
220
+ bool sc
221
221
  ) {
222
222
  result.isDelta = false;
223
- float tV = randomSampleValue.z;
224
- bool kq = false;
223
+ float uc = randomSampleValue.z;
224
+ bool kA = false;
225
225
  #ifdef USE_ENVMAP
226
- kq = tV < envLightSelectionPmf;
227
- if (kq) {
228
- mx(randomSampleValue.xy, result);
226
+ kA = uc < envLightSelectionPmf;
227
+ if (kA) {
228
+ mH(randomSampleValue.xy, result);
229
229
  result.pdf *= envLightSelectionPmf;
230
230
  }
231
231
  #endif
232
232
 
233
233
  #ifdef NUM_LIGHTS
234
- if (!kq) {
235
- int kT = NUM_LIGHTS - 1;
234
+ if (!kA) {
235
+ int lc = NUM_LIGHTS - 1;
236
236
  for (int index = 0; index < NUM_LIGHTS; index++) {
237
- if (tV < qp(index).selectionCdf) {
238
- kT = index;
237
+ if (uc < qx(index).selectionCdf) {
238
+ lc = index;
239
239
  break;
240
240
  }
241
241
  }
242
- Light qf = qp(kT);
243
- iL(
244
- qf,
242
+ Light qn = qx(lc);
243
+ iQ(
244
+ qn,
245
245
  shadingPoint,
246
246
  randomSampleValue.xy,
247
247
  result
248
248
  );
249
- result.pdf *= qf.selectionPmf;
249
+ result.pdf *= qn.selectionPmf;
250
250
  }
251
251
  #endif
252
252
  }