Skip to content

Demo pages fit a phone; iOS: byte voxels, a nearest shadow map; ?gldiag and ?nofloatlinear - #1166

Merged
transfix merged 1 commit into
masterfrom
fix/mobile-header-ios-float
Nov 12, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/mobile-header-ios-float

Conversation

@transfix

Copy link
Copy Markdown
Owner

Joe's report: on a phone the demo pages are squished, with the text at the top leaving the demo very little room. On a friend's iPhone the CSS looked broken, the rendering was washed out and discoloured, and the clouds were black.

Phone layout

The header was one flex row that never wrapped. At 375 px wide, the description and keyboard keys became a column about 690 px tall, half the screen, and the Fullscreen button ran off the right edge.

At phone width (≤ 720 px) or on a touch screen:

  • the title, the demo picker and the ⛶ icon share one line;
  • a short touch hint ("drag to turn · pinch to zoom · all examples") sits under them;
  • the description and keyboard keys are hidden.

Also:

  • The page is 100dvh tall, so it no longer runs under the address bar.
  • inset is replaced by top/right/bottom/left, since Safari before iOS 14.5 ignores inset.
  • The status text wraps.
  • An iPhone has no element fullscreen (only video), so tapping the button threw an error. It's hidden there now. The webkit calls cover iPads.

Checked in headless Chrome at 375 and 320 px wide, and at 1280 px, where the desktop header is unchanged.

iOS rendering

WebGL2 filters 32-bit float textures linearly only with OES_texture_float_linear, and iOS Safari lacks it. There, a linearly filtered 32F texture is incomplete and samples as zero.

  • Near clouds and the sea: cloud_sky's near volumes and wave_sea's volume now take byte voxels, through new VolumeNode::updateScalars overloads for unsigned char. Their transfer functions move to the 0–255 scale. VTK 9.5 uploads float voxels as GL_R32F / GL_RG32F (vtkVolumeTexture::SelectTextureFormat). The far cloud slices (VolSliceNode) already used bytes for this reason.
  • Shadow map: the sun's shadow map (R32F) samples NEAREST. In calcShadow a zero read means "nothing drawn here", so on iOS nothing was ever in the sun's shadow. That flat lighting is a likely cause of the washed-out look. Each of the 16 taps is compared on its own, so the soft edge never came from the filter.
  • Not covered: VTK's own transfer-function tables (vtkOpenGLVolumeLookupTable) are R32F / RGB32F textures, filtered linearly whenever the volume interpolates linearly. The fix belongs inside VTK's volume mapper. Changing VTK's default float format globally would also turn the float textures VTK uses for vertex data into 16-bit floats, so this PR doesn't do that.

Diagnostics

  • ?gldiag on any demo page (e.g. cvcgl/arigl/?gldiag) shows a WebGL2 report instead of the demo. It lists the renderer, the float extensions and the fragment shader precision. It also renders a 2×1 texture holding 0 and 1 to test whether R8, R16F, R32F, RG32F and RGB32F filter linearly (0.50 = ok, 0.00 = unfilterable). One screenshot from an iPhone settles which of these it supports.
  • ?nofloatlinear hides OES_texture_float_linear before the demo creates its context, so a desktop renders as such a device would. With the same patch applied by hand to the current live build, the terrain lab's near clouds vanish and the sky goes paler. They vanish here rather than turning black, so the black clouds on the iPhone are not explained yet.

Tests

  • cvcgl_ariadne_realize checks wave_sea's byte voxels and that its transfer function ends at 255.
  • Ran locally (MSVC Release): cvcgl_ariadne_realize, cvcgl_shadow_volume, cvcgl_shadow_casters, cvcgl_shadow_caster_growth, cvcgl_shadow_pass_programs, cvcgl_shadow_pass_reuse, cvcgl_city_sun_shadows, cvcgl_volume_range: all pass.
  • Native renders: terrain_lab (near clouds) and lsystem_forest (sea, tree shadows) look as before.
  • Not checked: an iPhone itself, and this build in a browser (that waits for a deploy).

…map; ?gldiag and ?nofloatlinear

Phone layout (examples/web/templates/demo.html.in):
- At phone width or on a touch screen, the title, the demo picker and the Fullscreen icon share
  one line, with a short touch hint on a second. The long description and the keyboard keys had
  been squeezed into a narrow column about 690 px tall at 375 px wide, half the screen.
- The page is 100dvh tall, so it no longer runs under a phone's address bar.
- top/right/bottom/left in place of `inset`, which Safari before iOS 14.5 ignores.
- An iPhone has no element fullscreen, so the button is hidden there rather than throwing on a
  tap. The webkit-prefixed calls cover iPads.

iOS rendering: WebGL2 filters 32-bit float textures linearly only with OES_texture_float_linear,
which iOS Safari lacks. There a linearly filtered 32F texture is incomplete and samples as zero.
- cloud_sky's near volumes and wave_sea's volume take byte voxels (new VolumeNode::updateScalars
  overloads for unsigned char), with their transfer functions on the 0-255 scale. VTK uploads
  float voxels as R32F / RG32F.
- The sun's shadow map (R32F) samples NEAREST. A zero read is "nothing drawn here" in calcShadow,
  so on iOS nothing was ever in shadow. Each of its taps is compared on its own, so the soft edge
  never came from the filter.
- Not covered: VTK's own transfer-function tables are 32F textures, filtered linearly when the
  volume interpolates linearly. That needs a change inside VTK's volume mapper.

Diagnostics:
- ?gldiag on a demo page shows a WebGL2 report instead of the demo: the renderer, the float
  extensions, the shader precision, and whether R8, R16F, R32F, RG32F and RGB32F filter linearly.
- ?nofloatlinear hides OES_texture_float_linear before the demo starts, so a desktop renders as
  a device without it would. On the current build it makes the terrain lab's near clouds vanish.

Tests: cvcgl_ariadne_realize checks wave_sea's byte voxels and byte-scale transfer function.
@transfix
transfix enabled auto-merge (squash) November 12, 2026 12:18
@transfix
transfix merged commit b745ea6 into master Nov 12, 2026
31 of 33 checks passed
@transfix
transfix deleted the fix/mobile-header-ios-float branch November 12, 2026 20:18
transfix added a commit that referenced this pull request Nov 12, 2026
ci.yml's sanitizer test list keeps this branch's stream_test, net_ws_client_test and ariadne_host_test and master's contour_stack_test. The allowlist ratchet (#1152) passes: against master the list only loses the open-url clock's line.
transfix added a commit that referenced this pull request Nov 13, 2026
package-linux / libcvc-release-grpc failed only in tools/singleton_scan, on
cvc::ocean::sea_surface::source's thread_local. The run tested a merge with master b745ea6,
from before #1181 (29ff406) took that thread_local out, and a rerun would test the same
merge. Master since then: #1156, #1153, #1166, #1181, #1165. No conflicts.
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