Skip to content

iOS: volumes draw with 16-bit float transfer-function tables - #1213

Merged
transfix merged 1 commit into
masterfrom
fix/vtk-float-tables-ios
Nov 15, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/vtk-float-tables-ios

Conversation

@transfix

Copy link
Copy Markdown
Owner

Follow-up to #1166 (Joe: "fix the VTK float lookup tables too").

Cause. VTK's GPU ray caster keeps a volume's transfer functions as float textures (RGB32F colour, R32F scalar and gradient opacity, RGBA32F 2-D tables), filtered with the volume's interpolation (vtkOpenGLVolumeRGBTable / vtkOpenGLVolumeOpacityTable → Create2DFromRaw(..., VTK_FLOAT, ...), format from vtkOpenGLState's defaults). WebGL2 filters 32F linearly only with OES_texture_float_linear, which iOS Safari lacks: there a linearly filtered 32F texture samples as zero, so a volume gets no colour and no opacity. #1166 moved the cloud and sea voxels to bytes; this fixes the tables.

Fix. VolumeNode's vtkVolume is now a small subclass. While it draws, and only on a context without the extension (an EM_JS check of GLctx.getExtension; desktop GL never), it switches the context's default float texture formats to R16F/RG16F/RGB16F/RGBA16F, then puts them back. vtkTextureObject keeps the format a texture was first made with, so the volume's tables stay 16F. The rest of the scene's float textures stay 32F, above all the texture-buffer vertex data: that's why a global switch was rejected. VolumeNode::setHalfFloatTextures(int) forces it on or off. VTK's protected format table is reached through a member pointer named in a derived class; no VTK patch is needed.

Test. New cvcgl_volume_half_float (native, forced on). The volume renders the same as with 32F tables: 6661 lit px each, mean |diff| 0.008, worst 1. With the switch on, two 16F textures exist (colour and opacity tables); with it off, none. The defaults read R32F/RGB32F again after the draw. Also passing locally: cvcgl_ariadne_realize, cvcgl_shadow_*, cvcgl_city_sun_shadows, cvcgl_volume_range, cvcgl_camera*, ariadne_runtime_test (14/14).

Demo page. ?hideext=A,B hides any WebGL extensions by name, as ?nofloatlinear hides OES_texture_float_linear. For example ?hideext=EXT_float_blend tests whether missing float blending explains the iPhone's black clouds.

Not checked: the wasm build in a browser, or a real iPhone. After deploy, ?nofloatlinear on the live terrain lab should show the near clouds again (before this, they vanished).

VTK's GPU ray caster keeps a volume's transfer functions as float textures
(RGB32F colour, R32F scalar and gradient opacity, RGBA32F 2-D tables),
filtered with the volume's interpolation. WebGL2 filters 32F linearly only
with OES_texture_float_linear, which iOS Safari lacks: a linearly filtered
32F texture there samples as zero, so a volume got no colour and no opacity.

VolumeNode's vtkVolume is now a small subclass that, while it draws and only
on a context without the extension, switches the context's default float
texture formats to R16F/RG16F/RGB16F/RGBA16F and puts them back after.
vtkTextureObject keeps the format a texture was first made with, so the
volume's tables stay 16F and the rest of the scene's float textures (texture
buffer vertex data above all) stay 32F. VolumeNode::setHalfFloatTextures
forces it on or off for that node (a member of its vtkVolume, no process-wide
state).

New test cvcgl_volume_half_float (native, forced on): the volume renders the
same as with 32F tables (worst pixel difference 1), its tables are 16F
textures, and the defaults are 32F again after the draw.

The demo page's ?hideext=A,B hides any WebGL extensions by name, as
?nofloatlinear hides OES_texture_float_linear (EXT_float_blend, say).
@transfix
transfix force-pushed the fix/vtk-float-tables-ios branch from b321c43 to f3cecaf Compare November 15, 2026 08:00
@transfix
transfix merged commit 7e93579 into master Nov 15, 2026
28 checks passed
@transfix
transfix deleted the fix/vtk-float-tables-ios branch November 15, 2026 19:46
transfix added a commit that referenced this pull request Nov 16, 2026
…#1253, #1255, #1256, #1264, #1268, #1271, #1273, #1277)

- ci.yml: the sanitizer list keeps this branch's tests (stream_test, net_ws_client_test,
  ariadne_host_test) and master's segmentation_intrinsics_test.
- STATE_EXEC_THREADED.md: the room-call verbs (room-run is #1273's) and #1252's segment.seeded
  provider in the provider table, both registered without a kind. room-call's async functions
  stay on the app's host: a reply settles on the relay client's reader thread through
  host.finish, so moving them to *ictx.host needs a finisher first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant