@@ -7,6 +7,8 @@ import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode';
77
88import { registerOverride } from 'vtk.js/Sources/Rendering/OpenGL/ViewNodeFactory' ;
99
10+ import supportsNorm16Linear from './supportsNorm16Linear' ;
11+
1012const { Wrap, Filter } = Constants ;
1113const { VtkDataTypes } = vtkDataArray ;
1214const { vtkDebugMacro, vtkErrorMacro, vtkWarningMacro } = macro ;
@@ -160,6 +162,17 @@ function vtkOpenGLTexture(publicAPI, model) {
160162 }
161163 } ;
162164
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+
163176 //----------------------------------------------------------------------------
164177 publicAPI . destroyTexture = ( ) => {
165178 // deactivate it first
@@ -391,7 +404,7 @@ function vtkOpenGLTexture(publicAPI, model) {
391404 result = model . _openGLRenderWindow . getDefaultTextureInternalFormat (
392405 vtktype ,
393406 numComps ,
394- model . oglNorm16Ext ,
407+ getNorm16Ext ( ) ,
395408 publicAPI . useHalfFloat ( )
396409 ) ;
397410 if ( result ) {
@@ -478,9 +491,9 @@ function vtkOpenGLTexture(publicAPI, model) {
478491 return model . context . UNSIGNED_BYTE ;
479492 // prefer norm16 since that is accurate compared to
480493 // half float which is not
481- case model . oglNorm16Ext && ! useHalfFloat && VtkDataTypes . SHORT :
494+ case getNorm16Ext ( ) && ! useHalfFloat && VtkDataTypes . SHORT :
482495 return model . context . SHORT ;
483- case model . oglNorm16Ext && ! useHalfFloat && VtkDataTypes . UNSIGNED_SHORT :
496+ case getNorm16Ext ( ) && ! useHalfFloat && VtkDataTypes . UNSIGNED_SHORT :
484497 return model . context . UNSIGNED_SHORT ;
485498 // use half float type
486499 case useHalfFloat && VtkDataTypes . SHORT :
@@ -820,7 +833,7 @@ function vtkOpenGLTexture(publicAPI, model) {
820833 if (
821834 webGLInfo . RENDERER . value . match ( / W e b K i t / gi) &&
822835 navigator . platform . match ( / M a c / gi) &&
823- model . oglNorm16Ext &&
836+ getNorm16Ext ( ) &&
824837 ( dataType === VtkDataTypes . UNSIGNED_SHORT ||
825838 dataType === VtkDataTypes . SHORT )
826839 ) {
@@ -925,7 +938,7 @@ function vtkOpenGLTexture(publicAPI, model) {
925938 numComps *
926939 model . _openGLRenderWindow . getDefaultTextureByteSize (
927940 dataType ,
928- model . oglNorm16Ext ,
941+ getNorm16Ext ( ) ,
929942 publicAPI . useHalfFloat ( )
930943 ) ;
931944 publicAPI . deactivate ( ) ;
@@ -1049,7 +1062,7 @@ function vtkOpenGLTexture(publicAPI, model) {
10491062 numComps *
10501063 model . _openGLRenderWindow . getDefaultTextureByteSize (
10511064 dataType ,
1052- model . oglNorm16Ext ,
1065+ getNorm16Ext ( ) ,
10531066 publicAPI . useHalfFloat ( )
10541067 ) ;
10551068 // generateMipmap must not be called here because we manually upload all levels
@@ -1138,7 +1151,7 @@ function vtkOpenGLTexture(publicAPI, model) {
11381151 model . components *
11391152 model . _openGLRenderWindow . getDefaultTextureByteSize (
11401153 dataType ,
1141- model . oglNorm16Ext ,
1154+ getNorm16Ext ( ) ,
11421155 publicAPI . useHalfFloat ( )
11431156 ) ;
11441157
@@ -1248,7 +1261,7 @@ function vtkOpenGLTexture(publicAPI, model) {
12481261 model . components *
12491262 model . _openGLRenderWindow . getDefaultTextureByteSize (
12501263 VtkDataTypes . UNSIGNED_CHAR ,
1251- model . oglNorm16Ext ,
1264+ getNorm16Ext ( ) ,
12521265 publicAPI . useHalfFloat ( )
12531266 ) ;
12541267
@@ -1401,11 +1414,7 @@ function vtkOpenGLTexture(publicAPI, model) {
14011414 }
14021415
14031416 // 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 ) {
14091418 for ( let c = 0 ; c < numComps ; ++ c ) {
14101419 model . volumeInfo . scale [ c ] = 32767.0 ; // Scale to [-1, 1] range
14111420 }
@@ -1414,7 +1423,7 @@ function vtkOpenGLTexture(publicAPI, model) {
14141423
14151424 // Handle UNSIGNED_SHORT data type with EXT_texture_norm16 extension
14161425 if (
1417- model . oglNorm16Ext &&
1426+ getNorm16Ext ( ) &&
14181427 ! useHalfFloat &&
14191428 dataType === VtkDataTypes . UNSIGNED_SHORT
14201429 ) {
@@ -1569,7 +1578,7 @@ function vtkOpenGLTexture(publicAPI, model) {
15691578 model . components *
15701579 model . _openGLRenderWindow . getDefaultTextureByteSize (
15711580 dataTypeToUse ,
1572- model . oglNorm16Ext ,
1581+ getNorm16Ext ( ) ,
15731582 publicAPI . useHalfFloat ( )
15741583 ) ;
15751584
0 commit comments