@zephyr3d/scene 0.4.0 → 0.5.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 (116) hide show
  1. package/dist/animation/animation.js +25 -117
  2. package/dist/animation/animation.js.map +1 -1
  3. package/dist/animation/animationset.js +164 -24
  4. package/dist/animation/animationset.js.map +1 -1
  5. package/dist/animation/animationtrack.js +6 -18
  6. package/dist/animation/animationtrack.js.map +1 -1
  7. package/dist/animation/eulerrotationtrack.js +16 -6
  8. package/dist/animation/eulerrotationtrack.js.map +1 -1
  9. package/dist/animation/morphtarget.js +104 -0
  10. package/dist/animation/morphtarget.js.map +1 -0
  11. package/dist/animation/morphtrack.js +68 -0
  12. package/dist/animation/morphtrack.js.map +1 -0
  13. package/dist/animation/rotationtrack.js +15 -7
  14. package/dist/animation/rotationtrack.js.map +1 -1
  15. package/dist/animation/scaletrack.js +15 -7
  16. package/dist/animation/scaletrack.js.map +1 -1
  17. package/dist/animation/skeleton.js +101 -1
  18. package/dist/animation/skeleton.js.map +1 -1
  19. package/dist/animation/translationtrack.js +15 -7
  20. package/dist/animation/translationtrack.js.map +1 -1
  21. package/dist/animation/usertrack.js +2 -2
  22. package/dist/app.js +4 -26
  23. package/dist/app.js.map +1 -1
  24. package/dist/asset/assetmanager.js +58 -107
  25. package/dist/asset/assetmanager.js.map +1 -1
  26. package/dist/asset/loaders/dds/dds.js +77 -3
  27. package/dist/asset/loaders/dds/dds.js.map +1 -1
  28. package/dist/asset/loaders/dds/dds_loader.js +1 -1
  29. package/dist/asset/loaders/gltf/gltf_loader.js +280 -37
  30. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
  31. package/dist/asset/loaders/image/tga_Loader.js +1 -1
  32. package/dist/asset/model.js +13 -0
  33. package/dist/asset/model.js.map +1 -1
  34. package/dist/blitter/blitter.js +2 -2
  35. package/dist/camera/camera.js +58 -3
  36. package/dist/camera/camera.js.map +1 -1
  37. package/dist/index.d.ts +3026 -2839
  38. package/dist/index.js +2 -5
  39. package/dist/index.js.map +1 -1
  40. package/dist/material/blinn.js +9 -4
  41. package/dist/material/blinn.js.map +1 -1
  42. package/dist/material/lambert.js +22 -17
  43. package/dist/material/lambert.js.map +1 -1
  44. package/dist/material/material.js +11 -2
  45. package/dist/material/material.js.map +1 -1
  46. package/dist/material/meshmaterial.js +36 -4
  47. package/dist/material/meshmaterial.js.map +1 -1
  48. package/dist/material/mixins/albedocolor.js +1 -1
  49. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +3 -3
  50. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
  51. package/dist/material/mixins/lit.js +2 -2
  52. package/dist/material/mixins/pbr/common.js +433 -10
  53. package/dist/material/mixins/pbr/common.js.map +1 -1
  54. package/dist/material/pbrmr.js +17 -6
  55. package/dist/material/pbrmr.js.map +1 -1
  56. package/dist/material/pbrsg.js +16 -9
  57. package/dist/material/pbrsg.js.map +1 -1
  58. package/dist/material/shader/helper.js +94 -4
  59. package/dist/material/shader/helper.js.map +1 -1
  60. package/dist/material/unlit.js +8 -4
  61. package/dist/material/unlit.js.map +1 -1
  62. package/dist/posteffect/bloom.js +33 -43
  63. package/dist/posteffect/bloom.js.map +1 -1
  64. package/dist/posteffect/compositor.js +8 -37
  65. package/dist/posteffect/compositor.js.map +1 -1
  66. package/dist/posteffect/sao.js +11 -24
  67. package/dist/posteffect/sao.js.map +1 -1
  68. package/dist/posteffect/water.js +2 -4
  69. package/dist/posteffect/water.js.map +1 -1
  70. package/dist/render/cull_visitor.js +3 -3
  71. package/dist/render/depthpass.js +13 -13
  72. package/dist/render/drawable_mixin.js +48 -6
  73. package/dist/render/drawable_mixin.js.map +1 -1
  74. package/dist/render/envlight.js +165 -31
  75. package/dist/render/envlight.js.map +1 -1
  76. package/dist/render/lightpass.js +35 -27
  77. package/dist/render/lightpass.js.map +1 -1
  78. package/dist/render/objectcolorpass.js +50 -0
  79. package/dist/render/objectcolorpass.js.map +1 -0
  80. package/dist/render/objectpool.js +295 -0
  81. package/dist/render/objectpool.js.map +1 -0
  82. package/dist/render/render_queue.js +189 -156
  83. package/dist/render/render_queue.js.map +1 -1
  84. package/dist/render/renderer.js +97 -20
  85. package/dist/render/renderer.js.map +1 -1
  86. package/dist/render/renderpass.js +18 -14
  87. package/dist/render/renderpass.js.map +1 -1
  88. package/dist/render/shadowmap_pass.js +14 -14
  89. package/dist/render/weightedblended_oit.js +11 -28
  90. package/dist/render/weightedblended_oit.js.map +1 -1
  91. package/dist/scene/environment.js +22 -1
  92. package/dist/scene/environment.js.map +1 -1
  93. package/dist/scene/graph_node.js +0 -9
  94. package/dist/scene/graph_node.js.map +1 -1
  95. package/dist/scene/mesh.js +32 -1
  96. package/dist/scene/mesh.js.map +1 -1
  97. package/dist/scene/scene.js +5 -8
  98. package/dist/scene/scene.js.map +1 -1
  99. package/dist/scene/scene_node.js +2 -3
  100. package/dist/scene/scene_node.js.map +1 -1
  101. package/dist/scene/terrain/grass.js +9 -0
  102. package/dist/scene/terrain/grass.js.map +1 -1
  103. package/dist/scene/terrain/patch.js +9 -0
  104. package/dist/scene/terrain/patch.js.map +1 -1
  105. package/dist/scene/terrain/quadtree.js +2 -2
  106. package/dist/shadow/esm.js +4 -22
  107. package/dist/shadow/esm.js.map +1 -1
  108. package/dist/shadow/shadowmapper.js +45 -20
  109. package/dist/shadow/shadowmapper.js.map +1 -1
  110. package/dist/shadow/vsm.js +4 -24
  111. package/dist/shadow/vsm.js.map +1 -1
  112. package/dist/utility/draco/decoder.js +116 -0
  113. package/dist/utility/draco/decoder.js.map +1 -0
  114. package/dist/values.js +18 -1
  115. package/dist/values.js.map +1 -1
  116. package/package.json +7 -6
@@ -2,6 +2,7 @@ import { applyMaterialMixins, MeshMaterial } from './meshmaterial.js';
2
2
  import { mixinVertexColor } from './mixins/vertexcolor.js';
3
3
  import { mixinPBRSpecularGlossness } from './mixins/lightmodel/pbrspecularglossness.js';
4
4
  import { ShaderHelper } from './shader/helper.js';
5
+ import { RENDER_PASS_TYPE_LIGHT } from '../values.js';
5
6
 
6
7
  /**
7
8
  * PBRSpecularGlossinessMaterial class
@@ -30,9 +31,15 @@ import { ShaderHelper } from './shader/helper.js';
30
31
  vertexShader(scope) {
31
32
  super.vertexShader(scope);
32
33
  const pb = scope.$builder;
34
+ const worldMatrix = ShaderHelper.getWorldMatrix(scope);
33
35
  scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);
34
- scope.$outputs.worldPos = pb.mul(ShaderHelper.getWorldMatrix(scope), pb.vec4(scope.oPos, 1)).xyz;
35
- ShaderHelper.setClipSpacePosition(scope, pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1)));
36
+ scope.$outputs.worldPos = pb.mul(worldMatrix, pb.vec4(scope.oPos, 1)).xyz;
37
+ scope.$l.csPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1));
38
+ ShaderHelper.setClipSpacePosition(scope, scope.csPos);
39
+ if (this.transmission) {
40
+ scope.$outputs.screenUV = pb.add(pb.mul(pb.div(scope.csPos.xy, scope.csPos.w), 0.5), pb.vec2(0.5));
41
+ scope.$outputs.modelScale = pb.vec3(pb.length(worldMatrix[0].xyz), pb.length(worldMatrix[1].xyz), pb.length(worldMatrix[2].xyz));
42
+ }
36
43
  if (this.vertexNormal) {
37
44
  scope.$l.oNorm = ShaderHelper.resolveVertexNormal(scope);
38
45
  scope.$outputs.wNorm = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;
@@ -51,14 +58,14 @@ import { ShaderHelper } from './shader/helper.js';
51
58
  if (this.vertexColor) {
52
59
  scope.albedo = pb.mul(scope.albedo, this.getVertexColor(scope));
53
60
  }
54
- scope.$l.albedo = this.calculateAlbedoColor(scope);
55
- if (this.vertexColor) {
56
- scope.albedo = pb.mul(scope.albedo, this.getVertexColor(scope));
61
+ if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
62
+ scope.$l.normalInfo = this.calculateNormalAndTBN(scope, scope.$inputs.worldPos, scope.$inputs.wNorm, scope.$inputs.wTangent, scope.$inputs.wBinormal);
63
+ scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);
64
+ scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN);
65
+ this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a));
66
+ } else {
67
+ this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.albedo);
57
68
  }
58
- scope.$l.normalInfo = this.calculateNormalAndTBN(scope, scope.$inputs.worldPos, scope.$inputs.wNorm, scope.$inputs.wTangent, scope.$inputs.wBinormal);
59
- scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);
60
- scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN);
61
- this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a));
62
69
  } else {
63
70
  this.outputFragmentColor(scope, scope.$inputs.worldPos, null);
64
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pbrsg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"pbrsg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { Vector3, Vector4 } from '@zephyr3d/base';
2
- import { RENDER_PASS_TYPE_SHADOWMAP, RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_LIGHT, MAX_CLUSTERED_LIGHTS } from '../../values.js';
2
+ import { RENDER_PASS_TYPE_SHADOWMAP, RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_OBJECT_COLOR, RENDER_PASS_TYPE_LIGHT, MAX_CLUSTERED_LIGHTS, MORPH_WEIGHTS_VECTOR_COUNT, MORPH_TARGET_POSITION, MORPH_TARGET_NORMAL, MORPH_TARGET_TANGENT, MORPH_ATTRIBUTE_VECTOR_COUNT } from '../../values.js';
3
3
  import { ScatteringLut } from '../../render/scatteringlut.js';
4
4
  import { linearToGamma } from '../../shaders/misc.js';
5
5
  import '../../app.js';
@@ -16,6 +16,8 @@ const UNIFORM_NAME_INSTANCE_DATA_OFFSET = 'Z_UniformInstanceDataOffset';
16
16
  const UNIFORM_NAME_BONE_MATRICES = 'Z_UniformBoneMatrices';
17
17
  const UNIFORM_NAME_BONE_TEXTURE_SIZE = 'Z_UniformBoneTexSize';
18
18
  const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
19
+ const UNIFORM_NAME_MORPH_DATA = 'Z_UniformMorphData';
20
+ const UNIFORM_NAME_MORPH_INFO = 'Z_UniformMorphInfo';
19
21
  /**
20
22
  * Helper shader functions for the builtin material system
21
23
  * @public
@@ -75,6 +77,12 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
75
77
  static getBoneInvBindMatrixUniformName() {
76
78
  return UNIFORM_NAME_BONE_INV_BIND_MATRIX;
77
79
  }
80
+ static getMorphDataUniformName() {
81
+ return UNIFORM_NAME_MORPH_DATA;
82
+ }
83
+ static getMorphInfoUniformName() {
84
+ return UNIFORM_NAME_MORPH_INFO;
85
+ }
78
86
  static getLightBufferUniformName() {
79
87
  return UNIFORM_NAME_LIGHT_BUFFER;
80
88
  }
@@ -124,7 +132,7 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
124
132
  lightStruct('light')
125
133
  ]);
126
134
  scope[UNIFORM_NAME_GLOBAL] = globalStruct().uniform(0);
127
- } else if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH) {
135
+ } else if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH || ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
128
136
  const globalStruct = pb.defineStruct([
129
137
  cameraStruct('camera')
130
138
  ]);
@@ -191,6 +199,15 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
191
199
  return !!scope[UNIFORM_NAME_BONE_MATRICES];
192
200
  }
193
201
  /**
202
+ * This function checks if the shader needs to process morph target animation.
203
+ *
204
+ * @param scope - Current shader scope
205
+ *
206
+ * @returns true if the shader needs to process morph target animation, otherwise false.
207
+ */ static hasMorphing(scope) {
208
+ return !!scope[UNIFORM_NAME_MORPH_DATA];
209
+ }
210
+ /**
194
211
  * Calculate skinning matrix for current vertex
195
212
  *
196
213
  * @param scope - Current shader scope
@@ -235,6 +252,66 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
235
252
  });
236
253
  return scope.$g[funcNameGetSkinningMatrix]();
237
254
  }
255
+ static calculateMorphDelta(scope, attrib) {
256
+ const pb = scope.$builder;
257
+ const isWebGL1 = pb.getDevice().type === 'webgl';
258
+ if (pb.shaderKind !== 'vertex') {
259
+ throw new Error(`ShaderHelper.calculateMorphDelta(): must be called at vertex stage`);
260
+ }
261
+ const funcName = 'Z_calculateMorph';
262
+ const that = this;
263
+ pb.func(funcName, [
264
+ pb.int('offset')
265
+ ], function() {
266
+ this.$if(pb.lessThan(this.offset, 0), function() {
267
+ this.$return(pb.vec4(0));
268
+ });
269
+ this.$l.vertexIndex = isWebGL1 ? pb.int(scope.$inputs.zFakeVertexID) : pb.int(scope.$builtins.vertexIndex);
270
+ const morphInfo = scope[that.getMorphInfoUniformName()];
271
+ this.$l.metaData = pb.ivec4(morphInfo[0]);
272
+ this.$l.texWidth = pb.float(this.metaData.x);
273
+ this.$l.texHeight = pb.float(this.metaData.y);
274
+ this.$l.numVertices = this.metaData.z;
275
+ this.$l.numTargets = this.metaData.w;
276
+ this.$l.value = pb.vec4(0);
277
+ if (isWebGL1) {
278
+ this.$for(pb.int('i'), 0, MORPH_WEIGHTS_VECTOR_COUNT, function() {
279
+ this.$for(pb.int('j'), 0, 4, function() {
280
+ this.$l.index = pb.add(pb.mul(this.i, 4), this.j);
281
+ this.$if(pb.greaterThanEqual(this.index, this.numTargets), function() {
282
+ this.$return(this.value);
283
+ });
284
+ this.$l.weight = morphInfo.at(pb.add(1, this.i)).at(this.j);
285
+ this.$l.pixelIndex = pb.float(pb.add(this.offset, pb.mul(this.index, this.numVertices), this.vertexIndex));
286
+ this.$l.xIndex = pb.mod(this.pixelIndex, this.texWidth);
287
+ this.$l.yIndex = pb.floor(pb.div(this.pixelIndex, this.texWidth));
288
+ this.$l.u = pb.div(pb.add(this.xIndex, 0.5), this.texWidth);
289
+ this.$l.v = pb.div(pb.add(this.yIndex, 0.5), this.texHeight);
290
+ this.$l.morphValue = pb.textureSampleLevel(this[that.getMorphDataUniformName()], pb.vec2(this.u, this.v), 0);
291
+ this.value = pb.add(this.value, pb.mul(this.morphValue, this.weight));
292
+ });
293
+ });
294
+ } else {
295
+ this.$for(pb.int('t'), 0, this.numTargets, function() {
296
+ this.$l.i = pb.sar(this.t, 2);
297
+ this.$l.j = pb.compAnd(this.t, 3);
298
+ this.$l.weight = morphInfo.at(pb.add(1, this.i)).at(this.j);
299
+ this.$l.pixelIndex = pb.float(pb.add(this.offset, pb.mul(this.t, this.numVertices), this.vertexIndex));
300
+ this.$l.xIndex = pb.mod(this.pixelIndex, this.texWidth);
301
+ this.$l.yIndex = pb.floor(pb.div(this.pixelIndex, this.texWidth));
302
+ this.$l.u = pb.div(pb.add(this.xIndex, 0.5), this.texWidth);
303
+ this.$l.v = pb.div(pb.add(this.yIndex, 0.5), this.texHeight);
304
+ this.$l.morphValue = pb.textureSampleLevel(this[that.getMorphDataUniformName()], pb.vec2(this.u, this.v), 0);
305
+ this.value = pb.add(this.value, pb.mul(this.morphValue, this.weight));
306
+ });
307
+ }
308
+ this.$return(this.value);
309
+ });
310
+ const pos = 1 + MORPH_WEIGHTS_VECTOR_COUNT + (attrib >> 2);
311
+ const comp = attrib & 3;
312
+ const offset = scope[this.getMorphInfoUniformName()][pos][comp];
313
+ return scope[funcName](pb.int(offset));
314
+ }
238
315
  /**
239
316
  * Calculates the vertex position of type vec3 in object space
240
317
  *
@@ -257,6 +334,9 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
257
334
  }
258
335
  pos = scope.$getVertexAttrib('position');
259
336
  }
337
+ if (this.hasMorphing(scope)) {
338
+ pos = pb.add(pos, this.calculateMorphDelta(scope, MORPH_TARGET_POSITION).xyz);
339
+ }
260
340
  if (this.hasSkinning(scope)) {
261
341
  if (!funcScope[this.SKIN_MATRIX_NAME]) {
262
342
  funcScope[this.SKIN_MATRIX_NAME] = this.calculateSkinMatrix(funcScope);
@@ -288,6 +368,9 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
288
368
  }
289
369
  normal = scope.$getVertexAttrib('normal');
290
370
  }
371
+ if (this.hasMorphing(scope)) {
372
+ normal = pb.normalize(pb.add(normal, this.calculateMorphDelta(scope, MORPH_TARGET_NORMAL).xyz));
373
+ }
291
374
  if (this.hasSkinning(scope)) {
292
375
  if (!funcScope[this.SKIN_MATRIX_NAME]) {
293
376
  funcScope[this.SKIN_MATRIX_NAME] = this.calculateSkinMatrix(funcScope);
@@ -319,6 +402,9 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
319
402
  }
320
403
  tangent = scope.$getVertexAttrib('tangent');
321
404
  }
405
+ if (this.hasMorphing(scope)) {
406
+ tangent = pb.normalize(pb.add(tangent, pb.vec4(this.calculateMorphDelta(scope, MORPH_TARGET_TANGENT).xyz, 0)));
407
+ }
322
408
  if (this.hasSkinning(scope)) {
323
409
  if (!funcScope[this.SKIN_MATRIX_NAME]) {
324
410
  funcScope[this.SKIN_MATRIX_NAME] = this.calculateSkinMatrix(funcScope);
@@ -358,7 +444,7 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
358
444
  * @param scope - Current shader scope
359
445
  * @param skinning - true if skinning is used, otherwise false.
360
446
  * @param instanced - true if instancing is used, otherwise false.
361
- */ static vertexShaderDrawableStuff(scope, skinning, instanced) {
447
+ */ static vertexShaderDrawableStuff(scope, skinning, morphing, instanced) {
362
448
  const pb = scope.$builder;
363
449
  if (instanced) {
364
450
  scope[UNIFORM_NAME_INSTANCE_DATA_STRIDE] = pb.uint().uniform(1);
@@ -372,9 +458,13 @@ const UNIFORM_NAME_BONE_INV_BIND_MATRIX = 'Z_UniformBoneInvBindMatrix';
372
458
  scope[UNIFORM_NAME_BONE_INV_BIND_MATRIX] = pb.mat4().uniform(1);
373
459
  scope[UNIFORM_NAME_BONE_TEXTURE_SIZE] = pb.int().uniform(1);
374
460
  }
461
+ if (morphing) {
462
+ scope[UNIFORM_NAME_MORPH_DATA] = pb.tex2D().uniform(1).sampleType('unfilterable-float');
463
+ scope[UNIFORM_NAME_MORPH_INFO] = pb.vec4[1 + MORPH_WEIGHTS_VECTOR_COUNT + MORPH_ATTRIBUTE_VECTOR_COUNT]().uniformBuffer(1);
464
+ }
375
465
  }
376
466
  /** @internal */ static prepareVertexShaderCommon(pb, ctx) {
377
- this.vertexShaderDrawableStuff(pb.getGlobalScope(), !!ctx.skinAnimation, !!ctx.instancing);
467
+ this.vertexShaderDrawableStuff(pb.getGlobalScope(), !!ctx.skinAnimation, !!ctx.morphAnimation, !!ctx.instancing);
378
468
  /*
379
469
  const skinning = !!ctx.target?.getBoneMatrices();
380
470
  const scope = pb.getGlobalScope();
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"helper.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -20,11 +20,15 @@ import { ShaderHelper } from './shader/helper.js';
20
20
  }
21
21
  fragmentShader(scope) {
22
22
  super.fragmentShader(scope);
23
- let color = this.calculateAlbedoColor(scope);
24
- if (this.vertexColor) {
25
- color = scope.$builder.mul(color, this.getVertexColor(scope));
23
+ if (this.needFragmentColor()) {
24
+ let color = this.calculateAlbedoColor(scope);
25
+ if (this.vertexColor) {
26
+ color = scope.$builder.mul(color, this.getVertexColor(scope));
27
+ }
28
+ this.outputFragmentColor(scope, scope.$inputs.worldPos, color);
29
+ } else {
30
+ this.outputFragmentColor(scope, scope.$inputs.worldPos, null);
26
31
  }
27
- this.outputFragmentColor(scope, scope.$inputs.worldPos, this.needFragmentColor() ? color : null);
28
32
  }
29
33
  }
30
34
 
@@ -1 +1 @@
1
- {"version":3,"file":"unlit.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"unlit.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,22 +1,5 @@
1
1
  import { AbstractPostEffect } from './posteffect.js';
2
2
  import { Vector4, Vector2 } from '@zephyr3d/base';
3
- import '../scene/octree.js';
4
- import '../app.js';
5
- import '@zephyr3d/device';
6
- import '../material/shader/helper.js';
7
- import '../material/lambert.js';
8
- import '../material/blinn.js';
9
- import '../material/unlit.js';
10
- import '../material/meshmaterial.js';
11
- import '../material/grassmaterial.js';
12
- import '../material/terrainmaterial.js';
13
- import '../material/pbrmr.js';
14
- import '../material/pbrsg.js';
15
- import '../render/renderer.js';
16
- import '../render/sky.js';
17
- import '../render/clipmap.js';
18
- import { TemporalCache } from '../render/temporalcache.js';
19
- import '../render/watermesh.js';
20
3
 
21
4
  /**
22
5
  * The bloom post effect
@@ -97,29 +80,31 @@ import '../render/watermesh.js';
97
80
  }
98
81
  /** {@inheritDoc AbstractPostEffect.apply} */ apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
99
82
  const device = ctx.device;
100
- const downsampleFramebuffers = [];
83
+ const downsampleTextures = [];
101
84
  this._prepare(device, inputColorTexture);
102
85
  device.pushDeviceStates();
103
86
  const w = Math.max(inputColorTexture.width >> 1, 1);
104
87
  const h = Math.max(inputColorTexture.height >> 1, 1);
105
- const prefilterFramebuffer = TemporalCache.getFramebufferFixedSize(w, h, 1, inputColorTexture.format, null, '2d', null, false);
106
- this.prefilter(device, inputColorTexture, prefilterFramebuffer);
107
- this.downsample(device, prefilterFramebuffer.getColorAttachments()[0], downsampleFramebuffers);
108
- this.upsample(device, downsampleFramebuffers);
88
+ const colorTex = device.pool.fetchTemporalTexture2D(false, inputColorTexture.format, w, h, false);
89
+ this.prefilter(device, inputColorTexture, colorTex);
90
+ this.downsample(device, colorTex, downsampleTextures);
91
+ this.upsample(device, downsampleTextures);
109
92
  device.popDeviceStates();
110
- this.finalCompose(device, inputColorTexture, downsampleFramebuffers[0].getColorAttachments()[0]);
111
- for (const fb of downsampleFramebuffers){
112
- TemporalCache.releaseFramebuffer(fb);
93
+ this.finalCompose(device, inputColorTexture, downsampleTextures[0]);
94
+ for (const tex of downsampleTextures){
95
+ device.pool.releaseTexture(tex);
113
96
  }
114
- TemporalCache.releaseFramebuffer(prefilterFramebuffer);
97
+ device.pool.releaseTexture(colorTex);
115
98
  }
116
- /** @internal */ prefilter(device, srcTexture, fb) {
99
+ /** @internal */ prefilter(device, srcTexture, rt) {
117
100
  this._thresholdValue.x = this._threshold * this._threshold;
118
101
  this._thresholdValue.y = this._thresholdValue.x * this._thresholdKnee;
119
102
  this._thresholdValue.z = 2 * this._thresholdValue.y;
120
103
  this._thresholdValue.w = 0.25 / (this._thresholdValue.y + 0.00001);
121
104
  this._thresholdValue.y -= this._thresholdValue.x;
122
- device.setFramebuffer(fb);
105
+ device.setFramebuffer([
106
+ rt
107
+ ]);
123
108
  device.setProgram(Bloom._programPrefilter);
124
109
  device.setBindGroup(0, this._bindgroupPrefilter);
125
110
  this._bindgroupPrefilter.setTexture('tex', srcTexture);
@@ -136,17 +121,19 @@ import '../render/watermesh.js';
136
121
  this._bindgroupFinalCompose.setValue('flip', device.type === 'webgpu' && device.getFramebuffer() ? 1 : 0);
137
122
  this.drawFullscreenQuad();
138
123
  }
139
- /** @internal */ upsample(device, framebuffers) {
124
+ /** @internal */ upsample(device, textures) {
140
125
  device.setProgram(Bloom._programUpsample);
141
126
  device.setBindGroup(0, this._bindgroupUpsample);
142
127
  this._bindgroupUpsample.setValue('flip', device.type === 'webgpu' ? 1 : 0);
143
- for(let i = framebuffers.length - 2; i >= 0; i--){
144
- this._bindgroupUpsample.setTexture('tex', framebuffers[i + 1].getColorAttachments()[0]);
145
- device.setFramebuffer(framebuffers[i]);
128
+ for(let i = textures.length - 2; i >= 0; i--){
129
+ this._bindgroupUpsample.setTexture('tex', textures[i + 1]);
130
+ device.setFramebuffer([
131
+ textures[i]
132
+ ]);
146
133
  this.drawFullscreenQuad(Bloom._renderStateAdditive);
147
134
  }
148
135
  }
149
- /** @internal */ downsample(device, inputColorTexture, framebuffers) {
136
+ /** @internal */ downsample(device, inputColorTexture, textures) {
150
137
  const t = Math.max(2, this._downsampleLimit);
151
138
  let w = Math.max(t, inputColorTexture.width >> 1);
152
139
  let h = Math.max(t, inputColorTexture.height >> 1);
@@ -155,31 +142,34 @@ import '../render/watermesh.js';
155
142
  this._bindgroupDownsampleH.setValue('flip', device.type === 'webgpu' ? 1 : 0);
156
143
  this._bindgroupDownsampleV.setValue('flip', device.type === 'webgpu' ? 1 : 0);
157
144
  while((w >= t || h >= t) && maxLevels > 0){
158
- const fb = TemporalCache.getFramebufferFixedSize(w, h, 1, inputColorTexture.format, null, '2d', '2d', false);
159
- const fbMiddle = TemporalCache.getFramebufferFixedSize(w, h, 1, inputColorTexture.format, null, '2d', '2d', false);
160
- framebuffers.push(fb);
145
+ const tex = device.pool.fetchTemporalTexture2D(false, inputColorTexture.format, w, h, false);
146
+ textures.push(tex);
147
+ const texMiddle = device.pool.fetchTemporalTexture2D(false, inputColorTexture.format, w, h, false);
161
148
  // horizonal blur
162
149
  this._invTexSize.setXY(1 / sourceTex.width, 1 / sourceTex.height);
163
- device.setFramebuffer(fbMiddle);
150
+ device.setFramebuffer([
151
+ texMiddle
152
+ ]);
164
153
  device.setProgram(Bloom._programDownsampleH);
165
154
  device.setBindGroup(0, this._bindgroupDownsampleH);
166
155
  this._bindgroupDownsampleH.setTexture('tex', sourceTex);
167
156
  this._bindgroupDownsampleH.setValue('invTexSize', this._invTexSize);
168
157
  this.drawFullscreenQuad();
169
158
  // vertical blur
170
- const midTex = fbMiddle.getColorAttachments()[0];
171
- this._invTexSize.setXY(1 / midTex.width, 1 / midTex.height);
172
- device.setFramebuffer(fb);
159
+ this._invTexSize.setXY(1 / texMiddle.width, 1 / texMiddle.height);
160
+ device.setFramebuffer([
161
+ tex
162
+ ]);
173
163
  device.setProgram(Bloom._programDownsampleV);
174
164
  device.setBindGroup(0, this._bindgroupDownsampleV);
175
- this._bindgroupDownsampleV.setTexture('tex', midTex);
165
+ this._bindgroupDownsampleV.setTexture('tex', texMiddle);
176
166
  this._bindgroupDownsampleV.setValue('invTexSize', this._invTexSize);
177
167
  this.drawFullscreenQuad();
178
168
  maxLevels--;
179
169
  w = Math.max(1, w >> 1);
180
170
  h = Math.max(1, h >> 1);
181
- sourceTex = fb.getColorAttachments()[0];
182
- TemporalCache.releaseFramebuffer(fbMiddle);
171
+ sourceTex = tex;
172
+ device.pool.releaseTexture(texMiddle);
183
173
  }
184
174
  }
185
175
  /** @internal */ _prepare(device, srcTexture) {
@@ -1 +1 @@
1
- {"version":3,"file":"bloom.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"bloom.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,22 +1,4 @@
1
1
  import { linearToGamma } from '../shaders/misc.js';
2
- import '@zephyr3d/base';
3
- import '../scene/octree.js';
4
- import '../app.js';
5
- import '@zephyr3d/device';
6
- import '../material/shader/helper.js';
7
- import '../material/lambert.js';
8
- import '../material/blinn.js';
9
- import '../material/unlit.js';
10
- import '../material/meshmaterial.js';
11
- import '../material/grassmaterial.js';
12
- import '../material/terrainmaterial.js';
13
- import '../material/pbrmr.js';
14
- import '../material/pbrsg.js';
15
- import '../render/renderer.js';
16
- import '../render/sky.js';
17
- import '../render/clipmap.js';
18
- import { TemporalCache } from '../render/temporalcache.js';
19
- import '../render/watermesh.js';
20
2
 
21
3
  /**
22
4
  * Post processing compositor
@@ -98,22 +80,16 @@ import '../render/watermesh.js';
98
80
  const format = device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';
99
81
  const finalFramebuffer = device.getFramebuffer();
100
82
  const depth = finalFramebuffer?.getDepthAttachment();
101
- let pingpongFramebuffers;
102
83
  let msFramebuffer = null;
84
+ const w = depth ? depth.width : ctx.viewportWidth;
85
+ const h = depth ? depth.height : ctx.viewportHeight;
103
86
  if (ctx.primaryCamera.sampleCount > 1) {
104
- msFramebuffer = depth ? TemporalCache.getFramebufferVariantSizeWithDepth(depth, 1, format, '2d', false, ctx.primaryCamera.sampleCount) : TemporalCache.getFramebufferVariantSize(ctx.viewportWidth, ctx.viewportHeight, 1, format, ctx.depthFormat, '2d', '2d', false, ctx.primaryCamera.sampleCount);
105
- }
106
- if (ctx.defaultViewport) {
107
- pingpongFramebuffers = [
108
- depth ? TemporalCache.getFramebufferVariantSizeWithDepth(depth, 1, format, '2d', false, 1) : TemporalCache.getFramebufferVariantSize(ctx.viewportWidth, ctx.viewportHeight, 1, format, ctx.depthFormat, '2d', '2d', false, 1),
109
- depth ? TemporalCache.getFramebufferVariantSizeWithDepth(depth, 1, format, '2d', false, 1) : TemporalCache.getFramebufferVariantSize(ctx.viewportWidth, ctx.viewportHeight, 1, format, ctx.depthFormat, '2d', '2d', false, 1)
110
- ];
111
- } else {
112
- pingpongFramebuffers = [
113
- depth ? TemporalCache.getFramebufferFixedSizeWithDepth(depth, 1, format, '2d', false, 4) : TemporalCache.getFramebufferFixedSize(ctx.viewportWidth, ctx.viewportHeight, 1, format, ctx.depthFormat, '2d', '2d', false, 4),
114
- depth ? TemporalCache.getFramebufferFixedSizeWithDepth(depth, 1, format, '2d', false, 4) : TemporalCache.getFramebufferFixedSize(ctx.viewportWidth, ctx.viewportHeight, 1, format, ctx.depthFormat, '2d', '2d', false, 4)
115
- ];
87
+ msFramebuffer = device.pool.fetchTemporalFramebuffer(true, w, h, format, depth, false, ctx.primaryCamera.sampleCount);
116
88
  }
89
+ const pingpongFramebuffers = [
90
+ device.pool.fetchTemporalFramebuffer(true, w, h, format, depth ?? ctx.depthFormat, false),
91
+ device.pool.fetchTemporalFramebuffer(true, w, h, format, depth ?? ctx.depthFormat, false)
92
+ ];
117
93
  let writeIndex;
118
94
  if (msFramebuffer) {
119
95
  writeIndex = 3;
@@ -127,7 +103,7 @@ import '../render/watermesh.js';
127
103
  ctx.compositorContex = {
128
104
  finalFramebuffer,
129
105
  pingpongFramebuffers,
130
- msFramebuffer,
106
+ msTexture: msFramebuffer,
131
107
  writeIndex
132
108
  };
133
109
  }
@@ -166,11 +142,6 @@ import '../render/watermesh.js';
166
142
  device.setScissor(null);
167
143
  Compositor._blit(device, srcTex, !ctx.compositorContex.finalFramebuffer);
168
144
  }
169
- TemporalCache.releaseFramebuffer(ctx.compositorContex.pingpongFramebuffers[0]);
170
- TemporalCache.releaseFramebuffer(ctx.compositorContex.pingpongFramebuffers[1]);
171
- if (ctx.compositorContex.msFramebuffer) {
172
- TemporalCache.releaseFramebuffer(ctx.compositorContex.msFramebuffer);
173
- }
174
145
  ctx.compositorContex = null;
175
146
  }
176
147
  /** @internal */ isLastPostEffect(opaque, index) {
@@ -1 +1 @@
1
- {"version":3,"file":"compositor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"compositor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,21 +5,6 @@ import { Vector2, Vector4, Matrix4x4 } from '@zephyr3d/base';
5
5
  import { AOBilateralBlurBlitter } from '../blitter/depthlimitedgaussion.js';
6
6
  import '../app.js';
7
7
  import { CopyBlitter } from '../blitter/copy.js';
8
- import '../scene/octree.js';
9
- import '../material/shader/helper.js';
10
- import '../material/lambert.js';
11
- import '../material/blinn.js';
12
- import '../material/unlit.js';
13
- import '../material/meshmaterial.js';
14
- import '../material/grassmaterial.js';
15
- import '../material/terrainmaterial.js';
16
- import '../material/pbrmr.js';
17
- import '../material/pbrsg.js';
18
- import '../render/renderer.js';
19
- import '../render/sky.js';
20
- import '../render/clipmap.js';
21
- import { TemporalCache } from '../render/temporalcache.js';
22
- import '../render/watermesh.js';
23
8
 
24
9
  const NUM_SAMPLES = 7;
25
10
  const NUM_RINGS = 4;
@@ -55,7 +40,7 @@ const NUM_RINGS = 4;
55
40
  this._opaque = true;
56
41
  this._saoScale = 10;
57
42
  this._saoBias = 1;
58
- this._saoIntensity = 0.05;
43
+ this._saoIntensity = 0.025;
59
44
  this._saoRadius = 100;
60
45
  this._saoMinResolution = 0;
61
46
  this._saoRandomSeed = 0;
@@ -136,12 +121,14 @@ const NUM_RINGS = 4;
136
121
  }
137
122
  const fmt = this._getIntermediateTextureFormat(device);
138
123
  const depth = device.getFramebuffer().getDepthAttachment();
139
- const fbao = ctx.defaultViewport ? TemporalCache.getFramebufferVariantSizeWithDepth(depth, 1, fmt, '2d', false) : TemporalCache.getFramebufferFixedSizeWithDepth(depth, 1, fmt, '2d', false);
140
- const fbblur = ctx.defaultViewport ? TemporalCache.getFramebufferVariantSizeWithDepth(depth, 1, fmt, '2d', false) : TemporalCache.getFramebufferFixedSizeWithDepth(depth, 1, fmt, '2d', false);
141
- const packed = fbao.getColorAttachments()[0].format === 'rgba8unorm';
124
+ const fbao = device.pool.fetchTemporalTexture2D(false, fmt, depth.width, depth.height, false);
125
+ const fbblur = device.pool.fetchTemporalTexture2D(false, fmt, depth.width, depth.height, false);
126
+ const packed = fbao.format === 'rgba8unorm';
142
127
  const cameraNearFar = new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane());
143
128
  device.pushDeviceStates();
144
- device.setFramebuffer(fbao);
129
+ device.setFramebuffer([
130
+ fbao
131
+ ], depth);
145
132
  device.clearFrameBuffer(packed ? new Vector4(0, 0, 0, 1) : new Vector4(1, 0, 0, 1), null, null);
146
133
  const bindgroup = packed ? this._bindgroupPacked : this._bindgroup;
147
134
  bindgroup.setValue('flip', this.needFlip(device) ? 1 : 0);
@@ -174,11 +161,11 @@ const NUM_RINGS = 4;
174
161
  this._blitterV.packed = packed;
175
162
  this._blitterV.srgbOut = srgbOutput;
176
163
  this._blitterV.renderStates = SAO._renderStateBlend;
177
- this._blitterH.blit(fbao.getColorAttachments()[0], fbblur);
164
+ this._blitterH.blit(fbao, fbblur);
178
165
  device.popDeviceStates();
179
- this._blitterV.blit(fbblur.getColorAttachments()[0], device.getFramebuffer());
180
- TemporalCache.releaseFramebuffer(fbao);
181
- TemporalCache.releaseFramebuffer(fbblur);
166
+ this._blitterV.blit(fbblur, device.getFramebuffer());
167
+ device.pool.releaseTexture(fbao);
168
+ device.pool.releaseTexture(fbblur);
182
169
  }
183
170
  _getIntermediateTextureFormat(device) {
184
171
  const texCaps = device.getDeviceCaps().textureCaps;
@@ -1 +1 @@
1
- {"version":3,"file":"sao.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"sao.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -14,7 +14,6 @@ import '../material/pbrsg.js';
14
14
  import '../render/renderer.js';
15
15
  import '../render/sky.js';
16
16
  import '../render/clipmap.js';
17
- import { TemporalCache } from '../render/temporalcache.js';
18
17
  import { WaterMesh } from '../render/watermesh.js';
19
18
  import { AbstractPostEffect } from './posteffect.js';
20
19
  import { decodeNormalizedFloatFromRGBA, linearToGamma } from '../shaders/misc.js';
@@ -324,7 +323,7 @@ import { fresnelSchlick, distributionGGX, visGGX } from '../shaders/pbr.js';
324
323
  return;
325
324
  }
326
325
  this._renderingReflections = true;
327
- const fbRefl = TemporalCache.getFramebufferFixedSize(this._reflectSize, this._reflectSize, 1, inputColorTexture.format, ctx.depthFormat, '2d', '2d', false);
326
+ const fbRefl = ctx.device.pool.fetchTemporalFramebuffer(true, this._reflectSize, this._reflectSize, inputColorTexture.format, ctx.depthFormat, false);
328
327
  const plane = new Plane(0, -1, 0, this._elevation);
329
328
  const clipPlane = new Plane(0, -1, 0, this._elevation - this._antiReflectanceLeak);
330
329
  const matReflectionR = Matrix4x4.invert(Matrix4x4.reflection(-plane.a, -plane.b, -plane.c, -plane.d));
@@ -381,7 +380,6 @@ import { fresnelSchlick, distributionGGX, visGGX } from '../shaders/pbr.js';
381
380
  ctx.env.light.envLight.updateBindGroup(waterMesh.bindGroup);
382
381
  }
383
382
  waterMesh.render(ctx.camera, this.needFlip(device));
384
- TemporalCache.releaseFramebuffer(fbRefl);
385
383
  }
386
384
  /** @internal */ _getRampTexture(device) {
387
385
  if (!this._rampTex) {
@@ -397,7 +395,7 @@ import { fresnelSchlick, distributionGGX, visGGX } from '../shaders/pbr.js';
397
395
  const tmpcolor = new Vector3();
398
396
  for(let i = 0; i < numTexels; i++){
399
397
  const grad = i >= numTexels / 2 ? this._scatterGrad : this._absorptionGrad;
400
- grad.interpolate(i % width / width, 1, tmpcolor);
398
+ grad.interpolate(i % width / width, tmpcolor);
401
399
  data[i * 4 + 0] = tmpcolor.x * 255 >> 0;
402
400
  data[i * 4 + 1] = tmpcolor.y * 255 >> 0;
403
401
  data[i * 4 + 2] = tmpcolor.z * 255 >> 0;
@@ -1 +1 @@
1
- {"version":3,"file":"water.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"water.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -51,8 +51,8 @@ import { RENDER_PASS_TYPE_SHADOWMAP } from '../values.js';
51
51
  /** Frustum for culling */ get frustum() {
52
52
  return this._camera?.frustum || null;
53
53
  }
54
- /** @internal */ push(camera, drawable, renderOrder) {
55
- this.renderQueue.push(camera, drawable, renderOrder);
54
+ /** @internal */ push(camera, drawable) {
55
+ this.renderQueue.push(camera, drawable);
56
56
  }
57
57
  /** @internal */ pushRenderQueue(renderQueue) {
58
58
  this.renderQueue.pushRenderQueue(renderQueue);
@@ -104,7 +104,7 @@ import { RENDER_PASS_TYPE_SHADOWMAP } from '../values.js';
104
104
  if (!node.hidden && (node.castShadow || this._renderPass.type !== RENDER_PASS_TYPE_SHADOWMAP)) {
105
105
  const clipState = this.getClipStateWithNode(node);
106
106
  if (clipState !== ClipState.NOT_CLIPPED) {
107
- this.push(this._camera, node, node.renderOrder);
107
+ this.push(this._camera, node);
108
108
  return true;
109
109
  }
110
110
  }