@zephyr3d/scene 0.9.26 → 0.9.27
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.
- package/dist/animation/animationset.js +92 -30
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/animation/skeleton.js +21 -1
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/asset/model.js +6 -2
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +75 -23
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +4764 -3600
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/material/hairstrand.js +235 -235
- package/dist/material/hairstrand.js.map +1 -1
- package/dist/material/material.js +296 -296
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lit.js +33 -1
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/shader/helper.js +404 -3
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/water.js +2057 -72
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/motionblur.js +663 -58
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js +12 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +46 -44
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/sss.js +30 -2
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/render/abuffer_oit.js +37 -37
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +156 -5
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cull_visitor.js +1 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +49 -49
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +3 -3
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +57 -15
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +127 -20
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/hzb.js +80 -22
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +6 -3
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/oit.js +11 -11
- package/dist/render/oit.js.map +1 -1
- package/dist/render/render_queue.js +36 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +4 -0
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +1 -0
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +318 -9
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
- package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +8 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/underwater.js +624 -0
- package/dist/render/underwater.js.map +1 -0
- package/dist/render/water_caustics.js +1380 -0
- package/dist/render/water_caustics.js.map +1 -0
- package/dist/render/weightedblended_oit.js +33 -33
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/water.js +540 -4
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/water.js +22 -19
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +56 -0
- package/dist/shaders/water_medium.js.map +1 -0
- package/dist/shadow/shadow_region.js +49 -49
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/utility/serialization/manager.js +3 -1
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +31 -2
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +53 -25
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +1101 -21
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/shprojector.js +87 -87
- package/dist/utility/shprojector.js.map +1 -1
- package/package.json +1 -1
- package/dist/render/rendergraph/frame_graph_context.js +0 -41
- package/dist/render/rendergraph/frame_graph_context.js.map +0 -1
- package/dist/shaders/ssgi.js +0 -63
- package/dist/shaders/ssgi.js.map +0 -1
- package/dist/shaders/ssgi_reprojection.js +0 -118
- package/dist/shaders/ssgi_reprojection.js.map +0 -1
|
@@ -14,7 +14,11 @@ function getDefaultBuildParams() {
|
|
|
14
14
|
strength: 0.4,
|
|
15
15
|
croppiness: -1.5,
|
|
16
16
|
minWave: 0,
|
|
17
|
-
|
|
17
|
+
// The whole patch. Capping this at 100 discarded every wavelength
|
|
18
|
+
// between 100 and 400 m, which is exactly where the Phillips peak
|
|
19
|
+
// moves once |wind| passes ~10 m/s - the wind then had nothing left
|
|
20
|
+
// to put energy into and the swell stopped growing.
|
|
21
|
+
maxWave: 400
|
|
18
22
|
},
|
|
19
23
|
{
|
|
20
24
|
size: 100.0,
|
|
@@ -360,14 +364,19 @@ const THREAD_GROUP_SIZE = 16;
|
|
|
360
364
|
}
|
|
361
365
|
/** @internal */ getNoiseTexture(size, randomSeed) {
|
|
362
366
|
const device = getDevice();
|
|
363
|
-
|
|
367
|
+
// Keyed on the seed as well as the size. Keying on size alone let the first
|
|
368
|
+
// generator of a given resolution decide the noise for every later one,
|
|
369
|
+
// silently discarding their seeds - two differently seeded oceans came out
|
|
370
|
+
// identical, and which seed won depended on creation order.
|
|
371
|
+
const key = `${size}:${randomSeed}`;
|
|
372
|
+
let tex = FFTWaveGenerator._globals.noiseTextures.get(key);
|
|
364
373
|
if (!tex) {
|
|
365
374
|
tex = device.createTexture2D(device.type === 'webgl' ? 'rgba32f' : 'rg32f', size, size, {
|
|
366
375
|
mipmapping: false
|
|
367
376
|
});
|
|
368
|
-
tex.name = `noiseTex${size}`;
|
|
377
|
+
tex.name = `noiseTex${size}_${randomSeed}`;
|
|
369
378
|
tex.update(this.getNoise2d(size, randomSeed, device.type === 'webgl'), 0, 0, size, size);
|
|
370
|
-
FFTWaveGenerator._globals.noiseTextures.set(
|
|
379
|
+
FFTWaveGenerator._globals.noiseTextures.set(key, tex);
|
|
371
380
|
}
|
|
372
381
|
return tex;
|
|
373
382
|
}
|
|
@@ -789,7 +798,6 @@ const THREAD_GROUP_SIZE = 16;
|
|
|
789
798
|
const nearestRepeatSampler = fetchSampler('repeat_nearest_nomip');
|
|
790
799
|
device.setProgram(FFTWaveGenerator._globals.programs.postfft2Program);
|
|
791
800
|
device.setBindGroup(0, this._postfft2BindGroup);
|
|
792
|
-
this._postfft2BindGroup.setValue('N2', this._params.resolution * this._params.resolution);
|
|
793
801
|
if (this._useComputeShader) {
|
|
794
802
|
this._postfft2BindGroup.setTexture('output', instanceData.dataTextures);
|
|
795
803
|
this._postfft2BindGroup.setTexture('ifft', this._ifftTextures, nearestRepeatSampler);
|
|
@@ -817,7 +825,6 @@ const THREAD_GROUP_SIZE = 16;
|
|
|
817
825
|
device.setProgram(FFTWaveGenerator._globals.programs.postfft2Program4);
|
|
818
826
|
device.setBindGroup(0, this._postfft2BindGroup4);
|
|
819
827
|
const ifftTextures = this._ifftTextures;
|
|
820
|
-
this._postfft2BindGroup4.setValue('N2', this._params.resolution * this._params.resolution);
|
|
821
828
|
this._postfft2BindGroup4.setTexture('ifft0', ifftTextures[0], nearestRepeatSampler);
|
|
822
829
|
this._postfft2BindGroup4.setTexture('ifft1', ifftTextures[1], nearestRepeatSampler);
|
|
823
830
|
this._postfft2BindGroup4.setTexture('ifft2', ifftTextures[2], nearestRepeatSampler);
|
|
@@ -829,7 +836,6 @@ const THREAD_GROUP_SIZE = 16;
|
|
|
829
836
|
device.setFramebuffer(instanceData.postIfft2Framebuffer2);
|
|
830
837
|
device.setProgram(FFTWaveGenerator._globals.programs.postfft2Program2);
|
|
831
838
|
device.setBindGroup(0, this._postfft2BindGroup2);
|
|
832
|
-
this._postfft2BindGroup2.setValue('N2', this._params.resolution * this._params.resolution);
|
|
833
839
|
this._postfft2BindGroup2.setTexture('ifft4', ifftTextures[4], nearestRepeatSampler);
|
|
834
840
|
this._postfft2BindGroup2.setTexture('ifft5', ifftTextures[5], nearestRepeatSampler);
|
|
835
841
|
if (device.type === 'webgl') {
|
|
@@ -851,9 +857,7 @@ const THREAD_GROUP_SIZE = 16;
|
|
|
851
857
|
scope.dx_hy_dz_dxdz2 = pb.tex2D().uniform(uniformGroup);
|
|
852
858
|
scope.sx_sz_dxdx_dzdz2 = pb.tex2D().uniform(uniformGroup);
|
|
853
859
|
}
|
|
854
|
-
|
|
855
|
-
scope.foamParams = pb.vec2().uniform(uniformGroup);
|
|
856
|
-
}
|
|
860
|
+
scope.foamParams = pb.vec2().uniform(uniformGroup);
|
|
857
861
|
}
|
|
858
862
|
/** {@inheritDoc WaveGenerator.calcVertexPositionAndNormal} */ calcVertexPositionAndNormal(scope, inPos, outPos, outNormal) {
|
|
859
863
|
const pb = scope.$builder;
|
|
@@ -903,8 +907,40 @@ const THREAD_GROUP_SIZE = 16;
|
|
|
903
907
|
this.$l.sx = pb.add(this._sx_sz_dxdx_dzdz0.x, this._sx_sz_dxdx_dzdz1.x, this._sx_sz_dxdx_dzdz2.x);
|
|
904
908
|
this.$l.sz = pb.add(this._sx_sz_dxdx_dzdz0.y, this._sx_sz_dxdx_dzdz1.y, this._sx_sz_dxdx_dzdz2.y);
|
|
905
909
|
this.$l.dxdx_dzdz = pb.add(pb.mul(this._sx_sz_dxdx_dzdz0.zw, this.croppinesses.x), pb.mul(this._sx_sz_dxdx_dzdz1.zw, this.croppinesses.y), pb.mul(this._sx_sz_dxdx_dzdz2.zw, this.croppinesses.z));
|
|
906
|
-
|
|
907
|
-
|
|
910
|
+
// The normal of the displaced surface. Writing the Jacobian of the
|
|
911
|
+
// horizontal displacement as [[A, C], [C, F]] with A = 1 + croppiness*d2x,
|
|
912
|
+
// F = 1 + croppiness*d2z, C = croppiness*dxdz and determinant
|
|
913
|
+
// J = A*F - C*C, the cross product of the two tangents is
|
|
914
|
+
//
|
|
915
|
+
// N ~ ( -sx * F, J, -sz * A )
|
|
916
|
+
//
|
|
917
|
+
// The determinant never reaches the horizontal components: dividing the
|
|
918
|
+
// whole vector by A*F recovers the per-axis slope correction -sx/A, -sz/F,
|
|
919
|
+
// which is what this used to do, plus the J/(A*F) = 1 - C^2/(A*F) term on
|
|
920
|
+
// the y axis that the earlier form dropped. Putting J on the horizontal
|
|
921
|
+
// components instead (a form this briefly had) multiplies the whole normal
|
|
922
|
+
// by sign(J), so they jump as J crosses zero - a hard seam, not a fold.
|
|
923
|
+
//
|
|
924
|
+
// The y component takes the magnitude. J goes negative where the choppy
|
|
925
|
+
// displacement folds the sheet over on itself - the same condition the
|
|
926
|
+
// foam mask reads - and the cross-product normal there points down, into
|
|
927
|
+
// the water. That is geometrically true of the overturned sheet and
|
|
928
|
+
// geometrically useless to a renderer that lights the surface from above:
|
|
929
|
+
// a downward normal loses the sun, samples the sky's lower hemisphere for
|
|
930
|
+
// the irradiance and drives the view-facing term negative, which between
|
|
931
|
+
// them painted the fold black. The shading treats the water interface as
|
|
932
|
+
// upward-facing wherever it is, and the foam owns the folded band.
|
|
933
|
+
let dxdzSamples;
|
|
934
|
+
if (that._useComputeShader) {
|
|
935
|
+
dxdzSamples = pb.vec3(pb.textureArraySampleLevel(this.dataTexture, this.uv0, 0, 0).w, pb.textureArraySampleLevel(this.dataTexture, this.uv1, 2, 0).w, pb.textureArraySampleLevel(this.dataTexture, this.uv2, 4, 0).w);
|
|
936
|
+
} else {
|
|
937
|
+
dxdzSamples = pb.vec3(pb.textureSampleLevel(this.dx_hy_dz_dxdz0, this.uv0, 0).w, pb.textureSampleLevel(this.dx_hy_dz_dxdz1, this.uv1, 0).w, pb.textureSampleLevel(this.dx_hy_dz_dxdz2, this.uv2, 0).w);
|
|
938
|
+
}
|
|
939
|
+
this.$l.dxdz = pb.add(pb.mul(dxdzSamples.x, this.croppinesses.x), pb.mul(dxdzSamples.y, this.croppinesses.y), pb.mul(dxdzSamples.z, this.croppinesses.z));
|
|
940
|
+
this.$l.jA = pb.add(1.0, this.dxdx_dzdz.x);
|
|
941
|
+
this.$l.jF = pb.add(1.0, this.dxdx_dzdz.y);
|
|
942
|
+
this.$l.jdet = pb.sub(pb.mul(this.jA, this.jF), pb.mul(this.dxdz, this.dxdz));
|
|
943
|
+
this.$l.normal = pb.normalize(pb.vec3(pb.neg(pb.mul(this.sx, this.jF)), pb.abs(this.jdet), pb.neg(pb.mul(this.sz, this.jA))));
|
|
908
944
|
this.$return(this.normal);
|
|
909
945
|
});
|
|
910
946
|
return scope.calcFragmentNormal(xz);
|
|
@@ -945,8 +981,6 @@ const THREAD_GROUP_SIZE = 16;
|
|
|
945
981
|
this.$l.sx = pb.add(this._sx_sz_dxdx_dzdz0.x, this._sx_sz_dxdx_dzdz1.x, this._sx_sz_dxdx_dzdz2.x);
|
|
946
982
|
this.$l.sz = pb.add(this._sx_sz_dxdx_dzdz0.y, this._sx_sz_dxdx_dzdz1.y, this._sx_sz_dxdx_dzdz2.y);
|
|
947
983
|
this.$l.dxdx_dzdz = pb.add(pb.mul(this._sx_sz_dxdx_dzdz0.zw, this.croppinesses.x), pb.mul(this._sx_sz_dxdx_dzdz1.zw, this.croppinesses.y), pb.mul(this._sx_sz_dxdx_dzdz2.zw, this.croppinesses.z));
|
|
948
|
-
this.$l.slope = pb.vec2(pb.div(this.sx, pb.add(1.0, this.dxdx_dzdz.x)), pb.div(this.sz, pb.add(1.0, this.dxdx_dzdz.y)));
|
|
949
|
-
this.$l.normal = pb.normalize(pb.vec3(pb.neg(this.slope.x), 1.0, pb.neg(this.slope.y)));
|
|
950
984
|
// foam
|
|
951
985
|
this.$l.dxdx_dzdz0 = this._sx_sz_dxdx_dzdz0.zw;
|
|
952
986
|
this.$l.dxdx_dzdz1 = this._sx_sz_dxdx_dzdz1.zw;
|
|
@@ -961,7 +995,15 @@ const THREAD_GROUP_SIZE = 16;
|
|
|
961
995
|
this.$l.dxdz2 = pb.textureSampleLevel(this.dx_hy_dz_dxdz2, this.uv2, 0).w;
|
|
962
996
|
}
|
|
963
997
|
this.$l.dxdz = pb.add(pb.mul(this.dxdz0, this.croppinesses.x), pb.mul(this.dxdz1, this.croppinesses.y), pb.mul(this.dxdz2, this.croppinesses.z));
|
|
964
|
-
this.$l.
|
|
998
|
+
this.$l.jacobian4 = this.jacobian(this.dxdx_dzdz.x, this.dxdz, this.dxdx_dzdz.y);
|
|
999
|
+
this.$l.val = this.det(this.jacobian4);
|
|
1000
|
+
// The normal of the displaced surface, from the same Jacobian the foam
|
|
1001
|
+
// reads: N ~ (-sx*F, J, -sz*A), with A and F the diagonals the helper
|
|
1002
|
+
// packs into x and w. Sharing the determinant keeps the shading normal and
|
|
1003
|
+
// the foam mask describing the same fold, and taking its magnitude keeps
|
|
1004
|
+
// the normal upward-facing there - see calcFragmentNormal for why the sign
|
|
1005
|
+
// cannot be used and why the horizontals take A and F rather than J.
|
|
1006
|
+
this.$l.normal = pb.normalize(pb.vec3(pb.neg(pb.mul(this.sx, this.jacobian4.w)), pb.abs(this.val), pb.neg(pb.mul(this.sz, this.jacobian4.x))));
|
|
965
1007
|
this.$l.foam = pb.abs(pb.pow(pb.neg(pb.min(0, pb.sub(this.val, this.foamParams.x))), this.foamParams.y));
|
|
966
1008
|
this.$return(pb.vec4(this.normal, this.foam));
|
|
967
1009
|
});
|