@@ -408,7 +408,7 @@ function vtkOpenGLTexture(publicAPI, model) {
408
408
return result ;
409
409
} ;
410
410
411
- publicAPI . useHalfFloat = ( ) => model . enableHalfFloat && model . canUseHalfFloat ;
411
+ publicAPI . useHalfFloat = ( ) => model . canUseHalfFloat ;
412
412
413
413
//----------------------------------------------------------------------------
414
414
publicAPI . setInternalFormat = ( iFormat ) => {
@@ -1284,21 +1284,28 @@ function vtkOpenGLTexture(publicAPI, model) {
1284
1284
function setCanUseHalfFloat ( dataType , offset , scale , preferSizeOverAccuracy ) {
1285
1285
publicAPI . getOpenGLDataType ( dataType ) ;
1286
1286
1287
+ // Don't consider halfFloat and convert back to Float when the range of data does not generate an accurate halfFloat
1288
+ // AND it is not preferable to have a smaller texture than an exact texture.
1289
+ const isExactHalfFloat =
1290
+ hasExactHalfFloat ( offset , scale ) || preferSizeOverAccuracy ;
1291
+
1287
1292
let useHalfFloat = false ;
1288
1293
if ( model . _openGLRenderWindow . getWebgl2 ( ) ) {
1289
- useHalfFloat = model . openGLDataType === model . context . HALF_FLOAT ;
1294
+ // If OES_texture_float_linear is not available, and using a half float would still be exact, force half floats
1295
+ // This is because half floats are always texture filterable in webgl2, while full *32F floats are not (unless the extension is present)
1296
+ const forceHalfFloat =
1297
+ model . openGLDataType === model . context . FLOAT &&
1298
+ model . context . getExtension ( 'OES_texture_float_linear' ) === null &&
1299
+ isExactHalfFloat ;
1300
+ useHalfFloat =
1301
+ forceHalfFloat || model . openGLDataType === model . context . HALF_FLOAT ;
1290
1302
} else {
1291
1303
const halfFloatExt = model . context . getExtension ( 'OES_texture_half_float' ) ;
1292
1304
useHalfFloat =
1293
1305
halfFloatExt && model . openGLDataType === halfFloatExt . HALF_FLOAT_OES ;
1294
1306
}
1295
1307
1296
- // Don't consider halfFloat and convert back to Float when the range of data does not generate an accurate halfFloat
1297
- // AND it is not preferable to have a smaller texture than an exact texture.
1298
- const isHalfFloat =
1299
- useHalfFloat &&
1300
- ( hasExactHalfFloat ( offset , scale ) || preferSizeOverAccuracy ) ;
1301
- model . canUseHalfFloat = isHalfFloat ;
1308
+ model . canUseHalfFloat = useHalfFloat && isExactHalfFloat ;
1302
1309
}
1303
1310
1304
1311
function processDataArray ( dataArray , preferSizeOverAccuracy ) {
0 commit comments