@@ -7,6 +7,8 @@ import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode';
7
7
8
8
import { registerOverride } from 'vtk.js/Sources/Rendering/OpenGL/ViewNodeFactory' ;
9
9
10
+ import supportsNorm16Linear from './supportsNorm16Linear' ;
11
+
10
12
const { Wrap, Filter } = Constants ;
11
13
const { VtkDataTypes } = vtkDataArray ;
12
14
const { vtkDebugMacro, vtkErrorMacro, vtkWarningMacro } = macro ;
@@ -160,6 +162,17 @@ function vtkOpenGLTexture(publicAPI, model) {
160
162
}
161
163
} ;
162
164
165
+ const getNorm16Ext = ( ) => {
166
+ if (
167
+ ( model . minificationFilter === Filter . LINEAR ||
168
+ model . magnificationFilter === Filter . LINEAR ) &&
169
+ ! supportsNorm16Linear ( )
170
+ ) {
171
+ return undefined ;
172
+ }
173
+ return model . oglNorm16Ext ;
174
+ } ;
175
+
163
176
//----------------------------------------------------------------------------
164
177
publicAPI . destroyTexture = ( ) => {
165
178
// deactivate it first
@@ -391,7 +404,7 @@ function vtkOpenGLTexture(publicAPI, model) {
391
404
result = model . _openGLRenderWindow . getDefaultTextureInternalFormat (
392
405
vtktype ,
393
406
numComps ,
394
- model . oglNorm16Ext ,
407
+ getNorm16Ext ( ) ,
395
408
publicAPI . useHalfFloat ( )
396
409
) ;
397
410
if ( result ) {
@@ -478,9 +491,9 @@ function vtkOpenGLTexture(publicAPI, model) {
478
491
return model . context . UNSIGNED_BYTE ;
479
492
// prefer norm16 since that is accurate compared to
480
493
// half float which is not
481
- case model . oglNorm16Ext && ! useHalfFloat && VtkDataTypes . SHORT :
494
+ case getNorm16Ext ( ) && ! useHalfFloat && VtkDataTypes . SHORT :
482
495
return model . context . SHORT ;
483
- case model . oglNorm16Ext && ! useHalfFloat && VtkDataTypes . UNSIGNED_SHORT :
496
+ case getNorm16Ext ( ) && ! useHalfFloat && VtkDataTypes . UNSIGNED_SHORT :
484
497
return model . context . UNSIGNED_SHORT ;
485
498
// use half float type
486
499
case useHalfFloat && VtkDataTypes . SHORT :
@@ -820,7 +833,7 @@ function vtkOpenGLTexture(publicAPI, model) {
820
833
if (
821
834
webGLInfo . RENDERER . value . match ( / W e b K i t / gi) &&
822
835
navigator . platform . match ( / M a c / gi) &&
823
- model . oglNorm16Ext &&
836
+ getNorm16Ext ( ) &&
824
837
( dataType === VtkDataTypes . UNSIGNED_SHORT ||
825
838
dataType === VtkDataTypes . SHORT )
826
839
) {
@@ -925,7 +938,7 @@ function vtkOpenGLTexture(publicAPI, model) {
925
938
numComps *
926
939
model . _openGLRenderWindow . getDefaultTextureByteSize (
927
940
dataType ,
928
- model . oglNorm16Ext ,
941
+ getNorm16Ext ( ) ,
929
942
publicAPI . useHalfFloat ( )
930
943
) ;
931
944
publicAPI . deactivate ( ) ;
@@ -1049,7 +1062,7 @@ function vtkOpenGLTexture(publicAPI, model) {
1049
1062
numComps *
1050
1063
model . _openGLRenderWindow . getDefaultTextureByteSize (
1051
1064
dataType ,
1052
- model . oglNorm16Ext ,
1065
+ getNorm16Ext ( ) ,
1053
1066
publicAPI . useHalfFloat ( )
1054
1067
) ;
1055
1068
// generateMipmap must not be called here because we manually upload all levels
@@ -1138,7 +1151,7 @@ function vtkOpenGLTexture(publicAPI, model) {
1138
1151
model . components *
1139
1152
model . _openGLRenderWindow . getDefaultTextureByteSize (
1140
1153
dataType ,
1141
- model . oglNorm16Ext ,
1154
+ getNorm16Ext ( ) ,
1142
1155
publicAPI . useHalfFloat ( )
1143
1156
) ;
1144
1157
@@ -1248,7 +1261,7 @@ function vtkOpenGLTexture(publicAPI, model) {
1248
1261
model . components *
1249
1262
model . _openGLRenderWindow . getDefaultTextureByteSize (
1250
1263
VtkDataTypes . UNSIGNED_CHAR ,
1251
- model . oglNorm16Ext ,
1264
+ getNorm16Ext ( ) ,
1252
1265
publicAPI . useHalfFloat ( )
1253
1266
) ;
1254
1267
@@ -1401,11 +1414,7 @@ function vtkOpenGLTexture(publicAPI, model) {
1401
1414
}
1402
1415
1403
1416
// Handle SHORT data type with EXT_texture_norm16 extension
1404
- if (
1405
- model . oglNorm16Ext &&
1406
- ! useHalfFloat &&
1407
- dataType === VtkDataTypes . SHORT
1408
- ) {
1417
+ if ( getNorm16Ext ( ) && ! useHalfFloat && dataType === VtkDataTypes . SHORT ) {
1409
1418
for ( let c = 0 ; c < numComps ; ++ c ) {
1410
1419
model . volumeInfo . scale [ c ] = 32767.0 ; // Scale to [-1, 1] range
1411
1420
}
@@ -1414,7 +1423,7 @@ function vtkOpenGLTexture(publicAPI, model) {
1414
1423
1415
1424
// Handle UNSIGNED_SHORT data type with EXT_texture_norm16 extension
1416
1425
if (
1417
- model . oglNorm16Ext &&
1426
+ getNorm16Ext ( ) &&
1418
1427
! useHalfFloat &&
1419
1428
dataType === VtkDataTypes . UNSIGNED_SHORT
1420
1429
) {
@@ -1569,7 +1578,7 @@ function vtkOpenGLTexture(publicAPI, model) {
1569
1578
model . components *
1570
1579
model . _openGLRenderWindow . getDefaultTextureByteSize (
1571
1580
dataTypeToUse ,
1572
- model . oglNorm16Ext ,
1581
+ getNorm16Ext ( ) ,
1573
1582
publicAPI . useHalfFloat ( )
1574
1583
) ;
1575
1584
0 commit comments