Skip to content

Commit d15d50f

Browse files
committed
fix(mapper): add docs and support max texture size
1 parent c510277 commit d15d50f

File tree

7 files changed

+99
-11
lines changed

7 files changed

+99
-11
lines changed

Sources/Rendering/Core/AbstractImageMapper/index.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ export interface vtkAbstractImageMapper extends vtkAbstractMapper3D {
130130
* Only set this property if your opacity function range width is
131131
* larger than 1024.
132132
*
133+
* A reasonable max texture size would be either 2048 or 4096, as those
134+
* widths are supported by the vast majority of devices. Any width larger
135+
* than that will have issues with device support.
136+
*
137+
* Specifying a width that is less than or equal to 0 will use the largest
138+
* possible texture width on the device. Use this with caution! The max texture
139+
* width of one device may not be the same for another device.
140+
*
141+
* You can find more information about supported texture widths at the following link:
142+
* https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
143+
*
133144
* @param {Number} width the texture width (defaults to 1024)
134145
*/
135146
setOpacityTextureWidth(width: number): boolean;
@@ -146,6 +157,17 @@ export interface vtkAbstractImageMapper extends vtkAbstractMapper3D {
146157
* Only set this property if your color transfer function range width is
147158
* larger than 1024.
148159
*
160+
* A reasonable max texture size would be either 2048 or 4096, as those
161+
* widths are supported by the vast majority of devices. Any width larger
162+
* than that will have issues with device support.
163+
*
164+
* Specifying a width that is less than or equal to 0 will use the largest
165+
* possible texture width on the device. Use this with caution! The max texture
166+
* width of one device may not be the same for another device.
167+
*
168+
* You can find more information about supported texture widths at the following link:
169+
* https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
170+
*
149171
* @param {Number} width the texture width (defaults to 1024)
150172
*/
151173
setColorTextureWidth(width: number): boolean;
@@ -162,6 +184,17 @@ export interface vtkAbstractImageMapper extends vtkAbstractMapper3D {
162184
* Only set this property if you have more than 1024 labels
163185
* that you want to render with thickness.
164186
*
187+
* A reasonable max texture size would be either 2048 or 4096, as those
188+
* widths are supported by the vast majority of devices. Any width larger
189+
* than that will have issues with device support.
190+
*
191+
* Specifying a width that is less than or equal to 0 will use the largest
192+
* possible texture width on the device. Use this with caution! The max texture
193+
* width of one device may not be the same for another device.
194+
*
195+
* You can find more information about supported texture widths at the following link:
196+
* https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
197+
*
165198
* @param {Number} width the texture width (defaults to 1024)
166199
*/
167200
setLabelOutlineTextureWidth(width: number): boolean;

Sources/Rendering/Core/CellPicker/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ function vtkCellPicker(publicAPI, model) {
277277

278278
// calculate opacity table
279279
const numIComps = 1;
280-
const oWidth = mapper.getOpacityTextureWidth();
280+
let oWidth = mapper.getOpacityTextureWidth();
281+
if (oWidth <= 0) {
282+
oWidth = 1024;
283+
}
281284
const tmpTable = new Float32Array(oWidth);
282285
const opacityArray = new Float32Array(oWidth);
283286
let ofun;

Sources/Rendering/Core/VolumeMapper/index.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,17 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
342342
* Only set this property if your color transfer function range width is
343343
* larger than 1024.
344344
*
345+
* A reasonable max texture size would be either 2048 or 4096, as those
346+
* widths are supported by the vast majority of devices. Any width larger
347+
* than that will have issues with device support.
348+
*
349+
* Specifying a width that is less than or equal to 0 will use the largest
350+
* possible texture width on the device. Use this with caution! The max texture
351+
* width of one device may not be the same for another device.
352+
*
353+
* You can find more information about supported texture widths at the following link:
354+
* https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
355+
*
345356
* @param {Number} width the texture width (defaults to 1024)
346357
*/
347358
setColorTextureWidth(width: number): boolean;
@@ -358,6 +369,17 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
358369
* Only set this property if you have more than 1024 labels
359370
* that you want to render with thickness.
360371
*
372+
* A reasonable max texture size would be either 2048 or 4096, as those
373+
* widths are supported by the vast majority of devices. Any width larger
374+
* than that will have issues with device support.
375+
*
376+
* Specifying a width that is less than or equal to 0 will use the largest
377+
* possible texture width on the device. Use this with caution! The max texture
378+
* width of one device may not be the same for another device.
379+
*
380+
* You can find more information about supported texture widths at the following link:
381+
* https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
382+
*
361383
* @param {Number} width the texture width (defaults to 1024)
362384
*/
363385
setLabelOutlineTextureWidth(width: number): boolean;

Sources/Rendering/OpenGL/ImageCPRMapper/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,10 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
275275
!cachedColorEntry?.oglObject?.getHandle() ||
276276
cachedColorEntry?.hash !== colorTextureHash;
277277
if (reBuildColorTexture) {
278-
const cWidth = model.renderable.getColorTextureWidth();
278+
let cWidth = model.renderable.getColorTextureWidth();
279+
if (cWidth <= 0) {
280+
cWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
281+
}
279282
const cSize = cWidth * textureHeight * 3;
280283
const cTable = new Uint8ClampedArray(cSize);
281284
model.colorTexture = vtkOpenGLTexture.newInstance();
@@ -355,7 +358,10 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
355358
!cachedPwfEntry?.oglObject?.getHandle() ||
356359
cachedPwfEntry?.hash !== pwfTextureHash;
357360
if (reBuildPwf) {
358-
const pwfWidth = model.renderable.getOpacityTextureWidth();
361+
let pwfWidth = model.renderable.getOpacityTextureWidth();
362+
if (pwfWidth <= 0) {
363+
pwfWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
364+
}
359365
const pwfSize = pwfWidth * textureHeight;
360366
const pwfTable = new Uint8ClampedArray(pwfSize);
361367
model.pwfTexture = vtkOpenGLTexture.newInstance();

Sources/Rendering/OpenGL/ImageMapper/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,10 @@ function vtkOpenGLImageMapper(publicAPI, model) {
969969
resizable: true,
970970
});
971971
model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
972-
const cWidth = model.renderable.getColorTextureWidth();
972+
let cWidth = model.renderable.getColorTextureWidth();
973+
if (cWidth <= 0) {
974+
cWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
975+
}
973976
const cSize = cWidth * textureHeight * 3;
974977
const cTable = new Uint8ClampedArray(cSize);
975978
// set interpolation on the texture based on property setting
@@ -1055,7 +1058,10 @@ function vtkOpenGLImageMapper(publicAPI, model) {
10551058
const reBuildPwf =
10561059
!pwfTex?.oglObject?.getHandle() || pwfTex?.hash !== pwfunToString;
10571060
if (reBuildPwf) {
1058-
const pwfWidth = model.renderable.getOpacityTextureWidth();
1061+
let pwfWidth = model.renderable.getOpacityTextureWidth();
1062+
if (pwfWidth <= 0) {
1063+
pwfWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
1064+
}
10591065
const pwfSize = pwfWidth * textureHeight;
10601066
const pwfTable = new Uint8ClampedArray(pwfSize);
10611067
model.pwfTexture = vtkOpenGLTexture.newInstance({
@@ -1397,7 +1403,10 @@ function vtkOpenGLImageMapper(publicAPI, model) {
13971403
const reBuildL = !lTex?.oglObject?.getHandle() || lTex?.hash !== toString;
13981404

13991405
if (reBuildL) {
1400-
const lWidth = model.renderable.getLabelOutlineTextureWidth();
1406+
let lWidth = model.renderable.getLabelOutlineTextureWidth();
1407+
if (lWidth <= 0) {
1408+
lWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
1409+
}
14011410
const lHeight = 1;
14021411
const lSize = lWidth * lHeight;
14031412
const lTable = new Uint8Array(lSize);

Sources/Rendering/OpenGL/ImageResliceMapper/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
302302
model._openGLRenderWindow.getGraphicsResourceForObject(colorTransferFunc);
303303
const reBuildC = !cTex?.oglObject?.getHandle() || cTex?.hash !== toString;
304304
if (reBuildC) {
305-
const cWidth = model.renderable.getColorTextureWidth();
305+
let cWidth = model.renderable.getColorTextureWidth();
306+
if (cWidth <= 0) {
307+
cWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
308+
}
306309
const cSize = cWidth * textureHeight * 3;
307310
const cTable = new Uint8ClampedArray(cSize);
308311
model.colorTexture = vtkOpenGLTexture.newInstance();
@@ -382,7 +385,10 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
382385
const reBuildPwf =
383386
!pwfTex?.oglObject?.getHandle() || pwfTex?.hash !== toString;
384387
if (reBuildPwf) {
385-
const pwfWidth = model.renderable.getOpacityTextureWidth();
388+
let pwfWidth = model.renderable.getOpacityTextureWidth();
389+
if (pwfWidth <= 0) {
390+
pwfWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
391+
}
386392
const pwfSize = pwfWidth * textureHeight;
387393
const pwfTable = new Uint8ClampedArray(pwfSize);
388394
model.pwfTexture = vtkOpenGLTexture.newInstance();

Sources/Rendering/OpenGL/VolumeMapper/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
15701570
model.opacityTexture = vtkOpenGLTexture.newInstance();
15711571
model.opacityTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
15721572
// rebuild opacity tfun?
1573-
const oWidth = model.renderable.getOpacityTextureWidth();
1573+
let oWidth = model.renderable.getOpacityTextureWidth();
1574+
if (oWidth <= 0) {
1575+
oWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
1576+
}
15741577
const oSize = oWidth * 2 * numIComps;
15751578
const ofTable = new Float32Array(oSize);
15761579
const tmpTable = new Float32Array(oWidth);
@@ -1659,7 +1662,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
16591662
if (reBuildC) {
16601663
model.colorTexture = vtkOpenGLTexture.newInstance();
16611664
model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
1662-
const cWidth = model.renderable.getColorTextureWidth();
1665+
let cWidth = model.renderable.getColorTextureWidth();
1666+
if (cWidth <= 0) {
1667+
cWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
1668+
}
16631669
const cSize = cWidth * 2 * numIComps * 3;
16641670
const cTable = new Uint8ClampedArray(cSize);
16651671
const tmpTable = new Float32Array(cWidth * 3);
@@ -1856,7 +1862,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
18561862
model.labelOutlineThicknessTexture.setOpenGLRenderWindow(
18571863
model._openGLRenderWindow
18581864
);
1859-
const lWidth = model.renderable.getLabelOutlineTextureWidth();
1865+
let lWidth = model.renderable.getLabelOutlineTextureWidth();
1866+
if (lWidth <= 0) {
1867+
lWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
1868+
}
18601869
const lHeight = 1;
18611870
const lSize = lWidth * lHeight;
18621871
const lTable = new Uint8Array(lSize);

0 commit comments

Comments
 (0)