@kitware/vtk.js 24.5.2 → 24.5.5
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/Common/DataModel/DataSetAttributes/FieldData.d.ts +3 -1
- package/Rendering/Core/RenderWindowInteractor.d.ts +123 -109
- package/Rendering/Core/ScalarBarActor.js +2 -2
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +5 -1
- package/Rendering/OpenGL/RenderWindow.d.ts +1 -1
- package/Rendering/OpenGL/VolumeMapper.js +1 -1
- package/Rendering/SceneGraph/ViewNode.js +28 -2
- package/Rendering/WebGPU/BufferManager.js +83 -14
- package/Rendering/WebGPU/CellArrayMapper.js +591 -0
- package/Rendering/WebGPU/Device.js +97 -57
- package/Rendering/WebGPU/FullScreenQuad.js +4 -6
- package/Rendering/WebGPU/Glyph3DMapper.js +62 -27
- package/Rendering/WebGPU/ImageMapper.js +23 -64
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +4 -6
- package/Rendering/WebGPU/Pipeline.js +12 -0
- package/Rendering/WebGPU/PolyDataMapper.js +49 -623
- package/Rendering/WebGPU/RenderEncoder.js +34 -0
- package/Rendering/WebGPU/Renderer.js +4 -62
- package/Rendering/WebGPU/ShaderDescription.js +6 -6
- package/Rendering/WebGPU/{MapperHelper.js → SimpleMapper.js} +64 -38
- package/Rendering/WebGPU/SphereMapper.js +66 -64
- package/Rendering/WebGPU/StickMapper.js +73 -72
- package/Rendering/WebGPU/StorageBuffer.js +2 -3
- package/Rendering/WebGPU/Texture.js +0 -2
- package/Rendering/WebGPU/TextureManager.js +37 -7
- package/Rendering/WebGPU/UniformBuffer.js +1 -2
- package/Rendering/WebGPU/Volume.js +1 -14
- package/Rendering/WebGPU/VolumePass.js +16 -22
- package/Rendering/WebGPU/VolumePassFSQ.js +19 -29
- package/package.json +1 -1
|
@@ -1,8 +1,83 @@
|
|
|
1
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
2
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
3
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
4
|
+
import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
|
|
5
|
+
import _inherits from '@babel/runtime/helpers/inherits';
|
|
6
|
+
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
|
|
7
|
+
import _get from '@babel/runtime/helpers/get';
|
|
8
|
+
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
|
|
9
|
+
import _wrapNativeSuper from '@babel/runtime/helpers/wrapNativeSuper';
|
|
1
10
|
import { newInstance as newInstance$1, obj, setGet, get } from '../../macros.js';
|
|
2
11
|
import vtkWebGPUBufferManager from './BufferManager.js';
|
|
3
12
|
import vtkWebGPUShaderCache from './ShaderCache.js';
|
|
4
13
|
import vtkWebGPUTextureManager from './TextureManager.js';
|
|
5
14
|
|
|
15
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
+
|
|
17
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
+
/**
|
|
19
|
+
* provide a simple WeakRefMap class to share device objects based on
|
|
20
|
+
* hash values so that buffers/textures etc can be shared betwen mappers.
|
|
21
|
+
* This is roughly based on WeakLRUCache but without the actual caching
|
|
22
|
+
* behavior. This is just a map of key -> WeakRef(value)
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/* eslint-disable no-undef */
|
|
26
|
+
|
|
27
|
+
var WeakRefMap = /*#__PURE__*/function (_Map) {
|
|
28
|
+
_inherits(WeakRefMap, _Map);
|
|
29
|
+
|
|
30
|
+
var _super = _createSuper(WeakRefMap);
|
|
31
|
+
|
|
32
|
+
function WeakRefMap() {
|
|
33
|
+
var _thisSuper, _thisSuper2, _this;
|
|
34
|
+
|
|
35
|
+
_classCallCheck(this, WeakRefMap);
|
|
36
|
+
|
|
37
|
+
_this = _super.call(this);
|
|
38
|
+
_this.registry = new FinalizationRegistry(function (key) {
|
|
39
|
+
var entry = _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(WeakRefMap.prototype)), "get", _thisSuper).call(_thisSuper, key);
|
|
40
|
+
|
|
41
|
+
if (entry && entry.deref && entry.deref() === undefined) _get((_thisSuper2 = _assertThisInitialized(_this), _getPrototypeOf(WeakRefMap.prototype)), "delete", _thisSuper2).call(_thisSuper2, key);
|
|
42
|
+
});
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_createClass(WeakRefMap, [{
|
|
47
|
+
key: "getValue",
|
|
48
|
+
value: function getValue(key) {
|
|
49
|
+
var entry = _get(_getPrototypeOf(WeakRefMap.prototype), "get", this).call(this, key);
|
|
50
|
+
|
|
51
|
+
if (entry) {
|
|
52
|
+
var value = entry.deref();
|
|
53
|
+
if (value !== undefined) return value;
|
|
54
|
+
|
|
55
|
+
_get(_getPrototypeOf(WeakRefMap.prototype), "delete", this).call(this, key);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "setValue",
|
|
62
|
+
value: function setValue(key, value) {
|
|
63
|
+
var entry;
|
|
64
|
+
|
|
65
|
+
if (value && _typeof(value) === 'object') {
|
|
66
|
+
entry = new WeakRef(value);
|
|
67
|
+
this.registry.register(value, key);
|
|
68
|
+
|
|
69
|
+
_get(_getPrototypeOf(WeakRefMap.prototype), "set", this).call(this, key, entry);
|
|
70
|
+
} // else entry is undefined
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
return entry;
|
|
74
|
+
}
|
|
75
|
+
}]);
|
|
76
|
+
|
|
77
|
+
return WeakRefMap;
|
|
78
|
+
}( /*#__PURE__*/_wrapNativeSuper(Map));
|
|
79
|
+
/* eslint-enable no-undef */
|
|
80
|
+
// ----------------------------------------------------------------------------
|
|
6
81
|
// vtkWebGPUDevice methods
|
|
7
82
|
// ----------------------------------------------------------------------------
|
|
8
83
|
|
|
@@ -92,72 +167,34 @@ function vtkWebGPUDevice(publicAPI, model) {
|
|
|
92
167
|
}; // The Device has an object cache that can be used to cache buffers,
|
|
93
168
|
// textures and other objects that can be shared. The basic approach is to
|
|
94
169
|
// call getCachedObject with a request and a create function. The request
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
// returns any entry that has a matching owner and hash. If a match isn't
|
|
99
|
-
// found then the create function is called with any extra arguments.
|
|
100
|
-
//
|
|
101
|
-
// For best memory management it is important that the owner be as close
|
|
102
|
-
// to the underlying object as possible. For example for a point data buffer
|
|
103
|
-
// you would want the actual vtkDataArray to be the owner, not the polydata
|
|
104
|
-
// or even worse the actor. As the points data array could be freed wihtout
|
|
105
|
-
// the polydata or actor being freed.
|
|
170
|
+
// is based on a hash. The cache lookup just returns any entry that has a
|
|
171
|
+
// matching hash. If a match isn't found then the create function is
|
|
172
|
+
// called with any extra arguments.
|
|
106
173
|
// is the object already cached?
|
|
107
174
|
|
|
108
175
|
|
|
109
|
-
publicAPI.hasCachedObject = function (
|
|
110
|
-
|
|
111
|
-
return false;
|
|
112
|
-
} // if a matching request already exists then return true
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (model.objectCache.has(owner)) {
|
|
116
|
-
var objects = model.objectCache.get(owner);
|
|
117
|
-
|
|
118
|
-
for (var i = 0; i < objects.length; i++) {
|
|
119
|
-
if (hash === objects[i].hash) {
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return false;
|
|
176
|
+
publicAPI.hasCachedObject = function (hash) {
|
|
177
|
+
return model.objectCache.getValue(hash);
|
|
126
178
|
};
|
|
127
179
|
|
|
128
|
-
publicAPI.getCachedObject = function (
|
|
129
|
-
if (!
|
|
130
|
-
vtkErrorMacro('attempt to cache an object without
|
|
180
|
+
publicAPI.getCachedObject = function (hash, creator) {
|
|
181
|
+
if (!hash) {
|
|
182
|
+
vtkErrorMacro('attempt to cache an object without a hash');
|
|
131
183
|
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (model.objectCache.has(owner)) {
|
|
136
|
-
var _objects = model.objectCache.get(owner);
|
|
137
|
-
|
|
138
|
-
for (var i = 0; i < _objects.length; i++) {
|
|
139
|
-
if (hash === _objects[i].hash) {
|
|
140
|
-
return _objects[i].object;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
} // otherwise create the object and cache it
|
|
184
|
+
}
|
|
144
185
|
|
|
186
|
+
var existingValue = model.objectCache.getValue(hash);
|
|
145
187
|
|
|
146
|
-
|
|
147
|
-
|
|
188
|
+
if (existingValue) {
|
|
189
|
+
return existingValue;
|
|
148
190
|
}
|
|
149
191
|
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
if (!model.objectCache.has(owner)) {
|
|
153
|
-
model.objectCache.set(owner, []);
|
|
192
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
193
|
+
args[_key - 2] = arguments[_key];
|
|
154
194
|
}
|
|
155
195
|
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
hash: hash,
|
|
159
|
-
object: createdObject
|
|
160
|
-
});
|
|
196
|
+
var createdObject = creator.apply(void 0, args);
|
|
197
|
+
model.objectCache.setValue(hash, createdObject);
|
|
161
198
|
return createdObject;
|
|
162
199
|
};
|
|
163
200
|
} // ----------------------------------------------------------------------------
|
|
@@ -180,9 +217,12 @@ function extend(publicAPI, model) {
|
|
|
180
217
|
|
|
181
218
|
obj(publicAPI, model);
|
|
182
219
|
setGet(publicAPI, model, ['handle']);
|
|
183
|
-
get(publicAPI, model, ['bufferManager', 'shaderCache', 'textureManager']); // this is a
|
|
220
|
+
get(publicAPI, model, ['bufferManager', 'shaderCache', 'textureManager']); // this is a weak ref cache implementation, we create it without
|
|
221
|
+
// an expirer (so it is strictly based on garbage collection and
|
|
222
|
+
// objects are not held if there are no external references)
|
|
223
|
+
// model.objectCache = new WeakLRUCache({ expirer: false });
|
|
184
224
|
|
|
185
|
-
model.objectCache = new
|
|
225
|
+
model.objectCache = new WeakRefMap();
|
|
186
226
|
model.shaderCache = vtkWebGPUShaderCache.newInstance();
|
|
187
227
|
model.shaderCache.setDevice(publicAPI);
|
|
188
228
|
model.bindGroupLayouts = [];
|
|
@@ -203,4 +243,4 @@ var vtkWebGPUDevice$1 = {
|
|
|
203
243
|
extend: extend
|
|
204
244
|
};
|
|
205
245
|
|
|
206
|
-
export { vtkWebGPUDevice$1 as default, extend, newInstance };
|
|
246
|
+
export { WeakRefMap, vtkWebGPUDevice$1 as default, extend, newInstance };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
2
|
import vtkWebGPUShaderCache from './ShaderCache.js';
|
|
3
|
-
import
|
|
3
|
+
import vtkWebGPUSimpleMapper from './SimpleMapper.js';
|
|
4
4
|
|
|
5
5
|
// vtkWebGPUFullScreenQuad methods
|
|
6
6
|
// ----------------------------------------------------------------------------
|
|
@@ -18,13 +18,11 @@ function vtkWebGPUFullScreenQuad(publicAPI, model) {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
model.shaderReplacements.set('replaceShaderPosition', publicAPI.replaceShaderPosition);
|
|
21
|
-
var superclassBuild = publicAPI.build;
|
|
22
21
|
|
|
23
|
-
publicAPI.
|
|
24
|
-
var buff = device.getBufferManager().getFullScreenQuadBuffer();
|
|
22
|
+
publicAPI.updateBuffers = function () {
|
|
23
|
+
var buff = model.device.getBufferManager().getFullScreenQuadBuffer();
|
|
25
24
|
model.vertexInput.addBuffer(buff, ['vertexBC']);
|
|
26
25
|
model.numberOfVertices = 6;
|
|
27
|
-
superclassBuild(renderEncoder, device);
|
|
28
26
|
};
|
|
29
27
|
} // ----------------------------------------------------------------------------
|
|
30
28
|
// Object factory
|
|
@@ -37,7 +35,7 @@ function extend(publicAPI, model) {
|
|
|
37
35
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
38
36
|
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
vtkWebGPUSimpleMapper.extend(publicAPI, model, initialValues); // Object methods
|
|
41
39
|
|
|
42
40
|
vtkWebGPUFullScreenQuad(publicAPI, model);
|
|
43
41
|
} // ----------------------------------------------------------------------------
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import { newInstance as newInstance$1, obj } from '../../macros.js';
|
|
3
|
+
import vtkWebGPUCellArrayMapper from './CellArrayMapper.js';
|
|
3
4
|
import vtkWebGPUPolyDataMapper from './PolyDataMapper.js';
|
|
4
5
|
import vtkWebGPUStorageBuffer from './StorageBuffer.js';
|
|
5
6
|
import vtkWebGPUShaderCache from './ShaderCache.js';
|
|
6
|
-
import vtkWebGPUBufferManager from './BufferManager.js';
|
|
7
7
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
8
8
|
|
|
9
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
10
|
|
|
11
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
var PrimitiveTypes = vtkWebGPUBufferManager.PrimitiveTypes; // ----------------------------------------------------------------------------
|
|
13
|
-
// vtkWebGPUSphereMapper methods
|
|
14
|
-
// ----------------------------------------------------------------------------
|
|
15
12
|
|
|
16
|
-
function
|
|
13
|
+
function vtkWebGPUGlyph3DCellArrayMapper(publicAPI, model) {
|
|
17
14
|
// Set our className
|
|
18
|
-
model.classHierarchy.push('
|
|
15
|
+
model.classHierarchy.push('vtkWebGPUGlyph3DCellArrayMapper');
|
|
19
16
|
|
|
20
17
|
var superClass = _objectSpread({}, publicAPI);
|
|
21
18
|
|
|
@@ -28,6 +25,8 @@ function vtkWebGPUGlyph3DMapper(publicAPI, model) {
|
|
|
28
25
|
vDesc.setCode(code);
|
|
29
26
|
};
|
|
30
27
|
|
|
28
|
+
model.shaderReplacements.set('replaceShaderPosition', publicAPI.replaceShaderPosition);
|
|
29
|
+
|
|
31
30
|
publicAPI.replaceShaderNormal = function (hash, pipeline, vertexInput) {
|
|
32
31
|
if (vertexInput.hasAttribute('normalMC')) {
|
|
33
32
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
@@ -39,8 +38,10 @@ function vtkWebGPUGlyph3DMapper(publicAPI, model) {
|
|
|
39
38
|
superClass.replaceShaderNormal(hash, pipeline, vertexInput);
|
|
40
39
|
};
|
|
41
40
|
|
|
41
|
+
model.shaderReplacements.set('replaceShaderNormal', publicAPI.replaceShaderNormal);
|
|
42
|
+
|
|
42
43
|
publicAPI.replaceShaderColor = function (hash, pipeline, vertexInput) {
|
|
43
|
-
if (!model.
|
|
44
|
+
if (!model.renderable.getColorArray()) {
|
|
44
45
|
superClass.replaceShaderColor(hash, pipeline, vertexInput);
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
@@ -56,6 +57,8 @@ function vtkWebGPUGlyph3DMapper(publicAPI, model) {
|
|
|
56
57
|
fDesc.setCode(code);
|
|
57
58
|
};
|
|
58
59
|
|
|
60
|
+
model.shaderReplacements.set('replaceShaderColor', publicAPI.replaceShaderColor);
|
|
61
|
+
|
|
59
62
|
publicAPI.replaceShaderSelect = function (hash, pipeline, vertexInput) {
|
|
60
63
|
if (hash.includes('sel')) {
|
|
61
64
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
@@ -70,21 +73,69 @@ function vtkWebGPUGlyph3DMapper(publicAPI, model) {
|
|
|
70
73
|
}
|
|
71
74
|
};
|
|
72
75
|
|
|
73
|
-
publicAPI.
|
|
76
|
+
model.shaderReplacements.set('replaceShaderSelect', publicAPI.replaceShaderSelect);
|
|
77
|
+
} // ----------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function caExtend(publicAPI, model) {
|
|
81
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
82
|
+
Object.assign(model, {}, initialValues); // Inheritance
|
|
83
|
+
|
|
84
|
+
vtkWebGPUCellArrayMapper.extend(publicAPI, model, initialValues); // Object methods
|
|
85
|
+
|
|
86
|
+
vtkWebGPUGlyph3DCellArrayMapper(publicAPI, model);
|
|
87
|
+
}
|
|
88
|
+
var caNewInstance = newInstance$1(caExtend, 'vtkWebGPUGlyph3DCellArrayMapper'); // ----------------------------------------------------------------------------
|
|
89
|
+
// vtkWebGPUSphereMapper methods
|
|
90
|
+
// ----------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
function vtkWebGPUGlyph3DMapper(publicAPI, model) {
|
|
93
|
+
// Set our className
|
|
94
|
+
model.classHierarchy.push('vtkWebGPUGlyph3DMapper');
|
|
95
|
+
|
|
96
|
+
publicAPI.createCellArrayMapper = function () {
|
|
97
|
+
var mpr = caNewInstance();
|
|
98
|
+
mpr.setSSBO(model.SSBO);
|
|
99
|
+
mpr.setRenderable(model.renderable);
|
|
100
|
+
return mpr;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
publicAPI.buildPass = function (prepass) {
|
|
104
|
+
if (prepass) {
|
|
105
|
+
model.WebGPUActor = publicAPI.getFirstAncestorOfType('vtkWebGPUActor');
|
|
106
|
+
|
|
107
|
+
if (!model.renderable.getStatic()) {
|
|
108
|
+
model.renderable.update();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var gpoly = model.renderable.getInputData(1);
|
|
112
|
+
model.renderable.mapScalars(gpoly, 1.0);
|
|
113
|
+
publicAPI.updateSSBO();
|
|
114
|
+
publicAPI.updateCellArrayMappers(gpoly);
|
|
115
|
+
|
|
116
|
+
for (var i = 0; i < model.children.length; i++) {
|
|
117
|
+
var cellMapper = model.children[i];
|
|
118
|
+
cellMapper.setNumberOfInstances(model.numInstances);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
publicAPI.updateSSBO = function () {
|
|
74
124
|
model.currentInput = model.renderable.getInputData(1);
|
|
75
125
|
model.renderable.buildArrays(); // update the buffer objects if needed
|
|
76
126
|
|
|
77
127
|
var garray = model.renderable.getMatrixArray();
|
|
78
128
|
var narray = model.renderable.getNormalArray();
|
|
79
129
|
model.carray = model.renderable.getColorArray();
|
|
80
|
-
|
|
130
|
+
model.numInstances = garray.length / 16;
|
|
81
131
|
|
|
82
132
|
if (model.renderable.getBuildTime().getMTime() > model.glyphBOBuildTime.getMTime()) {
|
|
83
133
|
// In Core class all arrays are rebuilt when this happens
|
|
84
134
|
// but these arrays can be shared between all primType
|
|
135
|
+
model.WebGPURenderWindow = publicAPI.getFirstAncestorOfType('vtkWebGPURenderWindow');
|
|
85
136
|
var device = model.WebGPURenderWindow.getDevice();
|
|
86
137
|
model.SSBO.clearData();
|
|
87
|
-
model.SSBO.setNumberOfInstances(numInstances);
|
|
138
|
+
model.SSBO.setNumberOfInstances(model.numInstances);
|
|
88
139
|
model.SSBO.addEntry('matrix', 'mat4x4<f32>');
|
|
89
140
|
model.SSBO.addEntry('normal', 'mat4x4<f32>');
|
|
90
141
|
|
|
@@ -102,13 +153,6 @@ function vtkWebGPUGlyph3DMapper(publicAPI, model) {
|
|
|
102
153
|
model.SSBO.send(device);
|
|
103
154
|
model.glyphBOBuildTime.modified();
|
|
104
155
|
}
|
|
105
|
-
|
|
106
|
-
superClass.buildPrimitives();
|
|
107
|
-
|
|
108
|
-
for (var i = 0; i < model.primitives.length; i++) {
|
|
109
|
-
var primHelper = model.primitives[i];
|
|
110
|
-
primHelper.setNumberOfInstances(numInstances);
|
|
111
|
-
}
|
|
112
156
|
};
|
|
113
157
|
} // ----------------------------------------------------------------------------
|
|
114
158
|
// Object factory
|
|
@@ -131,15 +175,6 @@ function extend(publicAPI, model) {
|
|
|
131
175
|
}); // Object methods
|
|
132
176
|
|
|
133
177
|
vtkWebGPUGlyph3DMapper(publicAPI, model);
|
|
134
|
-
|
|
135
|
-
for (var i = PrimitiveTypes.Start; i < PrimitiveTypes.End; i++) {
|
|
136
|
-
model.primitives[i].setSSBO(model.SSBO);
|
|
137
|
-
var sr = model.primitives[i].getShaderReplacements();
|
|
138
|
-
sr.set('replaceShaderPosition', publicAPI.replaceShaderPosition);
|
|
139
|
-
sr.set('replaceShaderNormal', publicAPI.replaceShaderNormal);
|
|
140
|
-
sr.set('replaceShaderSelect', publicAPI.replaceShaderSelect);
|
|
141
|
-
sr.set('replaceShaderColor', publicAPI.replaceShaderColor);
|
|
142
|
-
}
|
|
143
178
|
} // ----------------------------------------------------------------------------
|
|
144
179
|
|
|
145
180
|
var newInstance = newInstance$1(extend, 'vtkWebGPUGlyph3DMapper'); // ----------------------------------------------------------------------------
|
|
@@ -151,4 +186,4 @@ var index = {
|
|
|
151
186
|
|
|
152
187
|
registerOverride('vtkGlyph3DMapper', newInstance);
|
|
153
188
|
|
|
154
|
-
export { index as default, extend, newInstance };
|
|
189
|
+
export { caExtend, index as default, extend, newInstance };
|
|
@@ -2,11 +2,9 @@ import { mat4, vec4 } from 'gl-matrix';
|
|
|
2
2
|
import Constants from '../Core/ImageMapper/Constants.js';
|
|
3
3
|
import { newInstance as newInstance$1, obj } from '../../macros.js';
|
|
4
4
|
import vtkWebGPUShaderCache from './ShaderCache.js';
|
|
5
|
-
import vtkWebGPUStorageBuffer from './StorageBuffer.js';
|
|
6
5
|
import vtkWebGPUFullScreenQuad from './FullScreenQuad.js';
|
|
7
6
|
import vtkWebGPUUniformBuffer from './UniformBuffer.js';
|
|
8
7
|
import vtkWebGPUSampler from './Sampler.js';
|
|
9
|
-
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
10
8
|
import { InterpolationType } from '../Core/ImageProperty/Constants.js';
|
|
11
9
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
12
10
|
|
|
@@ -69,10 +67,8 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
69
67
|
publicAPI.render = function () {
|
|
70
68
|
model.renderable.update();
|
|
71
69
|
model.currentInput = model.renderable.getInputData();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
publicAPI.updateUBO(model.device);
|
|
70
|
+
publicAPI.prepareToDraw(model.WebGPURenderer.getRenderEncoder());
|
|
71
|
+
model.renderEncoder.registerDrawCallback(model.pipeline, publicAPI.draw);
|
|
76
72
|
};
|
|
77
73
|
|
|
78
74
|
publicAPI.computePipelineHash = function () {
|
|
@@ -87,7 +83,7 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
87
83
|
}
|
|
88
84
|
};
|
|
89
85
|
|
|
90
|
-
publicAPI.updateUBO = function (
|
|
86
|
+
publicAPI.updateUBO = function () {
|
|
91
87
|
var utime = model.UBO.getSendTime();
|
|
92
88
|
var actor = model.WebGPUImageSlice.getRenderable();
|
|
93
89
|
var volMapr = actor.getMapper();
|
|
@@ -172,7 +168,7 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
172
168
|
|
|
173
169
|
var cScale = [1, 1, 1, 1];
|
|
174
170
|
var cShift = [0, 0, 0, 0];
|
|
175
|
-
var tView = model.
|
|
171
|
+
var tView = model.textureViews[0];
|
|
176
172
|
var tScale = tView.getTexture().getScale();
|
|
177
173
|
var numComp = tView.getTexture().getNumberOfComponents();
|
|
178
174
|
var iComps = false; // todo handle independent?
|
|
@@ -195,13 +191,13 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
195
191
|
|
|
196
192
|
model.UBO.setArray('cScale', cScale);
|
|
197
193
|
model.UBO.setArray('cShift', cShift);
|
|
198
|
-
model.UBO.sendIfNeeded(device);
|
|
194
|
+
model.UBO.sendIfNeeded(model.device);
|
|
199
195
|
}
|
|
200
196
|
};
|
|
201
197
|
|
|
202
|
-
publicAPI.updateLUTImage = function (
|
|
198
|
+
publicAPI.updateLUTImage = function () {
|
|
203
199
|
var actorProperty = model.WebGPUImageSlice.getRenderable().getProperty();
|
|
204
|
-
var tView =
|
|
200
|
+
var tView = publicAPI.getTextureViews()[0];
|
|
205
201
|
tView.getTexture().getNumberOfComponents();
|
|
206
202
|
|
|
207
203
|
var numIComps = 1;
|
|
@@ -257,35 +253,28 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
257
253
|
depth: 1,
|
|
258
254
|
format: 'rgba8unorm'
|
|
259
255
|
};
|
|
260
|
-
var newTex = device.getTextureManager().getTexture(treq);
|
|
256
|
+
var newTex = model.device.getTextureManager().getTexture(treq);
|
|
261
257
|
var tview = newTex.createView('tfunTexture');
|
|
262
|
-
|
|
263
|
-
tViews[1] = tview;
|
|
258
|
+
model.textureViews[1] = tview;
|
|
264
259
|
}
|
|
265
260
|
model.colorTextureString = cfunToString;
|
|
266
261
|
}
|
|
267
262
|
};
|
|
268
263
|
|
|
269
|
-
publicAPI.updateBuffers
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var
|
|
275
|
-
var tViews = model.helper.getTextureViews();
|
|
264
|
+
var superClassUpdateBuffers = publicAPI.updateBuffers;
|
|
265
|
+
|
|
266
|
+
publicAPI.updateBuffers = function () {
|
|
267
|
+
superClassUpdateBuffers();
|
|
268
|
+
var newTex = model.device.getTextureManager().getTextureForImageData(model.currentInput);
|
|
269
|
+
var tViews = model.textureViews;
|
|
276
270
|
|
|
277
271
|
if (!tViews[0] || tViews[0].getTexture() !== newTex) {
|
|
278
272
|
var tview = newTex.createView('imgTexture');
|
|
279
273
|
tViews[0] = tview;
|
|
280
274
|
}
|
|
281
275
|
|
|
282
|
-
publicAPI.updateLUTImage(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
publicAPI.build = function (renderEncoder, device) {
|
|
286
|
-
publicAPI.computePipelineHash();
|
|
287
|
-
model.helper.setPipelineHash(model.pipelineHash);
|
|
288
|
-
publicAPI.updateBuffers(device); // set interpolation on the texture based on property setting
|
|
276
|
+
publicAPI.updateLUTImage();
|
|
277
|
+
publicAPI.updateUBO(); // set interpolation on the texture based on property setting
|
|
289
278
|
|
|
290
279
|
var actorProperty = model.WebGPUImageSlice.getRenderable().getProperty();
|
|
291
280
|
var iType = actorProperty.getInterpolationType() === InterpolationType.NEAREST ? 'nearest' : 'linear';
|
|
@@ -294,26 +283,15 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
294
283
|
model.clampSampler = vtkWebGPUSampler.newInstance({
|
|
295
284
|
label: 'clampSampler'
|
|
296
285
|
});
|
|
297
|
-
model.clampSampler.create(device, {
|
|
286
|
+
model.clampSampler.create(model.device, {
|
|
298
287
|
minFilter: iType,
|
|
299
288
|
magFilter: iType
|
|
300
289
|
});
|
|
290
|
+
model.additionalBindables = [model.clampSampler];
|
|
301
291
|
}
|
|
302
|
-
|
|
303
|
-
model.helper.setAdditionalBindables(publicAPI.getBindables());
|
|
304
|
-
model.helper.setWebGPURenderer(model.WebGPURenderer);
|
|
305
|
-
model.helper.build(renderEncoder, device);
|
|
306
|
-
model.helper.registerToDraw();
|
|
307
292
|
};
|
|
308
293
|
|
|
309
|
-
|
|
310
|
-
var bindables = []; // bindables.push(model.componentSSBO);
|
|
311
|
-
|
|
312
|
-
bindables.push(model.clampSampler);
|
|
313
|
-
return bindables;
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
var sr = model.helper.getShaderReplacements();
|
|
294
|
+
var sr = publicAPI.getShaderReplacements();
|
|
317
295
|
|
|
318
296
|
publicAPI.replaceShaderPosition = function (hash, pipeline, vertexInput) {
|
|
319
297
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
@@ -367,27 +345,15 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
367
345
|
|
|
368
346
|
|
|
369
347
|
var DEFAULT_VALUES = {
|
|
370
|
-
rowLength: 1024
|
|
371
|
-
// VBOBuildString: null,
|
|
372
|
-
// webGPUTexture: null,
|
|
373
|
-
// tris: null,
|
|
374
|
-
// imagemat: null,
|
|
375
|
-
// imagematinv: null,
|
|
376
|
-
// colorTexture: null,
|
|
377
|
-
// pwfTexture: null,
|
|
378
|
-
// lastHaveSeenDepthRequest: false,
|
|
379
|
-
// haveSeenDepthRequest: false,
|
|
380
|
-
// lastTextureComponents: 0,
|
|
381
|
-
|
|
348
|
+
rowLength: 1024
|
|
382
349
|
}; // ----------------------------------------------------------------------------
|
|
383
350
|
|
|
384
351
|
function extend(publicAPI, model) {
|
|
385
352
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
386
353
|
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
387
354
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
model.helper.setFragmentShaderTemplate(imgFragTemplate);
|
|
355
|
+
vtkWebGPUFullScreenQuad.extend(publicAPI, model, initialValues);
|
|
356
|
+
publicAPI.setFragmentShaderTemplate(imgFragTemplate);
|
|
391
357
|
model.UBO = vtkWebGPUUniformBuffer.newInstance({
|
|
392
358
|
label: 'mapperUBO'
|
|
393
359
|
});
|
|
@@ -397,13 +363,6 @@ function extend(publicAPI, model) {
|
|
|
397
363
|
model.UBO.addEntry('Axis1', 'vec4<f32>');
|
|
398
364
|
model.UBO.addEntry('cScale', 'vec4<f32>');
|
|
399
365
|
model.UBO.addEntry('cShift', 'vec4<f32>');
|
|
400
|
-
model.helper.setUBO(model.UBO);
|
|
401
|
-
model.SSBO = vtkWebGPUStorageBuffer.newInstance({
|
|
402
|
-
label: 'volumeSSBO'
|
|
403
|
-
});
|
|
404
|
-
model.componentSSBO = vtkWebGPUStorageBuffer.newInstance({
|
|
405
|
-
label: 'componentSSBO'
|
|
406
|
-
});
|
|
407
366
|
model.lutBuildTime = {};
|
|
408
367
|
obj(model.lutBuildTime, {
|
|
409
368
|
mtime: 0
|
|
@@ -77,11 +77,9 @@ function vtkWebGPUOrderIndependentTranslucentPass(publicAPI, model) {
|
|
|
77
77
|
publicAPI.finalPass = function (viewNode, renNode) {
|
|
78
78
|
model.translucentFinalEncoder.setColorTextureView(0, model.colorTextureView);
|
|
79
79
|
model.translucentFinalEncoder.attachTextureViews();
|
|
80
|
-
|
|
81
|
-
model.translucentFinalEncoder.begin(viewNode.getCommandEncoder()); // set viewport
|
|
82
|
-
|
|
80
|
+
model.translucentFinalEncoder.begin(viewNode.getCommandEncoder());
|
|
83
81
|
renNode.scissorAndViewport(model.translucentFinalEncoder);
|
|
84
|
-
model.fullScreenQuad.
|
|
82
|
+
model.fullScreenQuad.prepareAndDraw(model.translucentFinalEncoder);
|
|
85
83
|
model.translucentFinalEncoder.end();
|
|
86
84
|
};
|
|
87
85
|
|
|
@@ -116,8 +114,8 @@ function vtkWebGPUOrderIndependentTranslucentPass(publicAPI, model) {
|
|
|
116
114
|
fDesc.addOutput('f32', 'outAccum');
|
|
117
115
|
fDesc.addBuiltinInput('vec4<f32>', '@builtin(position) fragPos');
|
|
118
116
|
var code = fDesc.getCode();
|
|
119
|
-
code = vtkWebGPUShaderCache.substitute(code, '//VTK::RenderEncoder::Impl', [// very simple depth weighting in w
|
|
120
|
-
'var w: f32 =
|
|
117
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::RenderEncoder::Impl', [// very simple depth weighting in w z ranges from 1.0 near to 0.0
|
|
118
|
+
'var w: f32 = computedColor.a * pow(0.1 + input.fragPos.z, 2.0);', 'output.outColor = vec4<f32>(computedColor.rgb*w, w);', 'output.outAccum = computedColor.a;']).result;
|
|
121
119
|
fDesc.setCode(code);
|
|
122
120
|
});
|
|
123
121
|
model.translucentRenderEncoder.setPipelineHash('oitpr');
|
|
@@ -83,6 +83,17 @@ function vtkWebGPUPipeline(publicAPI, model) {
|
|
|
83
83
|
publicAPI.bindVertexInput = function (renderEncoder, vInput) {
|
|
84
84
|
vInput.bindBuffers(renderEncoder);
|
|
85
85
|
};
|
|
86
|
+
|
|
87
|
+
publicAPI.addDrawCallback = function (cb) {
|
|
88
|
+
model._drawCallbacks.push(cb);
|
|
89
|
+
}; // handle anything that needs to be done when drawing
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
publicAPI.draw = function (encoder) {
|
|
93
|
+
for (var cb = 0; cb < model._drawCallbacks.length; cb++) {
|
|
94
|
+
model._drawCallbacks[cb](encoder, publicAPI);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
86
97
|
} // ----------------------------------------------------------------------------
|
|
87
98
|
// Object factory
|
|
88
99
|
// ----------------------------------------------------------------------------
|
|
@@ -105,6 +116,7 @@ function extend(publicAPI, model) {
|
|
|
105
116
|
obj(publicAPI, model);
|
|
106
117
|
model.layouts = [];
|
|
107
118
|
model.shaderDescriptions = [];
|
|
119
|
+
model._drawCallbacks = [];
|
|
108
120
|
get(publicAPI, model, ['handle', 'pipelineDescription']);
|
|
109
121
|
setGet(publicAPI, model, ['device', 'renderEncoder', 'topology', 'vertexState']); // For more macro methods, see "Sources/macros.js"
|
|
110
122
|
// Object specific methods
|