@zephyr3d/scene 0.1.2 → 0.2.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 (146) hide show
  1. package/dist/asset/assetmanager.js +124 -67
  2. package/dist/asset/assetmanager.js.map +1 -1
  3. package/dist/asset/builtin.js +2 -2
  4. package/dist/asset/loaders/gltf/gltf_loader.js +105 -59
  5. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
  6. package/dist/asset/loaders/hdr/hdr.js +1 -1
  7. package/dist/blitter/blitter.js +0 -1
  8. package/dist/blitter/blitter.js.map +1 -1
  9. package/dist/blitter/depthlimitedgaussion.js +0 -1
  10. package/dist/blitter/depthlimitedgaussion.js.map +1 -1
  11. package/dist/blitter/gaussianblur.js +0 -1
  12. package/dist/blitter/gaussianblur.js.map +1 -1
  13. package/dist/camera/camera.js +10 -8
  14. package/dist/camera/camera.js.map +1 -1
  15. package/dist/camera/orbit.js +24 -7
  16. package/dist/camera/orbit.js.map +1 -1
  17. package/dist/index.d.ts +1842 -2484
  18. package/dist/index.js +21 -10
  19. package/dist/index.js.map +1 -1
  20. package/dist/material/blinn.js +47 -57
  21. package/dist/material/blinn.js.map +1 -1
  22. package/dist/material/grassmat.js +127 -0
  23. package/dist/material/grassmat.js.map +1 -0
  24. package/dist/material/grassmaterial.js +66 -194
  25. package/dist/material/grassmaterial.js.map +1 -1
  26. package/dist/material/lambert.js +48 -22
  27. package/dist/material/lambert.js.map +1 -1
  28. package/dist/material/lightmodel.js +4 -4
  29. package/dist/material/material.js +100 -59
  30. package/dist/material/material.js.map +1 -1
  31. package/dist/material/meshmaterial.js +227 -186
  32. package/dist/material/meshmaterial.js.map +1 -1
  33. package/dist/material/mixins/albedocolor.js +29 -100
  34. package/dist/material/mixins/albedocolor.js.map +1 -1
  35. package/dist/material/mixins/foliage.js +47 -0
  36. package/dist/material/mixins/foliage.js.map +1 -0
  37. package/dist/material/mixins/ggxlut.js +213 -0
  38. package/dist/material/mixins/ggxlut.js.map +1 -0
  39. package/dist/material/mixins/lightmodel/blinnphong.js +89 -0
  40. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -0
  41. package/dist/material/mixins/lightmodel/lambert.js +58 -0
  42. package/dist/material/mixins/lightmodel/lambert.js.map +1 -0
  43. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +132 -0
  44. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  45. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +105 -0
  46. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  47. package/dist/material/mixins/lit.js +464 -0
  48. package/dist/material/mixins/lit.js.map +1 -0
  49. package/dist/material/mixins/pbr/common.js +451 -0
  50. package/dist/material/mixins/pbr/common.js.map +1 -0
  51. package/dist/material/mixins/pbr/metallicroughness.js +126 -0
  52. package/dist/material/mixins/pbr/metallicroughness.js.map +1 -0
  53. package/dist/material/mixins/pbr/specularglossness.js +104 -0
  54. package/dist/material/mixins/pbr/specularglossness.js.map +1 -0
  55. package/dist/material/mixins/texture.js +157 -0
  56. package/dist/material/mixins/texture.js.map +1 -0
  57. package/dist/material/mixins/vertexcolor.js +16 -11
  58. package/dist/material/mixins/vertexcolor.js.map +1 -1
  59. package/dist/material/pbrmr.js +65 -0
  60. package/dist/material/pbrmr.js.map +1 -0
  61. package/dist/material/pbrsg.js +64 -0
  62. package/dist/material/pbrsg.js.map +1 -0
  63. package/dist/material/shader/helper.js +903 -0
  64. package/dist/material/shader/helper.js.map +1 -0
  65. package/dist/material/terrainmat.js +357 -0
  66. package/dist/material/terrainmat.js.map +1 -0
  67. package/dist/material/terrainmaterial.js +311 -103
  68. package/dist/material/terrainmaterial.js.map +1 -1
  69. package/dist/material/unlit.js +12 -9
  70. package/dist/material/unlit.js.map +1 -1
  71. package/dist/posteffect/bloom.js +8 -6
  72. package/dist/posteffect/bloom.js.map +1 -1
  73. package/dist/posteffect/compositor.js +14 -6
  74. package/dist/posteffect/compositor.js.map +1 -1
  75. package/dist/posteffect/posteffect.js +1 -1
  76. package/dist/posteffect/sao.js +8 -5
  77. package/dist/posteffect/sao.js.map +1 -1
  78. package/dist/posteffect/tonemap.js +2 -2
  79. package/dist/posteffect/water.js +10 -8
  80. package/dist/posteffect/water.js.map +1 -1
  81. package/dist/render/cluster_light.js +6 -5
  82. package/dist/render/cluster_light.js.map +1 -1
  83. package/dist/render/depthpass.js +46 -0
  84. package/dist/render/depthpass.js.map +1 -0
  85. package/dist/render/envlight.js +26 -24
  86. package/dist/render/envlight.js.map +1 -1
  87. package/dist/render/fullscreenquad.js +38 -0
  88. package/dist/render/fullscreenquad.js.map +1 -0
  89. package/dist/render/lightpass.js +98 -0
  90. package/dist/render/lightpass.js.map +1 -0
  91. package/dist/render/render_queue.js +2 -1
  92. package/dist/render/render_queue.js.map +1 -1
  93. package/dist/render/renderer.js +191 -0
  94. package/dist/render/renderer.js.map +1 -0
  95. package/dist/render/renderpass.js +10 -8
  96. package/dist/render/renderpass.js.map +1 -1
  97. package/dist/render/shadowmap_pass.js +3 -4
  98. package/dist/render/shadowmap_pass.js.map +1 -1
  99. package/dist/render/sky.js +31 -15
  100. package/dist/render/sky.js.map +1 -1
  101. package/dist/scene/environment.js +8 -6
  102. package/dist/scene/environment.js.map +1 -1
  103. package/dist/scene/graph_node.js +3 -0
  104. package/dist/scene/graph_node.js.map +1 -1
  105. package/dist/scene/mesh.js +13 -12
  106. package/dist/scene/mesh.js.map +1 -1
  107. package/dist/scene/scene.js +11 -15
  108. package/dist/scene/scene.js.map +1 -1
  109. package/dist/scene/scene_node.js +10 -16
  110. package/dist/scene/scene_node.js.map +1 -1
  111. package/dist/scene/terrain/grass.js +4 -14
  112. package/dist/scene/terrain/grass.js.map +1 -1
  113. package/dist/scene/terrain/patch.js +3 -3
  114. package/dist/scene/terrain/terrain.js +4 -9
  115. package/dist/scene/terrain/terrain.js.map +1 -1
  116. package/dist/shaders/framework.js +17 -3
  117. package/dist/shaders/framework.js.map +1 -1
  118. package/dist/shaders/misc.js +13 -161
  119. package/dist/shaders/misc.js.map +1 -1
  120. package/dist/shaders/noise.js +7 -7
  121. package/dist/shaders/pbr.js +1 -82
  122. package/dist/shaders/pbr.js.map +1 -1
  123. package/dist/shaders/shadow.js +33 -31
  124. package/dist/shaders/shadow.js.map +1 -1
  125. package/dist/shaders/water.js +3 -9
  126. package/dist/shaders/water.js.map +1 -1
  127. package/dist/shadow/esm.js +11 -9
  128. package/dist/shadow/esm.js.map +1 -1
  129. package/dist/shadow/pcf_opt.js +15 -15
  130. package/dist/shadow/pcf_pd.js +15 -15
  131. package/dist/shadow/shadowmapper.js +13 -15
  132. package/dist/shadow/shadowmapper.js.map +1 -1
  133. package/dist/shadow/ssm.js +21 -55
  134. package/dist/shadow/ssm.js.map +1 -1
  135. package/dist/shadow/vsm.js +15 -13
  136. package/dist/shadow/vsm.js.map +1 -1
  137. package/dist/shapes/torus.js +2 -2
  138. package/dist/utility/bounding_volume.js +27 -27
  139. package/dist/utility/pmrem.js +4 -4
  140. package/dist/utility/sheenlut.js +196 -0
  141. package/dist/utility/sheenlut.js.map +1 -0
  142. package/dist/utility/shprojection.js +0 -1
  143. package/dist/utility/shprojection.js.map +1 -1
  144. package/dist/values.js +11 -8
  145. package/dist/values.js.map +1 -1
  146. package/package.json +3 -3
@@ -1,20 +1,22 @@
1
1
  import { ShadowImpl } from './shadow_impl.js';
2
2
  import '@zephyr3d/base';
3
3
  import { Application } from '../app.js';
4
- import { ShaderFramework } from '../shaders/framework.js';
5
4
  import { decodeNormalizedFloatFromRGBA, encodeNormalizedFloatToRGBA } from '../shaders/misc.js';
6
5
  import { GaussianBlurBlitter } from '../blitter/gaussianblur.js';
7
6
  import { computeShadowMapDepth, filterShadowESM } from '../shaders/shadow.js';
8
7
  import '../scene/octree.js';
9
8
  import { LIGHT_TYPE_POINT } from '../values.js';
10
- import '../material/material.js';
11
- import '@zephyr3d/device';
12
- import '../render/scatteringlut.js';
9
+ import { ShaderHelper } from '../material/shader/helper.js';
13
10
  import '../material/lambert.js';
14
11
  import '../material/blinn.js';
15
12
  import '../material/unlit.js';
16
- import '../material/lightmodel.js';
17
- import '../render/forward.js';
13
+ import '../material/material.js';
14
+ import '../material/meshmaterial.js';
15
+ import '../material/grassmaterial.js';
16
+ import '../material/terrainmaterial.js';
17
+ import '../material/pbrmr.js';
18
+ import '../material/pbrsg.js';
19
+ import '../render/renderer.js';
18
20
  import '../render/sky.js';
19
21
  import '../render/clipmap.js';
20
22
  import { TemporalCache } from '../render/temporalcache.js';
@@ -181,8 +183,8 @@ class BlurBlitter extends GaussianBlurBlitter {
181
183
  getShadowMapDepthFormat(shadowMapParams) {
182
184
  return 'd24s8';
183
185
  }
184
- computeShadowMapDepth(shadowMapParams, scope) {
185
- return computeShadowMapDepth(scope, shadowMapParams.shadowMap.format);
186
+ computeShadowMapDepth(shadowMapParams, scope, worldPos) {
187
+ return computeShadowMapDepth(scope, worldPos, shadowMapParams.shadowMap.format);
186
188
  }
187
189
  computeShadowCSM(shadowMapParams, scope, shadowVertex, NdotL, split) {
188
190
  const funcNameComputeShadowCSM = 'lib_computeShadowCSM';
@@ -211,7 +213,7 @@ class BlurBlitter extends GaussianBlurBlitter {
211
213
  pb.float('NdotL')
212
214
  ], function() {
213
215
  if (shadowMapParams.lightType === LIGHT_TYPE_POINT) {
214
- this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderFramework.getLightPositionAndRangeForShadow(this).xyz);
216
+ this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderHelper.getLightPositionAndRangeForShadow(this).xyz);
215
217
  this.$return(filterShadowESM(this, LIGHT_TYPE_POINT, shadowMapParams.shadowMap.format, this.dir));
216
218
  } else {
217
219
  this.$l.shadowCoord = pb.div(this.shadowVertex, this.shadowVertex.w);
@@ -1 +1 @@
1
- {"version":3,"file":"esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,10 +1,10 @@
1
1
  import { ShadowImpl } from './shadow_impl.js';
2
- import { linearDepthToNonLinear, decodeNormalizedFloatFromRGBA } from '../shaders/misc.js';
2
+ import { decodeNormalizedFloatFromRGBA } from '../shaders/misc.js';
3
3
  import { computeShadowMapDepth, computeReceiverPlaneDepthBias, filterShadowPCF } from '../shaders/shadow.js';
4
4
  import { ShadowMapper } from './shadowmapper.js';
5
- import { ShaderFramework } from '../shaders/framework.js';
6
5
  import { Application } from '../app.js';
7
6
  import { LIGHT_TYPE_POINT } from '../values.js';
7
+ import { ShaderHelper } from '../material/shader/helper.js';
8
8
 
9
9
  /** @internal */ class PCFOPT extends ShadowImpl {
10
10
  _kernelSize;
@@ -55,8 +55,8 @@ import { LIGHT_TYPE_POINT } from '../values.js';
55
55
  getShadowMapDepthFormat(shadowMapParams) {
56
56
  return Application.instance.device.type === 'webgl' ? 'd24s8' : 'd32f';
57
57
  }
58
- computeShadowMapDepth(shadowMapParams, scope) {
59
- return computeShadowMapDepth(scope, shadowMapParams.shadowMap.format);
58
+ computeShadowMapDepth(shadowMapParams, scope, worldPos) {
59
+ return computeShadowMapDepth(scope, worldPos, shadowMapParams.shadowMap.format);
60
60
  }
61
61
  computeShadowCSM(shadowMapParams, scope, shadowVertex, NdotL, split) {
62
62
  const funcNameComputeShadowCSM = 'lib_computeShadowCSM';
@@ -90,15 +90,15 @@ import { LIGHT_TYPE_POINT } from '../values.js';
90
90
  pb.float('NdotL')
91
91
  ], function() {
92
92
  if (shadowMapParams.lightType === LIGHT_TYPE_POINT) {
93
- this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderFramework.getLightPositionAndRangeForShadow(this).xyz);
93
+ this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderHelper.getLightPositionAndRangeForShadow(this).xyz);
94
94
  if (that.useNativeShadowMap(shadowMapParams)) {
95
- this.$l.nearFar = ShaderFramework.getShadowCameraParams(this).xy;
95
+ this.$l.nearFar = ShaderHelper.getShadowCameraParams(this).xy;
96
96
  this.$l.maxZ = pb.max(pb.max(pb.abs(this.dir.x), pb.abs(this.dir.y)), pb.abs(this.dir.z));
97
- this.$l.distance = linearDepthToNonLinear(this, this.maxZ, this.nearFar);
98
- this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, pb.div(this.maxZ, ShaderFramework.getLightPositionAndRangeForShadow(this).w), this.NdotL, true);
97
+ this.$l.distance = ShaderHelper.linearDepthToNonLinear(this, this.maxZ, this.nearFar);
98
+ this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, pb.div(this.maxZ, ShaderHelper.getLightPositionAndRangeForShadow(this).w), this.NdotL, true);
99
99
  this.$return(that.sampleShadowMap(shadowMapParams, this, this.dir, this.distance, this.shadowBias));
100
100
  } else {
101
- this.$l.distance = pb.div(pb.length(this.dir), ShaderFramework.getLightPositionAndRangeForShadow(this).w);
101
+ this.$l.distance = pb.div(pb.length(this.dir), ShaderHelper.getLightPositionAndRangeForShadow(this).w);
102
102
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.distance, this.NdotL, true);
103
103
  this.$return(that.sampleShadowMap(shadowMapParams, this, this.dir, this.distance, this.shadowBias));
104
104
  }
@@ -132,9 +132,9 @@ import { LIGHT_TYPE_POINT } from '../values.js';
132
132
  ], function() {
133
133
  const floatDepthTexture = shadowMapParams.shadowMap.format !== 'rgba8unorm';
134
134
  if (that.useNativeShadowMap(shadowMapParams)) {
135
- this.$return(pb.clamp(pb.textureSampleCompareLevel(this.shadowMap, this.coords, pb.sub(this.z, this.bias)), 0, 1));
135
+ this.$return(pb.clamp(pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords, pb.sub(this.z, this.bias)), 0, 1));
136
136
  } else {
137
- this.$l.shadowTex = pb.textureSampleLevel(this.shadowMap, this.coords, 0);
137
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.coords, 0);
138
138
  if (!floatDepthTexture) {
139
139
  this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
140
140
  }
@@ -158,15 +158,15 @@ import { LIGHT_TYPE_POINT } from '../values.js';
158
158
  this.$l.distance = pb.sub(this.z, this.bias);
159
159
  if (that.useNativeShadowMap(shadowMapParams)) {
160
160
  if (shadowMapParams.shadowMap.isTexture2DArray()) {
161
- this.$return(pb.clamp(pb.textureArraySampleCompareLevel(this.shadowMap, this.coords.xy, this.split, this.distance), 0, 1));
161
+ this.$return(pb.clamp(pb.textureArraySampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords.xy, this.split, this.distance), 0, 1));
162
162
  } else {
163
- this.$return(pb.clamp(pb.textureSampleCompareLevel(this.shadowMap, this.coords.xy, this.distance), 0, 1));
163
+ this.$return(pb.clamp(pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords.xy, this.distance), 0, 1));
164
164
  }
165
165
  } else {
166
166
  if (shadowMapParams.shadowMap.isTexture2DArray()) {
167
- this.$l.shadowTex = pb.textureArraySampleLevel(this.shadowMap, this.coords.xy, this.split, 0);
167
+ this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.coords.xy, this.split, 0);
168
168
  } else {
169
- this.$l.shadowTex = pb.textureSampleLevel(this.shadowMap, this.coords.xy, 0);
169
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.coords.xy, 0);
170
170
  }
171
171
  if (!floatDepthTexture) {
172
172
  this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
@@ -1,10 +1,10 @@
1
1
  import { ShadowImpl } from './shadow_impl.js';
2
2
  import { computeShadowMapDepth, computeReceiverPlaneDepthBias, filterShadowPoissonDisc } from '../shaders/shadow.js';
3
3
  import { ShadowMapper } from './shadowmapper.js';
4
- import { linearDepthToNonLinear, decodeNormalizedFloatFromRGBA } from '../shaders/misc.js';
5
- import { ShaderFramework } from '../shaders/framework.js';
4
+ import { decodeNormalizedFloatFromRGBA } from '../shaders/misc.js';
6
5
  import { Application } from '../app.js';
7
6
  import { LIGHT_TYPE_POINT } from '../values.js';
7
+ import { ShaderHelper } from '../material/shader/helper.js';
8
8
 
9
9
  /** @internal */ class PCFPD extends ShadowImpl {
10
10
  _tapCount;
@@ -63,8 +63,8 @@ import { LIGHT_TYPE_POINT } from '../values.js';
63
63
  getShadowMapDepthFormat(shadowMapParams) {
64
64
  return Application.instance.device.type === 'webgl' ? 'd24s8' : 'd32f';
65
65
  }
66
- computeShadowMapDepth(shadowMapParams, scope) {
67
- return computeShadowMapDepth(scope, shadowMapParams.shadowMap.format);
66
+ computeShadowMapDepth(shadowMapParams, scope, worldPos) {
67
+ return computeShadowMapDepth(scope, worldPos, shadowMapParams.shadowMap.format);
68
68
  }
69
69
  computeShadowCSM(shadowMapParams, scope, shadowVertex, NdotL, split) {
70
70
  const funcNameComputeShadowCSM = 'lib_computeShadowCSM';
@@ -98,15 +98,15 @@ import { LIGHT_TYPE_POINT } from '../values.js';
98
98
  pb.float('NdotL')
99
99
  ], function() {
100
100
  if (shadowMapParams.lightType === LIGHT_TYPE_POINT) {
101
- this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderFramework.getLightPositionAndRangeForShadow(this).xyz);
101
+ this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderHelper.getLightPositionAndRangeForShadow(this).xyz);
102
102
  if (that.useNativeShadowMap(shadowMapParams)) {
103
- this.$l.nearFar = ShaderFramework.getShadowCameraParams(this).xy;
103
+ this.$l.nearFar = ShaderHelper.getShadowCameraParams(this).xy;
104
104
  this.$l.maxZ = pb.max(pb.max(pb.abs(this.dir.x), pb.abs(this.dir.y)), pb.abs(this.dir.z));
105
- this.$l.distance = linearDepthToNonLinear(this, this.maxZ, this.nearFar);
106
- this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, pb.div(this.maxZ, ShaderFramework.getLightPositionAndRangeForShadow(this).w), this.NdotL, true);
105
+ this.$l.distance = ShaderHelper.linearDepthToNonLinear(this, this.maxZ, this.nearFar);
106
+ this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, pb.div(this.maxZ, ShaderHelper.getLightPositionAndRangeForShadow(this).w), this.NdotL, true);
107
107
  this.$return(that.sampleShadowMap(shadowMapParams, this, this.dir, this.distance, this.shadowBias));
108
108
  } else {
109
- this.$l.distance = pb.div(pb.length(this.dir), ShaderFramework.getLightPositionAndRangeForShadow(this).w);
109
+ this.$l.distance = pb.div(pb.length(this.dir), ShaderHelper.getLightPositionAndRangeForShadow(this).w);
110
110
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.distance, this.NdotL, true);
111
111
  this.$return(that.sampleShadowMap(shadowMapParams, this, this.dir, this.distance, this.shadowBias));
112
112
  }
@@ -140,9 +140,9 @@ import { LIGHT_TYPE_POINT } from '../values.js';
140
140
  ], function() {
141
141
  const floatDepthTexture = shadowMapParams.shadowMap.format !== 'rgba8unorm';
142
142
  if (that.useNativeShadowMap(shadowMapParams)) {
143
- this.$return(pb.clamp(pb.textureSampleCompareLevel(this.shadowMap, this.coords, pb.sub(this.z, this.bias)), 0, 1));
143
+ this.$return(pb.clamp(pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords, pb.sub(this.z, this.bias)), 0, 1));
144
144
  } else {
145
- this.$l.shadowTex = pb.textureSampleLevel(this.shadowMap, this.coords, 0);
145
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.coords, 0);
146
146
  if (!floatDepthTexture) {
147
147
  this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
148
148
  }
@@ -166,15 +166,15 @@ import { LIGHT_TYPE_POINT } from '../values.js';
166
166
  this.$l.distance = pb.sub(this.z, this.bias);
167
167
  if (that.useNativeShadowMap(shadowMapParams)) {
168
168
  if (shadowMapParams.shadowMap.isTexture2DArray()) {
169
- this.$return(pb.clamp(pb.textureArraySampleCompareLevel(this.shadowMap, this.coords.xy, this.split, this.distance), 0, 1));
169
+ this.$return(pb.clamp(pb.textureArraySampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords.xy, this.split, this.distance), 0, 1));
170
170
  } else {
171
- this.$return(pb.clamp(pb.textureSampleCompareLevel(this.shadowMap, this.coords.xy, this.distance), 0, 1));
171
+ this.$return(pb.clamp(pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords.xy, this.distance), 0, 1));
172
172
  }
173
173
  } else {
174
174
  if (shadowMapParams.shadowMap.isTexture2DArray()) {
175
- this.$l.shadowTex = pb.textureArraySampleLevel(this.shadowMap, this.coords.xy, this.split, 0);
175
+ this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.coords.xy, this.split, 0);
176
176
  } else {
177
- this.$l.shadowTex = pb.textureSampleLevel(this.shadowMap, this.coords.xy, 0);
177
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.coords.xy, 0);
178
178
  }
179
179
  if (!floatDepthTexture) {
180
180
  this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
@@ -5,19 +5,20 @@ import { ESM } from './esm.js';
5
5
  import { VSM } from './vsm.js';
6
6
  import { PCFPD } from './pcf_pd.js';
7
7
  import { PCFOPT } from './pcf_opt.js';
8
- import { nonLinearDepthToLinearNormalized } from '../shaders/misc.js';
9
- import { ShaderFramework } from '../shaders/framework.js';
10
8
  import { Application } from '../app.js';
11
9
  import '../scene/octree.js';
12
10
  import { LIGHT_TYPE_NONE, LIGHT_TYPE_DIRECTIONAL } from '../values.js';
13
- import '../material/material.js';
14
- import '@zephyr3d/device';
15
- import '../render/scatteringlut.js';
11
+ import { ShaderHelper } from '../material/shader/helper.js';
16
12
  import '../material/lambert.js';
17
13
  import '../material/blinn.js';
18
14
  import '../material/unlit.js';
19
- import '../material/lightmodel.js';
20
- import '../render/forward.js';
15
+ import '../material/material.js';
16
+ import '../material/meshmaterial.js';
17
+ import '../material/grassmaterial.js';
18
+ import '../material/terrainmaterial.js';
19
+ import '../material/pbrmr.js';
20
+ import '../material/pbrsg.js';
21
+ import '../render/renderer.js';
21
22
  import '../render/sky.js';
22
23
  import '../render/clipmap.js';
23
24
  import { TemporalCache } from '../render/temporalcache.js';
@@ -269,9 +270,6 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
269
270
  this.asESM()?.setDepthScale(this._esmDepthScale);
270
271
  }
271
272
  }
272
- /** @internal */ computeShadowMapDepth(shadowMapParams, scope) {
273
- return this._impl.computeShadowMapDepth(shadowMapParams, scope);
274
- }
275
273
  /** @internal */ computeShadow(shadowMapParams, scope, shadowVertex, NdotL) {
276
274
  return this._impl.computeShadow(shadowMapParams, scope, shadowVertex, NdotL);
277
275
  }
@@ -300,21 +298,21 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
300
298
  }
301
299
  /** @internal */ static computeShadowBias(shadowMapParams, scope, z, NdotL, linear) {
302
300
  const pb = scope.$builder;
303
- const depthBiasParam = ShaderFramework.getDepthBiasValues(scope);
301
+ const depthBiasParam = ShaderHelper.getDepthBiasValues(scope);
304
302
  if (shadowMapParams.lightType === LIGHT_TYPE_DIRECTIONAL) {
305
303
  return pb.dot(pb.mul(depthBiasParam.xy, pb.vec2(1, pb.sub(1, NdotL))), pb.vec2(1, 1));
306
304
  } else {
307
- const nearFar = ShaderFramework.getShadowCameraParams(scope).xy;
308
- const linearDepth = linear ? z : nonLinearDepthToLinearNormalized(scope, z, nearFar);
305
+ const nearFar = ShaderHelper.getShadowCameraParams(scope).xy;
306
+ const linearDepth = linear ? z : ShaderHelper.nonLinearDepthToLinearNormalized(scope, z, nearFar);
309
307
  const biasScaleFactor = pb.mix(1, depthBiasParam.w, linearDepth);
310
308
  return pb.dot(pb.mul(depthBiasParam.xy, pb.vec2(1, pb.sub(1, NdotL)), biasScaleFactor), pb.vec2(1, 1));
311
309
  }
312
310
  }
313
311
  /** @internal */ static computeShadowBiasCSM(shadowMapParams, scope, NdotL, split) {
314
312
  const pb = scope.$builder;
315
- const depthBiasParam = ShaderFramework.getDepthBiasValues(scope);
313
+ const depthBiasParam = ShaderHelper.getDepthBiasValues(scope);
316
314
  const splitFlags = pb.vec4(pb.float(pb.equal(split, 0)), pb.float(pb.equal(split, 1)), pb.float(pb.equal(split, 2)), pb.float(pb.equal(split, 3)));
317
- const depthBiasScale = pb.dot(ShaderFramework.getDepthBiasScales(scope), splitFlags);
315
+ const depthBiasScale = pb.dot(ShaderHelper.getDepthBiasScales(scope), splitFlags);
318
316
  return pb.dot(pb.mul(depthBiasParam.xy, pb.vec2(1, pb.sub(1, NdotL)), depthBiasScale), pb.vec2(1, 1));
319
317
  }
320
318
  /** @internal */ isTextureInvalid(texture, target, format, width, height) {
@@ -1 +1 @@
1
- {"version":3,"file":"shadowmapper.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"shadowmapper.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,10 +1,10 @@
1
1
  import { ShadowImpl } from './shadow_impl.js';
2
- import { ShaderFramework } from '../shaders/framework.js';
3
- import { decodeNormalizedFloatFromRGBA, linearDepthToNonLinear, nonLinearDepthToLinearNormalized } from '../shaders/misc.js';
4
- import { Application } from '../app.js';
2
+ import { decodeNormalizedFloatFromRGBA } from '../shaders/misc.js';
5
3
  import { ShadowMapper } from './shadowmapper.js';
4
+ import { Application } from '../app.js';
6
5
  import { LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } from '../values.js';
7
6
  import { computeShadowMapDepth } from '../shaders/shadow.js';
7
+ import { ShaderHelper } from '../material/shader/helper.js';
8
8
 
9
9
  /** @internal */ class SSM extends ShadowImpl {
10
10
  static instance = new SSM();
@@ -51,43 +51,9 @@ import { computeShadowMapDepth } from '../shaders/shadow.js';
51
51
  getShadowMapDepthFormat(shadowMapParams) {
52
52
  return Application.instance.device.type === 'webgl' ? 'd24s8' : 'd32f';
53
53
  }
54
- computeShadowMapDepth(shadowMapParams, scope) {
55
- return computeShadowMapDepth(scope, shadowMapParams.shadowMap.format);
56
- /*
57
- if (this.useNativeShadowMap(shadowMapParams)) {
58
- return scope.$builder.vec4(
59
- scope.$builder.emulateDepthClamp
60
- ? scope.$builder.clamp(scope.$inputs.clamppedDepth, 0, 1)
61
- : scope.$builtins.fragCoord.z,
62
- 0,
63
- 0,
64
- 1
65
- );
66
- } else {
67
- const pb = scope.$builder;
68
- let depth: PBShaderExp = null;
69
- if (shadowMapParams.lightType === LIGHT_TYPE_DIRECTIONAL) {
70
- depth = pb.emulateDepthClamp
71
- ? pb.clamp(scope.$inputs.clamppedDepth, 0, 1)
72
- : scope.$builtins.fragCoord.z;
73
- } else if (shadowMapParams.lightType === LIGHT_TYPE_POINT) {
74
- const lightSpacePos = pb.mul(
75
- ShaderFramework.getLightViewMatrixForShadow(scope),
76
- ShaderFramework.getWorldPosition(scope)
77
- );
78
- depth = pb.div(pb.length(lightSpacePos.xyz), ShaderFramework.getLightPositionAndRangeForShadow(scope).w);
79
- } else if (shadowMapParams.lightType === LIGHT_TYPE_SPOT) {
80
- const lightSpacePos = pb.mul(
81
- ShaderFramework.getLightViewMatrixForShadow(scope),
82
- ShaderFramework.getWorldPosition(scope)
83
- );
84
- depth = pb.min(pb.div(pb.neg(lightSpacePos.z), ShaderFramework.getLightPositionAndRangeForShadow(scope).w), 1);
85
- }
86
- return shadowMapParams.shadowMap.format === 'rgba8unorm'
87
- ? encodeNormalizedFloatToRGBA(scope, depth)
88
- : pb.vec4(depth, 0, 0, 1);
89
- }
90
- */ }
54
+ computeShadowMapDepth(shadowMapParams, scope, worldPos) {
55
+ return computeShadowMapDepth(scope, worldPos, shadowMapParams.shadowMap.format);
56
+ }
91
57
  computeShadowCSM(shadowMapParams, scope, shadowVertex, NdotL, split) {
92
58
  const funcNameComputeShadowCSM = 'lib_computeShadowCSM';
93
59
  const pb = scope.$builder;
@@ -107,15 +73,15 @@ import { computeShadowMapDepth } from '../shaders/shadow.js';
107
73
  this.shadowCoord.z = pb.sub(this.shadowCoord.z, this.shadowBias);
108
74
  if (that.useNativeShadowMap(shadowMapParams)) {
109
75
  if (shadowMapParams.shadowMap.isTexture2DArray()) {
110
- this.shadow = pb.textureArraySampleCompareLevel(this.shadowMap, this.shadowCoord.xy, this.split, this.shadowCoord.z);
76
+ this.shadow = pb.textureArraySampleCompareLevel(ShaderHelper.getShadowMap(this), this.shadowCoord.xy, this.split, this.shadowCoord.z);
111
77
  } else {
112
- this.shadow = pb.textureSampleCompareLevel(this.shadowMap, this.shadowCoord.xy, this.shadowCoord.z);
78
+ this.shadow = pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.shadowCoord.xy, this.shadowCoord.z);
113
79
  }
114
80
  } else {
115
81
  if (shadowMapParams.shadowMap.isTexture2DArray()) {
116
- this.$l.shadowTex = pb.textureArraySampleLevel(this.shadowMap, this.shadowCoord.xy, this.split, 0);
82
+ this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.shadowCoord.xy, this.split, 0);
117
83
  } else {
118
- this.$l.shadowTex = pb.textureSampleLevel(this.shadowMap, this.shadowCoord.xy, 0);
84
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.shadowCoord.xy, 0);
119
85
  }
120
86
  if (!floatDepthTexture) {
121
87
  this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
@@ -137,17 +103,17 @@ import { computeShadowMapDepth } from '../shaders/shadow.js';
137
103
  ], function() {
138
104
  const floatDepthTexture = shadowMapParams.shadowMap.format !== 'rgba8unorm';
139
105
  if (shadowMapParams.lightType === LIGHT_TYPE_POINT) {
140
- this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderFramework.getLightPositionAndRangeForShadow(this).xyz);
106
+ this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderHelper.getLightPositionAndRangeForShadow(this).xyz);
141
107
  if (that.useNativeShadowMap(shadowMapParams)) {
142
- this.$l.nearFar = ShaderFramework.getShadowCameraParams(this).xy;
108
+ this.$l.nearFar = ShaderHelper.getShadowCameraParams(this).xy;
143
109
  this.$l.maxZ = pb.max(pb.max(pb.abs(this.dir.x), pb.abs(this.dir.y)), pb.abs(this.dir.z));
144
- this.$l.distance = linearDepthToNonLinear(this, this.maxZ, this.nearFar);
145
- this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, pb.div(this.maxZ, ShaderFramework.getLightPositionAndRangeForShadow(this).w), this.NdotL, true);
146
- this.$return(pb.textureSampleCompareLevel(this.shadowMap, this.dir, pb.sub(this.distance, this.shadowBias)));
110
+ this.$l.distance = ShaderHelper.linearDepthToNonLinear(this, this.maxZ, this.nearFar);
111
+ this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, pb.div(this.maxZ, ShaderHelper.getLightPositionAndRangeForShadow(this).w), this.NdotL, true);
112
+ this.$return(pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.dir, pb.sub(this.distance, this.shadowBias)));
147
113
  } else {
148
- this.$l.distance = pb.div(pb.length(this.dir), ShaderFramework.getLightPositionAndRangeForShadow(this).w);
114
+ this.$l.distance = pb.div(pb.length(this.dir), ShaderHelper.getLightPositionAndRangeForShadow(this).w);
149
115
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.distance, this.NdotL, true);
150
- this.$l.shadowTex = pb.textureSampleLevel(this.shadowMap, this.dir, 0);
116
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.dir, 0);
151
117
  if (!floatDepthTexture) {
152
118
  this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
153
119
  }
@@ -163,17 +129,17 @@ import { computeShadowMapDepth } from '../shaders/shadow.js';
163
129
  if (that.useNativeShadowMap(shadowMapParams)) {
164
130
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.shadowCoord.z, this.NdotL, false);
165
131
  this.shadowCoord.z = pb.sub(this.shadowCoord.z, this.shadowBias);
166
- this.shadow = pb.textureSampleCompareLevel(this.shadowMap, this.shadowCoord.xy, this.shadowCoord.z);
132
+ this.shadow = pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.shadowCoord.xy, this.shadowCoord.z);
167
133
  } else {
168
134
  if (shadowMapParams.lightType === LIGHT_TYPE_SPOT) {
169
- this.$l.nearFar = ShaderFramework.getShadowCameraParams(this).xy;
170
- this.shadowCoord.z = nonLinearDepthToLinearNormalized(this, this.shadowCoord.z, this.nearFar);
135
+ this.$l.nearFar = ShaderHelper.getShadowCameraParams(this).xy;
136
+ this.shadowCoord.z = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.shadowCoord.z, this.nearFar);
171
137
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.shadowCoord.z, this.NdotL, true);
172
138
  } else {
173
139
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.shadowCoord.z, this.NdotL, false);
174
140
  }
175
141
  this.shadowCoord.z = pb.sub(this.shadowCoord.z, this.shadowBias);
176
- this.$l.shadowTex = pb.textureSampleLevel(this.shadowMap, this.shadowCoord.xy, 0);
142
+ this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.shadowCoord.xy, 0);
177
143
  if (!floatDepthTexture) {
178
144
  this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
179
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ssm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ssm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,21 +1,23 @@
1
1
  import { ShadowImpl } from './shadow_impl.js';
2
2
  import { Blitter } from '../blitter/blitter.js';
3
- import { ShaderFramework } from '../shaders/framework.js';
4
- import { nonLinearDepthToLinearNormalized, decodeNormalizedFloatFromRGBA, decode2HalfFromRGBA, encode2HalfToRGBA } from '../shaders/misc.js';
3
+ import { decodeNormalizedFloatFromRGBA, decode2HalfFromRGBA, encode2HalfToRGBA } from '../shaders/misc.js';
5
4
  import { Application } from '../app.js';
6
5
  import { computeShadowMapDepth, filterShadowVSM } from '../shaders/shadow.js';
7
6
  import { ShadowMapper } from './shadowmapper.js';
8
7
  import '@zephyr3d/base';
9
8
  import '../scene/octree.js';
10
9
  import { LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } from '../values.js';
11
- import '../material/material.js';
12
- import '@zephyr3d/device';
13
- import '../render/scatteringlut.js';
10
+ import { ShaderHelper } from '../material/shader/helper.js';
14
11
  import '../material/lambert.js';
15
12
  import '../material/blinn.js';
16
13
  import '../material/unlit.js';
17
- import '../material/lightmodel.js';
18
- import '../render/forward.js';
14
+ import '../material/material.js';
15
+ import '../material/meshmaterial.js';
16
+ import '../material/grassmaterial.js';
17
+ import '../material/terrainmaterial.js';
18
+ import '../material/pbrmr.js';
19
+ import '../material/pbrsg.js';
20
+ import '../render/renderer.js';
19
21
  import '../render/sky.js';
20
22
  import '../render/clipmap.js';
21
23
  import { TemporalCache } from '../render/temporalcache.js';
@@ -231,8 +233,8 @@ class VSMBlitter extends Blitter {
231
233
  getShadowMapDepthFormat(shadowMapParams) {
232
234
  return 'd24s8';
233
235
  }
234
- computeShadowMapDepth(shadowMapParams, scope) {
235
- return computeShadowMapDepth(scope, shadowMapParams.shadowMap.format);
236
+ computeShadowMapDepth(shadowMapParams, scope, worldPos) {
237
+ return computeShadowMapDepth(scope, worldPos, shadowMapParams.shadowMap.format);
236
238
  }
237
239
  computeShadowCSM(shadowMapParams, scope, shadowVertex, NdotL, split) {
238
240
  const funcNameComputeShadowCSM = 'lib_computeShadowCSM';
@@ -263,8 +265,8 @@ class VSMBlitter extends Blitter {
263
265
  pb.float('NdotL')
264
266
  ], function() {
265
267
  if (shadowMapParams.lightType === LIGHT_TYPE_POINT) {
266
- this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderFramework.getLightPositionAndRangeForShadow(this).xyz);
267
- this.$l.distance = pb.div(pb.length(this.dir), ShaderFramework.getLightPositionAndRangeForShadow(this).w);
268
+ this.$l.dir = pb.sub(this.shadowVertex.xyz, ShaderHelper.getLightPositionAndRangeForShadow(this).xyz);
269
+ this.$l.distance = pb.div(pb.length(this.dir), ShaderHelper.getLightPositionAndRangeForShadow(this).w);
268
270
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.distance, this.NdotL, true);
269
271
  this.$l.coord = pb.vec4(this.dir, pb.sub(this.distance, this.shadowBias));
270
272
  this.$return(filterShadowVSM(this, shadowMapParams.lightType, shadowMapParams.shadowMap.format, this.coord));
@@ -275,8 +277,8 @@ class VSMBlitter extends Blitter {
275
277
  this.$l.shadow = pb.float(1);
276
278
  this.$if(this.inShadow, function() {
277
279
  if (shadowMapParams.lightType === LIGHT_TYPE_SPOT) {
278
- this.$l.nearFar = ShaderFramework.getShadowCameraParams(this).xy;
279
- this.shadowCoord.z = nonLinearDepthToLinearNormalized(this, this.shadowCoord.z, this.nearFar);
280
+ this.$l.nearFar = ShaderHelper.getShadowCameraParams(this).xy;
281
+ this.shadowCoord.z = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.shadowCoord.z, this.nearFar);
280
282
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.shadowCoord.z, this.NdotL, true);
281
283
  } else {
282
284
  this.$l.shadowBias = ShadowMapper.computeShadowBias(shadowMapParams, this, this.shadowCoord.z, this.NdotL, false);
@@ -1 +1 @@
1
- {"version":3,"file":"vsm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"vsm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -17,9 +17,9 @@ TC(n, m) = (m / M, n / N)
17
17
 
18
18
  VIndex(n, m) = n * (M + 1) + m
19
19
  Triangle(n, m) = (VIndex(n, m), VIndex(n+1, m), VIndex(n+1, m+1), VIndex(n, m), VIndex(n+1, m+1), VIndex(n, m+1))*/ /**
20
- *
20
+ *
21
21
  * Torus shape
22
- *
22
+ *
23
23
  * @public
24
24
  */ class TorusShape extends Shape {
25
25
  /**
@@ -1,9 +1,9 @@
1
1
  import { AABB, Frustum, ClipState } from '@zephyr3d/base';
2
2
  import { AABBTree } from './aabbtree.js';
3
3
 
4
- /**
5
- * The bounding box class
6
- * @public
4
+ /**
5
+ * The bounding box class
6
+ * @public
7
7
  */ class BoundingBox extends AABB {
8
8
  constructor(arg0, arg1){
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -25,9 +25,9 @@ import { AABBTree } from './aabbtree.js';
25
25
  return this;
26
26
  }
27
27
  }
28
- /**
29
- * Bounding box tree
30
- * @public
28
+ /**
29
+ * Bounding box tree
30
+ * @public
31
31
  */ class BoundingBoxTree extends AABBTree {
32
32
  constructor(arg){
33
33
  super(arg);
@@ -54,27 +54,27 @@ import { AABBTree } from './aabbtree.js';
54
54
  /** {@inheritDoc BoundingVolume.toAABB} */ toAABB() {
55
55
  return this.getTopLevelAABB();
56
56
  }
57
- } /*
58
- export class BoundingFrustum implements BoundingVolume {
59
- protected _frustum: Frustum;
60
- constructor ();
61
- constructor (other: BoundingFrustum|Frustum|Matrix4x4);
62
- constructor (arg0?: BoundingFrustum|Frustum|Matrix4x4) {
63
- if (arg0 instanceof BoundingFrustum) {
64
- this._frustum = arg0._frustum ? new Frustum (arg0._frustum) : null;
65
- } else if (arg0 instanceof Frustum) {
66
- this._frustum = new Frustum (arg0);
67
- } else if (arg0 instanceof Matrix4x4) {
68
- this._frustum = new Frustum (arg0);
69
- } else {
70
- this._frustum = null;
71
- }
72
- }
73
- clone (): BoundingVolume {
74
- return new BoundingFrustum (this);
75
- }
76
- transform (matrix: Matrix4x4)
77
- }
57
+ } /*
58
+ export class BoundingFrustum implements BoundingVolume {
59
+ protected _frustum: Frustum;
60
+ constructor ();
61
+ constructor (other: BoundingFrustum|Frustum|Matrix4x4);
62
+ constructor (arg0?: BoundingFrustum|Frustum|Matrix4x4) {
63
+ if (arg0 instanceof BoundingFrustum) {
64
+ this._frustum = arg0._frustum ? new Frustum (arg0._frustum) : null;
65
+ } else if (arg0 instanceof Frustum) {
66
+ this._frustum = new Frustum (arg0);
67
+ } else if (arg0 instanceof Matrix4x4) {
68
+ this._frustum = new Frustum (arg0);
69
+ } else {
70
+ this._frustum = null;
71
+ }
72
+ }
73
+ clone (): BoundingVolume {
74
+ return new BoundingFrustum (this);
75
+ }
76
+ transform (matrix: Matrix4x4)
77
+ }
78
78
  */
79
79
 
80
80
  export { BoundingBox, BoundingBoxTree };
@@ -140,10 +140,10 @@ function createPMREMProgram(type, numSamples) {
140
140
  ], function() {
141
141
  this.$l.n = this.bits;
142
142
  this.n = pb.compOr(pb.sal(this.n, 16), pb.sar(this.n, 16));
143
- this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x55555555), 1), pb.sar(pb.compAnd(this.n, 0xAAAAAAAA), 1));
144
- this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x33333333), 2), pb.sar(pb.compAnd(this.n, 0xCCCCCCCC), 2));
145
- this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x0F0F0F0F), 4), pb.sar(pb.compAnd(this.n, 0xF0F0F0F0), 4));
146
- this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x00FF00FF), 8), pb.sar(pb.compAnd(this.n, 0xFF00FF00), 8));
143
+ this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x55555555), 1), pb.sar(pb.compAnd(this.n, 0xaaaaaaaa), 1));
144
+ this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x33333333), 2), pb.sar(pb.compAnd(this.n, 0xcccccccc), 2));
145
+ this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x0f0f0f0f), 4), pb.sar(pb.compAnd(this.n, 0xf0f0f0f0), 4));
146
+ this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x00ff00ff), 8), pb.sar(pb.compAnd(this.n, 0xff00ff00), 8));
147
147
  this.$return(pb.mul(pb.float(this.n), 2.3283064365386963e-10));
148
148
  });
149
149
  pb.func('hammersley2d', [