@zephyr3d/scene 0.5.0 → 0.6.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.
- package/dist/animation/animationset.js +37 -37
- package/dist/animation/morphtrack.js +7 -5
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +11 -9
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -2
- package/dist/asset/loaders/gltf/gltf_loader.js +7 -3
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/image/webimage_loader.js +16 -0
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
- package/dist/asset/model.js +3 -9
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/bilateralblur.js +222 -0
- package/dist/{render/temporalcache.js.map → blitter/bilateralblur.js.map} +1 -1
- package/dist/blitter/blitter.js +7 -1
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/depthlimitedgaussion.js +96 -39
- package/dist/blitter/depthlimitedgaussion.js.map +1 -1
- package/dist/blitter/gaussianblur.js +21 -21
- package/dist/camera/camera.js +142 -1
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1178 -745
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +9 -3
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +6 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +3 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +73 -33
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +5 -4
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +17 -7
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +13 -4
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +13 -4
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +27 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrmr.js +14 -3
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +14 -3
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +36 -21
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/posteffect/bloom.js +1 -10
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +43 -24
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +3 -11
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -11
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/posteffect.js +4 -0
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +44 -24
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/ssr.js +536 -0
- package/dist/{material/lit.js.map → posteffect/ssr.js.map} +1 -1
- package/dist/posteffect/tonemap.js +3 -11
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/posteffect/water.js +305 -337
- package/dist/posteffect/water.js.map +1 -1
- package/dist/render/abuffer_oit.js +2 -2
- package/dist/render/clipmap.js +16 -19
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cull_visitor.js +5 -3
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +17 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +25 -19
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +4 -2
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +989 -0
- package/dist/{shaders/framework.js.map → render/fft_wavegenerator.js.map} +1 -1
- package/dist/render/gerstner_wavegenerator.js +265 -0
- package/dist/{material/standard.js.map → render/gerstner_wavegenerator.js.map} +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +273 -0
- package/dist/{material/terrainlightmodel.js.map → render/hzb.js.map} +1 -1
- package/dist/render/lightpass.js +35 -3
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +2 -1
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/render_queue.js +72 -52
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderbundle_wrapper.js +79 -0
- package/dist/render/renderbundle_wrapper.js.map +1 -1
- package/dist/render/renderer.js +75 -36
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +16 -13
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +6 -0
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +12 -13
- package/dist/render/sky.js.map +1 -1
- package/dist/render/watermesh.js +94 -828
- package/dist/render/watermesh.js.map +1 -1
- package/dist/render/wavegenerator.js +8 -0
- package/dist/render/wavegenerator.js.map +1 -0
- package/dist/scene/batchgroup.js +60 -14
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +2 -2
- package/dist/scene/graph_node.js +0 -5
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +5 -5
- package/dist/scene/mesh.js +34 -18
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/octree.js +5 -2
- package/dist/scene/octree.js.map +1 -1
- package/dist/scene/raycast_visitor.js +4 -2
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +1 -1
- package/dist/scene/scene_node.js +9 -5
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +3 -4
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/heightfield.js +135 -53
- package/dist/scene/terrain/heightfield.js.map +1 -1
- package/dist/scene/terrain/patch.js +3 -4
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/terrain.js +1 -1
- package/dist/scene/xform.js +7 -9
- package/dist/scene/xform.js.map +1 -1
- package/dist/shaders/misc.js +10 -1
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +81 -16
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/shadow.js +1 -9
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/ssr.js +442 -0
- package/dist/{material/terrainmat.js.map → shaders/ssr.js.map} +1 -1
- package/dist/shaders/water.js +377 -250
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/shadowmapper.js +11 -11
- package/dist/shapes/cylinder.js +6 -5
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/utility/bounding_volume.js +1 -53
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/misc.js +93 -0
- package/dist/utility/misc.js.map +1 -0
- package/dist/utility/shprojection.js +2 -7
- package/dist/utility/shprojection.js.map +1 -1
- package/dist/utility/textures/ggxlut.js +213 -0
- package/dist/utility/textures/ggxlut.js.map +1 -0
- package/dist/utility/textures/gradientnoise.js +61 -0
- package/dist/utility/textures/gradientnoise.js.map +1 -0
- package/dist/utility/textures/randomnoise.js +41 -0
- package/dist/utility/textures/randomnoise.js.map +1 -0
- package/dist/values.js +8 -1
- package/dist/values.js.map +1 -1
- package/package.json +4 -8
- package/dist/animation/usertrack.js +0 -47
- package/dist/animation/usertrack.js.map +0 -1
- package/dist/material/grassmat.js +0 -127
- package/dist/material/grassmat.js.map +0 -1
- package/dist/material/lightmodel.js +0 -2074
- package/dist/material/lightmodel.js.map +0 -1
- package/dist/material/lit.js +0 -578
- package/dist/material/mixins/pbr/metallicroughness.js +0 -126
- package/dist/material/mixins/pbr/metallicroughness.js.map +0 -1
- package/dist/material/mixins/pbr/specularglossness.js +0 -104
- package/dist/material/mixins/pbr/specularglossness.js.map +0 -1
- package/dist/material/pbr.js +0 -27
- package/dist/material/pbr.js.map +0 -1
- package/dist/material/standard.js +0 -282
- package/dist/material/terrainlightmodel.js +0 -259
- package/dist/material/terrainmat.js +0 -357
- package/dist/render/depth_pass.js +0 -47
- package/dist/render/depth_pass.js.map +0 -1
- package/dist/render/forward.js +0 -186
- package/dist/render/forward.js.map +0 -1
- package/dist/render/forward_pass.js +0 -137
- package/dist/render/forward_pass.js.map +0 -1
- package/dist/render/helper.js +0 -38
- package/dist/render/helper.js.map +0 -1
- package/dist/render/objectpool.js +0 -295
- package/dist/render/objectpool.js.map +0 -1
- package/dist/render/renderscheme.js +0 -61
- package/dist/render/renderscheme.js.map +0 -1
- package/dist/render/temporalcache.js +0 -222
- package/dist/scene/model.js +0 -111
- package/dist/scene/model.js.map +0 -1
- package/dist/scene/octree_update_visitor.js +0 -20
- package/dist/scene/octree_update_visitor.js.map +0 -1
- package/dist/shaders/builtins.js +0 -110
- package/dist/shaders/builtins.js.map +0 -1
- package/dist/shaders/framework.js +0 -723
- package/dist/shaders/lighting.js +0 -335
- package/dist/shaders/lighting.js.map +0 -1
- package/dist/utility/sheenlut.js +0 -196
- package/dist/utility/sheenlut.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { weightedAverage } from '@zephyr3d/base';
|
|
2
2
|
import { Application } from '../app.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Animation set
|
|
6
|
-
* @public
|
|
4
|
+
/**
|
|
5
|
+
* Animation set
|
|
6
|
+
* @public
|
|
7
7
|
*/ class AnimationSet {
|
|
8
8
|
/** @internal */ _model;
|
|
9
9
|
/** @internal */ _animations;
|
|
@@ -11,9 +11,9 @@ import { Application } from '../app.js';
|
|
|
11
11
|
/** @internal */ _activeTracks;
|
|
12
12
|
/** @internal */ _activeSkeletons;
|
|
13
13
|
/** @internal */ _activeAnimations;
|
|
14
|
-
/**
|
|
15
|
-
* Creates an instance of AnimationSet
|
|
16
|
-
* @param scene - The scene to which the animation set belongs
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of AnimationSet
|
|
16
|
+
* @param scene - The scene to which the animation set belongs
|
|
17
17
|
*/ constructor(scene, model){
|
|
18
18
|
this._scene = scene;
|
|
19
19
|
this._model = model;
|
|
@@ -23,30 +23,30 @@ import { Application } from '../app.js';
|
|
|
23
23
|
this._activeSkeletons = new Map();
|
|
24
24
|
this._activeAnimations = new Map();
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
* How many animations in this set
|
|
26
|
+
/**
|
|
27
|
+
* How many animations in this set
|
|
28
28
|
*/ get numAnimations() {
|
|
29
29
|
return Object.getOwnPropertyNames(this._animations).length;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Gets an animation clip by name
|
|
33
|
-
* @param name - name of the animation to get
|
|
31
|
+
/**
|
|
32
|
+
* Gets an animation clip by name
|
|
33
|
+
* @param name - name of the animation to get
|
|
34
34
|
*/ get(name) {
|
|
35
35
|
return this._animations[name] ?? null;
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Adds an animation
|
|
37
|
+
/**
|
|
38
|
+
* Adds an animation
|
|
39
39
|
*/ add(animation) {
|
|
40
40
|
this._animations[animation.name] = animation;
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Gets names of all the animations of the model
|
|
44
|
-
* @returns An array of string that contains the animation names
|
|
42
|
+
/**
|
|
43
|
+
* Gets names of all the animations of the model
|
|
44
|
+
* @returns An array of string that contains the animation names
|
|
45
45
|
*/ getAnimationNames() {
|
|
46
46
|
return Object.keys(this._animations);
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Updates all animations of the model
|
|
48
|
+
/**
|
|
49
|
+
* Updates all animations of the model
|
|
50
50
|
*/ update() {
|
|
51
51
|
this._activeAnimations.forEach((v, k)=>{
|
|
52
52
|
if (v.fadeOut > 0 && v.fadeOutStart < 0) {
|
|
@@ -102,26 +102,26 @@ import { Application } from '../app.js';
|
|
|
102
102
|
k.apply();
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Checks whether an animation is playing
|
|
107
|
-
* @param name - Name of the animation to be checked
|
|
108
|
-
* @returns true if the animation is playing, otherwise false
|
|
105
|
+
/**
|
|
106
|
+
* Checks whether an animation is playing
|
|
107
|
+
* @param name - Name of the animation to be checked
|
|
108
|
+
* @returns true if the animation is playing, otherwise false
|
|
109
109
|
*/ isPlayingAnimation(name) {
|
|
110
110
|
return name ? this._activeAnimations.has(this._animations[name]) : this._activeAnimations.size > 0;
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Gets the weight of specific animation which is currently playing
|
|
114
|
-
* @param name - Name of the animation
|
|
115
|
-
* @returns Weight of the animation or 0 if this animation is not playing
|
|
112
|
+
/**
|
|
113
|
+
* Gets the weight of specific animation which is currently playing
|
|
114
|
+
* @param name - Name of the animation
|
|
115
|
+
* @returns Weight of the animation or 0 if this animation is not playing
|
|
116
116
|
*/ getAnimationWeight(name) {
|
|
117
117
|
const ani = this._animations[name];
|
|
118
118
|
const info = this._activeAnimations.get(ani);
|
|
119
119
|
return info?.weight ?? 0;
|
|
120
120
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Sets the weight of specific animation which is currently playing
|
|
123
|
-
* @param name - Name of the animation
|
|
124
|
-
* @param weight - New weight value
|
|
121
|
+
/**
|
|
122
|
+
* Sets the weight of specific animation which is currently playing
|
|
123
|
+
* @param name - Name of the animation
|
|
124
|
+
* @param weight - New weight value
|
|
125
125
|
*/ setAnimationWeight(name, weight) {
|
|
126
126
|
const ani = this._animations[name];
|
|
127
127
|
const info = this._activeAnimations.get(ani);
|
|
@@ -129,10 +129,10 @@ import { Application } from '../app.js';
|
|
|
129
129
|
info.weight = weight;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Starts playing an animation of the model
|
|
134
|
-
* @param name - Name of the animation to play
|
|
135
|
-
* @param options - Playing options
|
|
132
|
+
/**
|
|
133
|
+
* Starts playing an animation of the model
|
|
134
|
+
* @param name - Name of the animation to play
|
|
135
|
+
* @param options - Playing options
|
|
136
136
|
*/ playAnimation(name, options) {
|
|
137
137
|
const ani = this._animations[name];
|
|
138
138
|
if (!ani) {
|
|
@@ -186,9 +186,9 @@ import { Application } from '../app.js';
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Stops playing an animation of the model
|
|
191
|
-
* @param name - Name of the animation to stop playing
|
|
189
|
+
/**
|
|
190
|
+
* Stops playing an animation of the model
|
|
191
|
+
* @param name - Name of the animation to stop playing
|
|
192
192
|
*/ stopAnimation(name, options) {
|
|
193
193
|
const ani = this._animations[name];
|
|
194
194
|
const info = this._activeAnimations.get(ani);
|
|
@@ -4,6 +4,8 @@ import '../utility/panorama.js';
|
|
|
4
4
|
import '../utility/shprojection.js';
|
|
5
5
|
import { Vector3 } from '@zephyr3d/base';
|
|
6
6
|
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
7
|
+
import '../app.js';
|
|
8
|
+
import '@zephyr3d/device';
|
|
7
9
|
import { MAX_MORPH_TARGETS } from '../values.js';
|
|
8
10
|
import { calculateMorphBoundingBox } from './morphtarget.js';
|
|
9
11
|
|
|
@@ -12,6 +14,7 @@ import { calculateMorphBoundingBox } from './morphtarget.js';
|
|
|
12
14
|
* @public
|
|
13
15
|
*/ class MorphTargetTrack extends AnimationTrack {
|
|
14
16
|
_state;
|
|
17
|
+
_originBox;
|
|
15
18
|
_boundingBox;
|
|
16
19
|
_defaultWeights;
|
|
17
20
|
/**
|
|
@@ -24,6 +27,7 @@ import { calculateMorphBoundingBox } from './morphtarget.js';
|
|
|
24
27
|
weights: new Float32Array(MAX_MORPH_TARGETS)
|
|
25
28
|
};
|
|
26
29
|
this._boundingBox = subMesh.targetBox;
|
|
30
|
+
this._originBox = subMesh.mesh.getBoundingVolume().toAABB();
|
|
27
31
|
this._defaultWeights = assetTrack.defaultMorphWeights ?? Array.from({
|
|
28
32
|
length: this._state.numTargets
|
|
29
33
|
}).map(()=>0);
|
|
@@ -35,11 +39,9 @@ import { calculateMorphBoundingBox } from './morphtarget.js';
|
|
|
35
39
|
}
|
|
36
40
|
applyState(node, state) {
|
|
37
41
|
node.getMorphInfo().bufferSubData(4 * 4, state.weights);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
animatedBoundingBox.maxPoint = Vector3.add(originBoundingBox.maxPoint, state.boundingBox.maxPoint);
|
|
42
|
-
node.setAnimatedBoundingBox(animatedBoundingBox);
|
|
42
|
+
state.boundingBox.minPoint.addBy(this._originBox.minPoint);
|
|
43
|
+
state.boundingBox.maxPoint.addBy(this._originBox.maxPoint);
|
|
44
|
+
node.setAnimatedBoundingBox(state.boundingBox);
|
|
43
45
|
}
|
|
44
46
|
mixState(a, b, t) {
|
|
45
47
|
const state = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morphtrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"morphtrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -4,6 +4,7 @@ import '../utility/pmrem.js';
|
|
|
4
4
|
import '../utility/panorama.js';
|
|
5
5
|
import '../utility/shprojection.js';
|
|
6
6
|
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
7
|
+
import '@zephyr3d/device';
|
|
7
8
|
|
|
8
9
|
const tmpV0 = new Vector3();
|
|
9
10
|
const tmpV1 = new Vector3();
|
|
@@ -62,17 +63,21 @@ const tmpV3 = new Vector3();
|
|
|
62
63
|
*/ get jointTexture() {
|
|
63
64
|
return this._jointTexture;
|
|
64
65
|
}
|
|
65
|
-
/** @internal */ updateJointMatrices(jointTransforms) {
|
|
66
|
+
/** @internal */ updateJointMatrices(jointTransforms, worldMatrix) {
|
|
66
67
|
if (!this._jointTexture) {
|
|
67
68
|
this._createJointTexture();
|
|
68
69
|
}
|
|
69
70
|
for(let i = 0; i < this._joints.length; i++){
|
|
70
71
|
const mat = this._jointMatrices[i];
|
|
71
|
-
|
|
72
|
+
const jointTransform = jointTransforms ? jointTransforms[i] : this._joints[i].worldMatrix;
|
|
73
|
+
if (worldMatrix) {
|
|
74
|
+
Matrix4x4.multiplyAffine(worldMatrix, jointTransform, jointTransform);
|
|
75
|
+
}
|
|
76
|
+
Matrix4x4.multiply(jointTransform, this._inverseBindMatrices[i], mat);
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
|
-
/** @internal */ computeBindPose() {
|
|
75
|
-
this.updateJointMatrices(this._bindPoseMatrices);
|
|
79
|
+
/** @internal */ computeBindPose(model) {
|
|
80
|
+
this.updateJointMatrices(this._bindPoseMatrices, model.worldMatrix);
|
|
76
81
|
this._jointTexture.update(this._jointMatrixArray, 0, 0, this._jointTexture.width, this._jointTexture.height);
|
|
77
82
|
}
|
|
78
83
|
/** @internal */ computeJoints() {
|
|
@@ -84,17 +89,14 @@ const tmpV3 = new Vector3();
|
|
|
84
89
|
for (const mesh of this._meshes){
|
|
85
90
|
this.computeBoundingBox(mesh.bounding, mesh.mesh.invWorldMatrix);
|
|
86
91
|
mesh.mesh.setBoneMatrices(this.jointTexture);
|
|
87
|
-
mesh.mesh.setInvBindMatrix(mesh.mesh.invWorldMatrix);
|
|
88
92
|
mesh.mesh.setAnimatedBoundingBox(mesh.bounding.boundingBox);
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
/** @internal */ reset(model) {
|
|
92
|
-
this.computeBindPose();
|
|
96
|
+
this.computeBindPose(model);
|
|
93
97
|
for (const mesh of this._meshes){
|
|
94
|
-
|
|
95
|
-
this.computeBoundingBox(mesh.bounding, invWorldMatrix);
|
|
98
|
+
this.computeBoundingBox(mesh.bounding, mesh.mesh.invWorldMatrix);
|
|
96
99
|
mesh.mesh.setBoneMatrices(this.jointTexture);
|
|
97
|
-
mesh.mesh.setInvBindMatrix(invWorldMatrix);
|
|
98
100
|
mesh.mesh.setAnimatedBoundingBox(mesh.bounding.boundingBox);
|
|
99
101
|
}
|
|
100
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skeleton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -73,8 +73,8 @@ import { processMorphData } from '../animation/morphtarget.js';
|
|
|
73
73
|
*/ purgeCache() {
|
|
74
74
|
for(const k in this._textures){
|
|
75
75
|
this._textures[k].then((tex)=>tex?.dispose()).catch((err)=>{});
|
|
76
|
-
delete this._textures[k];
|
|
77
76
|
}
|
|
77
|
+
this._textures = {};
|
|
78
78
|
this._models = {};
|
|
79
79
|
this._binaryDatas = {};
|
|
80
80
|
this._textDatas = {};
|
|
@@ -417,7 +417,7 @@ import { processMorphData } from '../animation/morphtarget.js';
|
|
|
417
417
|
if (loader) {
|
|
418
418
|
this._builtinTextureLoaders[name] = loader;
|
|
419
419
|
} else {
|
|
420
|
-
|
|
420
|
+
this._builtinTextureLoaders[name] = undefined;
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
/** @internal */ setAssetNodeToSceneNode(scene, parent, model, assetNode, skeletonMeshMap, nodeMap, instancing) {
|
|
@@ -8,12 +8,12 @@ import '../../../material/blinn.js';
|
|
|
8
8
|
import { UnlitMaterial } from '../../../material/unlit.js';
|
|
9
9
|
import '@zephyr3d/device';
|
|
10
10
|
import { MORPH_TARGET_POSITION, MORPH_TARGET_NORMAL, MORPH_TARGET_TANGENT, MORPH_TARGET_TEX0, MORPH_TARGET_TEX1, MORPH_TARGET_TEX2, MORPH_TARGET_TEX3, MORPH_TARGET_COLOR } from '../../../values.js';
|
|
11
|
+
import { Application } from '../../../app.js';
|
|
11
12
|
import '../../../material/meshmaterial.js';
|
|
12
13
|
import '../../../material/grassmaterial.js';
|
|
13
14
|
import '../../../material/terrainmaterial.js';
|
|
14
15
|
import { PBRMetallicRoughnessMaterial } from '../../../material/pbrmr.js';
|
|
15
16
|
import { PBRSpecularGlossinessMaterial } from '../../../material/pbrsg.js';
|
|
16
|
-
import { Application } from '../../../app.js';
|
|
17
17
|
import { GLTFAccessor, ComponentType } from './helpers.js';
|
|
18
18
|
import { AbstractModelLoader } from '../loader.js';
|
|
19
19
|
import { DracoMeshDecoder } from '../../../utility/draco/decoder.js';
|
|
@@ -265,8 +265,12 @@ import { DracoMeshDecoder } from '../../../utility/draco/decoder.js';
|
|
|
265
265
|
if (animationData.nodes.indexOf(targetNode) < 0) {
|
|
266
266
|
animationData.nodes.push(targetNode);
|
|
267
267
|
}
|
|
268
|
-
if (targetNode.skeletonAttached
|
|
269
|
-
|
|
268
|
+
if (targetNode.skeletonAttached) {
|
|
269
|
+
for (const skeleton of targetNode.skeletonAttached){
|
|
270
|
+
if (animationData.skeletons.indexOf(skeleton) < 0) {
|
|
271
|
+
animationData.skeletons.push(skeleton);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
270
274
|
}
|
|
271
275
|
}
|
|
272
276
|
return animationData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf_loader.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gltf_loader.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -37,6 +37,22 @@ import { Application } from '../../../app.js';
|
|
|
37
37
|
} else {
|
|
38
38
|
reject('create texture from image element failed');
|
|
39
39
|
}
|
|
40
|
+
}).catch((reason)=>{
|
|
41
|
+
const cvs = document.createElement('canvas');
|
|
42
|
+
cvs.width = img.width;
|
|
43
|
+
cvs.height = img.height;
|
|
44
|
+
const ctx = cvs.getContext('2d');
|
|
45
|
+
ctx.drawImage(img, 0, 0);
|
|
46
|
+
const options = {
|
|
47
|
+
texture: texture,
|
|
48
|
+
samplerOptions
|
|
49
|
+
};
|
|
50
|
+
const tex = Application.instance.device.createTexture2DFromImage(cvs, srgb, options);
|
|
51
|
+
if (tex) {
|
|
52
|
+
resolve(tex);
|
|
53
|
+
} else {
|
|
54
|
+
reject('create texture from image element failed');
|
|
55
|
+
}
|
|
40
56
|
});
|
|
41
57
|
};
|
|
42
58
|
img.onerror = (err)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webimage_loader.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webimage_loader.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/asset/model.js
CHANGED
|
@@ -23,7 +23,6 @@ import { Vector3, Quaternion, Matrix4x4 } from '@zephyr3d/base';
|
|
|
23
23
|
_mesh;
|
|
24
24
|
_skeleton;
|
|
25
25
|
_attachToSkeleton;
|
|
26
|
-
_attachIndex;
|
|
27
26
|
_meshAttached;
|
|
28
27
|
_matrix;
|
|
29
28
|
_worldMatrix;
|
|
@@ -45,7 +44,6 @@ import { Vector3, Quaternion, Matrix4x4 } from '@zephyr3d/base';
|
|
|
45
44
|
this._skeleton = null;
|
|
46
45
|
this._attachToSkeleton = null;
|
|
47
46
|
this._meshAttached = false;
|
|
48
|
-
this._attachIndex = -1;
|
|
49
47
|
this._matrix = null;
|
|
50
48
|
this._weights = null;
|
|
51
49
|
this._worldMatrix = null;
|
|
@@ -110,9 +108,6 @@ import { Vector3, Quaternion, Matrix4x4 } from '@zephyr3d/base';
|
|
|
110
108
|
/** The skeleton to which the node belongs if this is a joint node */ get skeletonAttached() {
|
|
111
109
|
return this._attachToSkeleton;
|
|
112
110
|
}
|
|
113
|
-
/** The joint index if this is a joint node */ get attachIndex() {
|
|
114
|
-
return this._attachIndex;
|
|
115
|
-
}
|
|
116
111
|
/** @internal */ computeTransforms(parentTransform) {
|
|
117
112
|
this._matrix = Matrix4x4.scaling(this._scaling).rotateLeft(this._rotation).translateLeft(this._position);
|
|
118
113
|
this._worldMatrix = parentTransform ? Matrix4x4.multiply(parentTransform, this._matrix) : new Matrix4x4(this._matrix);
|
|
@@ -149,11 +144,10 @@ import { Vector3, Quaternion, Matrix4x4 } from '@zephyr3d/base';
|
|
|
149
144
|
* @param skeleton - The skeleton to which to node will attach
|
|
150
145
|
* @param index - The joint index
|
|
151
146
|
*/ attachToSkeleton(skeleton, index) {
|
|
152
|
-
if (this._attachToSkeleton
|
|
153
|
-
|
|
147
|
+
if (!this._attachToSkeleton) {
|
|
148
|
+
this._attachToSkeleton = new Set();
|
|
154
149
|
}
|
|
155
|
-
this._attachToSkeleton
|
|
156
|
-
this._attachIndex = index;
|
|
150
|
+
this._attachToSkeleton.add(skeleton);
|
|
157
151
|
}
|
|
158
152
|
/** @internal */ setMeshAttached() {
|
|
159
153
|
this._meshAttached = true;
|
package/dist/asset/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { Blitter } from './blitter.js';
|
|
2
|
+
import { decodeNormalizedFloatFromRGBA } from '../shaders/misc.js';
|
|
3
|
+
import '../app.js';
|
|
4
|
+
import { Vector2 } from '@zephyr3d/base';
|
|
5
|
+
import { fetchSampler } from '../utility/misc.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Bilateral blur blitter
|
|
9
|
+
* @public
|
|
10
|
+
*/ class BilateralBlurBlitter extends Blitter {
|
|
11
|
+
_depthTex;
|
|
12
|
+
_sampler;
|
|
13
|
+
_blurSizeTex;
|
|
14
|
+
_blurSizeScale;
|
|
15
|
+
_blurSizeIndex;
|
|
16
|
+
_kernelRadius;
|
|
17
|
+
_cameraNearFar;
|
|
18
|
+
_depthCutoff;
|
|
19
|
+
_stepSize;
|
|
20
|
+
_uvStep;
|
|
21
|
+
_size;
|
|
22
|
+
_stdDev;
|
|
23
|
+
_offsetsAndWeights;
|
|
24
|
+
_finalPhase;
|
|
25
|
+
constructor(finalPhase){
|
|
26
|
+
super();
|
|
27
|
+
this._depthTex = null;
|
|
28
|
+
this._depthCutoff = 2;
|
|
29
|
+
this._blurSizeTex = null;
|
|
30
|
+
this._blurSizeScale = 1;
|
|
31
|
+
this._blurSizeIndex = 0;
|
|
32
|
+
this._sampler = null;
|
|
33
|
+
this._blurSizeTex = null;
|
|
34
|
+
this._kernelRadius = 8;
|
|
35
|
+
this._cameraNearFar = Vector2.zero();
|
|
36
|
+
this._size = Vector2.zero();
|
|
37
|
+
this._stdDev = 2;
|
|
38
|
+
this._offsetsAndWeights = new Float32Array(4 * (this._kernelRadius + 1));
|
|
39
|
+
this._finalPhase = !!finalPhase;
|
|
40
|
+
this._stepSize = 1;
|
|
41
|
+
this._uvStep = this._finalPhase ? new Vector2(1, 0) : new Vector2(0, 1);
|
|
42
|
+
this.calcGaussion();
|
|
43
|
+
}
|
|
44
|
+
get depthTex() {
|
|
45
|
+
return this._depthTex;
|
|
46
|
+
}
|
|
47
|
+
set depthTex(tex) {
|
|
48
|
+
this._depthTex = tex;
|
|
49
|
+
}
|
|
50
|
+
get blurSizeTex() {
|
|
51
|
+
return this._blurSizeTex;
|
|
52
|
+
}
|
|
53
|
+
set blurSizeTex(tex) {
|
|
54
|
+
this._blurSizeTex = tex;
|
|
55
|
+
}
|
|
56
|
+
get blurSizeIndex() {
|
|
57
|
+
return this._blurSizeIndex;
|
|
58
|
+
}
|
|
59
|
+
set blurSizeIndex(val) {
|
|
60
|
+
this._blurSizeIndex = val;
|
|
61
|
+
}
|
|
62
|
+
get blurSizeScale() {
|
|
63
|
+
return this._blurSizeScale;
|
|
64
|
+
}
|
|
65
|
+
set blurSizeScale(val) {
|
|
66
|
+
this._blurSizeScale = val;
|
|
67
|
+
}
|
|
68
|
+
get sampler() {
|
|
69
|
+
return this._sampler;
|
|
70
|
+
}
|
|
71
|
+
set sampler(sampler) {
|
|
72
|
+
this._sampler = sampler;
|
|
73
|
+
}
|
|
74
|
+
get cameraNearFar() {
|
|
75
|
+
return this._cameraNearFar;
|
|
76
|
+
}
|
|
77
|
+
set cameraNearFar(v) {
|
|
78
|
+
this._cameraNearFar.set(v);
|
|
79
|
+
}
|
|
80
|
+
get depthCutoff() {
|
|
81
|
+
return this._depthCutoff;
|
|
82
|
+
}
|
|
83
|
+
set depthCutoff(val) {
|
|
84
|
+
this._depthCutoff = val;
|
|
85
|
+
}
|
|
86
|
+
get size() {
|
|
87
|
+
return this._size;
|
|
88
|
+
}
|
|
89
|
+
set size(val) {
|
|
90
|
+
this._size.set(val);
|
|
91
|
+
}
|
|
92
|
+
get stepSize() {
|
|
93
|
+
return this._stepSize;
|
|
94
|
+
}
|
|
95
|
+
set stepSize(val) {
|
|
96
|
+
if (val !== this._stepSize) {
|
|
97
|
+
this._stepSize = val;
|
|
98
|
+
this.calcGaussion();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
get stdDev() {
|
|
102
|
+
return this._stdDev;
|
|
103
|
+
}
|
|
104
|
+
set stdDev(val) {
|
|
105
|
+
if (val !== this._stdDev) {
|
|
106
|
+
this._stdDev = val;
|
|
107
|
+
this.calcGaussion();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
get kernelRadius() {
|
|
111
|
+
return this._kernelRadius;
|
|
112
|
+
}
|
|
113
|
+
set kernelRadius(val) {
|
|
114
|
+
val = Math.max(val, 0) >> 0;
|
|
115
|
+
if (val !== this._kernelRadius) {
|
|
116
|
+
this._kernelRadius = val;
|
|
117
|
+
this._offsetsAndWeights = new Float32Array(4 * (this._kernelRadius + 1));
|
|
118
|
+
this.calcGaussion();
|
|
119
|
+
this.invalidateHash();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
calcHash() {
|
|
123
|
+
return `${Number(!!this._blurSizeTex)}:${this._blurSizeIndex}:${this._kernelRadius}:${this._finalPhase}`;
|
|
124
|
+
}
|
|
125
|
+
calcGaussion() {
|
|
126
|
+
const kernel = [];
|
|
127
|
+
const size = this.kernelRadius * 2 + 1;
|
|
128
|
+
let sum = 0;
|
|
129
|
+
for(let x = 0; x < size; x++){
|
|
130
|
+
const value = 1 / (Math.sqrt(2 * Math.PI) * this._stdDev) * Math.exp(-((x - this.kernelRadius) ** 2) / (2 * this._stdDev ** 2));
|
|
131
|
+
kernel.push(value);
|
|
132
|
+
sum += value;
|
|
133
|
+
}
|
|
134
|
+
for(let i = 0; i <= this.kernelRadius; i++){
|
|
135
|
+
this._offsetsAndWeights[i * 4] = this._uvStep.x * i;
|
|
136
|
+
this._offsetsAndWeights[i * 4 + 1] = this._uvStep.y * i;
|
|
137
|
+
this._offsetsAndWeights[i * 4 + 2] = kernel[this.kernelRadius - i] / sum;
|
|
138
|
+
this._offsetsAndWeights[i * 4 + 3] = this._stepSize;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
setup(scope, type) {
|
|
142
|
+
super.setup(scope, type);
|
|
143
|
+
const pb = scope.$builder;
|
|
144
|
+
if (pb.shaderKind === 'fragment') {
|
|
145
|
+
scope.depthTex = pb.tex2D().uniform(0);
|
|
146
|
+
if (this._blurSizeTex) {
|
|
147
|
+
scope.blurSizeTex = pb.tex2D().uniform(0);
|
|
148
|
+
scope.blurSizeScale = pb.float().uniform(0);
|
|
149
|
+
}
|
|
150
|
+
scope.depthCutoff = pb.float().uniform(0);
|
|
151
|
+
scope.offsetsAndWeights = pb.vec4[this._kernelRadius + 1]().uniform(0);
|
|
152
|
+
scope.cameraNearFar = pb.vec2().uniform(0);
|
|
153
|
+
scope.size = pb.vec2().uniform(0);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
setUniforms(bindGroup, sourceTex) {
|
|
157
|
+
super.setUniforms(bindGroup, sourceTex);
|
|
158
|
+
bindGroup.setTexture('depthTex', this._depthTex, this._sampler ?? fetchSampler('clamp_nearest_nomip'));
|
|
159
|
+
if (this._blurSizeTex) {
|
|
160
|
+
bindGroup.setTexture('blurSizeTex', this._blurSizeTex, fetchSampler('clamp_linear_nomip'));
|
|
161
|
+
bindGroup.setValue('blurSizeScale', this._blurSizeScale);
|
|
162
|
+
}
|
|
163
|
+
bindGroup.setValue('depthCutoff', this._depthCutoff);
|
|
164
|
+
bindGroup.setValue('offsetsAndWeights', this._offsetsAndWeights);
|
|
165
|
+
bindGroup.setValue('cameraNearFar', this._cameraNearFar);
|
|
166
|
+
bindGroup.setValue('size', this._size);
|
|
167
|
+
}
|
|
168
|
+
filter(scope, type, srcTex, srcUV, srcLayer, sampleType) {
|
|
169
|
+
const that = this;
|
|
170
|
+
const pb = scope.$builder;
|
|
171
|
+
pb.func('getLinearDepth', [
|
|
172
|
+
pb.vec2('uv')
|
|
173
|
+
], function() {
|
|
174
|
+
this.$l.depthValue = pb.textureSample(this.depthTex, this.uv);
|
|
175
|
+
this.$l.depth01 = pb.getDevice().type === 'webgl' ? decodeNormalizedFloatFromRGBA(this, this.depthValue) : this.depthValue.r;
|
|
176
|
+
this.$return(pb.mul(this.depth01, this.cameraNearFar.y));
|
|
177
|
+
});
|
|
178
|
+
pb.func('getLogDepth', [
|
|
179
|
+
pb.float('linearDepth')
|
|
180
|
+
], function() {
|
|
181
|
+
this.$return(pb.log(pb.add(this.linearDepth, 1)));
|
|
182
|
+
});
|
|
183
|
+
scope.centerDepth = scope.getLogDepth(scope.getLinearDepth(srcUV));
|
|
184
|
+
scope.depthDiff = pb.div(scope.depthCutoff, pb.sub(scope.getLogDepth(scope.cameraNearFar.y), scope.getLogDepth(scope.cameraNearFar.x)));
|
|
185
|
+
scope.weightSum = scope.offsetsAndWeights[0].z;
|
|
186
|
+
scope.srcTexel = that.readTexel(scope, type, srcTex, srcUV, srcLayer, sampleType);
|
|
187
|
+
scope.colorSum = pb.mul(scope.srcTexel, scope.weightSum);
|
|
188
|
+
if (that._blurSizeTex) {
|
|
189
|
+
scope.blurSize = pb.textureSample(scope.blurSizeTex, srcUV)['rgba'[this._blurSizeIndex]];
|
|
190
|
+
}
|
|
191
|
+
scope.$for(pb.int('i'), 0, that._kernelRadius, function() {
|
|
192
|
+
this.$l.offsetAndWeight = this.offsetsAndWeights.at(pb.add(this.i, 1));
|
|
193
|
+
this.$l.weight = this.offsetAndWeight.z;
|
|
194
|
+
this.$l.offset = this.offsetAndWeight.xy;
|
|
195
|
+
if (that._blurSizeTex) {
|
|
196
|
+
this.offset = pb.mul(this.offset, this.blurSize, this.blurSizeScale);
|
|
197
|
+
}
|
|
198
|
+
this.$l.offset = pb.div(this.offset, this.size);
|
|
199
|
+
this.$l.uvRight = pb.add(srcUV, this.offset);
|
|
200
|
+
this.$l.depthRight = this.getLogDepth(this.getLinearDepth(this.uvRight));
|
|
201
|
+
this.$if(pb.lessThan(pb.abs(pb.sub(this.depthRight, this.centerDepth)), this.depthDiff), function() {
|
|
202
|
+
this.$l.srcTexelRight = that.readTexel(this, type, srcTex, this.uvRight, srcLayer, sampleType);
|
|
203
|
+
this.$l.colorWeight = pb.mul(this.weight, pb.exp(pb.neg(pb.distance(this.srcTexelRight.rgb, this.srcTexel.rgb))));
|
|
204
|
+
this.colorSum = pb.add(this.colorSum, pb.mul(this.srcTexelRight, this.colorWeight));
|
|
205
|
+
this.weightSum = pb.add(this.weightSum, this.colorWeight);
|
|
206
|
+
});
|
|
207
|
+
this.$l.uvLeft = pb.sub(srcUV, this.offset);
|
|
208
|
+
this.$l.depthLeft = this.getLogDepth(this.getLinearDepth(this.uvLeft));
|
|
209
|
+
this.$if(pb.lessThan(pb.abs(pb.sub(this.depthLeft, this.centerDepth)), this.depthDiff), function() {
|
|
210
|
+
this.$l.srcTexelLeft = that.readTexel(this, type, srcTex, this.uvLeft, srcLayer, sampleType);
|
|
211
|
+
this.$l.colorWeight = pb.mul(this.weight, pb.exp(pb.neg(pb.distance(this.srcTexelLeft.rgb, this.srcTexel.rgb))));
|
|
212
|
+
this.colorSum = pb.add(this.colorSum, pb.mul(this.srcTexelLeft, this.colorWeight));
|
|
213
|
+
this.weightSum = pb.add(this.weightSum, this.colorWeight);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
scope.colorSum = pb.div(scope.colorSum, scope.weightSum);
|
|
217
|
+
return scope.colorSum;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export { BilateralBlurBlitter };
|
|
222
|
+
//# sourceMappingURL=bilateralblur.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"bilateralblur.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/blitter/blitter.js
CHANGED
|
@@ -90,7 +90,7 @@ import { linearToGamma } from '../shaders/misc.js';
|
|
|
90
90
|
* @returns The read texel
|
|
91
91
|
*/ readTexel(scope, type, srcTex, uv, srcLayer, sampleType) {
|
|
92
92
|
const pb = scope.$builder;
|
|
93
|
-
if (sampleType === 'float') {
|
|
93
|
+
if (sampleType === 'float' || sampleType === 'depth') {
|
|
94
94
|
switch(type){
|
|
95
95
|
case '2d':
|
|
96
96
|
case 'cube':
|
|
@@ -318,6 +318,8 @@ function createBlitProgram(type, filter, bilinearFiltering, st, flip, scaleBias)
|
|
|
318
318
|
this.srcTex = pb.itex2D().sampleType('sint').uniform(0);
|
|
319
319
|
} else if (st === 'uint') {
|
|
320
320
|
this.srcTex = pb.utex2D().sampleType('uint').uniform(0);
|
|
321
|
+
} else if (st === 'depth') {
|
|
322
|
+
this.srcTex = pb.tex2DShadow().uniform(0);
|
|
321
323
|
} else {
|
|
322
324
|
this.srcTex = pb.tex2D().sampleType(bilinearFiltering ? 'float' : 'unfilterable-float').uniform(0);
|
|
323
325
|
}
|
|
@@ -327,6 +329,8 @@ function createBlitProgram(type, filter, bilinearFiltering, st, flip, scaleBias)
|
|
|
327
329
|
this.srcTex = pb.itex2DArray().sampleType('sint').uniform(0);
|
|
328
330
|
} else if (st === 'uint') {
|
|
329
331
|
this.srcTex = pb.utex2DArray().sampleType('uint').uniform(0);
|
|
332
|
+
} else if (st === 'depth') {
|
|
333
|
+
this.srcTex = pb.tex2DArrayShadow().uniform(0);
|
|
330
334
|
} else {
|
|
331
335
|
this.srcTex = pb.tex2DArray().sampleType(bilinearFiltering ? 'float' : 'unfilterable-float').uniform(0);
|
|
332
336
|
}
|
|
@@ -337,6 +341,8 @@ function createBlitProgram(type, filter, bilinearFiltering, st, flip, scaleBias)
|
|
|
337
341
|
this.srcTex = pb.itexCube().sampleType('sint').uniform(0);
|
|
338
342
|
} else if (st === 'uint') {
|
|
339
343
|
this.srcTex = pb.utexCube().sampleType('uint').uniform(0);
|
|
344
|
+
} else if (st === 'depth') {
|
|
345
|
+
this.srcTex = pb.texCubeShadow().uniform(0);
|
|
340
346
|
} else {
|
|
341
347
|
this.srcTex = pb.texCube().sampleType(bilinearFiltering ? 'float' : 'unfilterable-float').uniform(0);
|
|
342
348
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blitter.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blitter.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|