Skip to content

feat(WebGPU): support cube map textures on the diffuse texture - #3669

Open
daker wants to merge 1 commit into
Kitware:masterfrom
daker:webgpu-cubetexture
Open

daker wants to merge 1 commit into
Kitware:masterfrom
daker:webgpu-cubetexture

Conversation

@daker

@daker daker commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Context

Results

Before After
before after

Changes

Add a cubeMap flag to vtkTexture (setCubeMap/getCubeMap, default false), The static vtkTexture.useCubeMap() decides if a backend uploads the texture as a cube map: the flag is set and the six input ports have image data, or the six ports have image data without the flag. The second case logs a warning one time for each texture. The flag with a missing face logs an error and gives a 2D texture.

WebGL uses useCubeMap() in place of its six input test, so its behavior does not change.

WebGPU uploads the six faces as the six layers of one 2D texture and samples it through a 'cube' view. The rows of each face are reversed to get the same orientation as WebGL. The cube texture has its own cache key, and the pipeline hash includes the view dimension of each texture. Only the diffuse texture asks for the cube map path, because Background and environment lighting sample 2D textures. The fragment shader samples the diffuse cube map with the vec3 texture coordinates when the bound view is a 'cube' view, so the shader always matches the binding.

PR Checklist

  • GitHub Actions CI passed: semantic-release commit messages, lint, and tests
  • Test coverage added
  • Documentation and TypeScript definitions are updated to match these changes

@daker
daker force-pushed the webgpu-cubetexture branch 4 times, most recently from ba3733c to 7f407cf Compare October 4, 2026 01:26
@daker daker mentioned this pull request Oct 4, 2026
49 of 56 tasks
@daker
daker force-pushed the webgpu-cubetexture branch from 7f407cf to 5ca3398 Compare October 4, 2026 14:31
@daker
daker force-pushed the webgpu-cubetexture branch 2 times, most recently from 828eb15 to 94439ca Compare October 27, 2026 09:08
const hasNormal = code.includes('var normal:');
const ppty = model.WebGPUActor.getRenderable().getProperty();
const needLighting =
ppty.getLighting() &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vtkProperty2D has no getLighting(), and this now runs before the !model.is2D guard.

Add the cubeMap flag to vtkTexture. vtkTexture.useCubeMap() tells a
backend to upload the texture as a cube map. Six faces without the flag
also give a cube map, with a warning. WebGL uses useCubeMap().

In WebGPU, the texture manager uploads the six faces as the six layers
of one 2D texture with a 'cube' view. The rows of each face are flipped
to match WebGL. Only the diffuse texture uses this path. The shader
samples it with the texture coordinates as a vec3 direction. A missing
third component is zero.

Skybox now uses the cube path of the texture manager. This fixes RGB
faces, which Skybox uploaded without RGBA padding.

Other changes:
- Each face of an interpolated cube map gets a mip chain.
- An image larger than the device limit is drawn smaller one time,
  when the texture is made.
- A texture larger than the device limits logs an error, and the
  texture skips all writes.
- RGB data is padded to RGBA only when it is uploaded.
@daker
daker force-pushed the webgpu-cubetexture branch from 94439ca to 95be37f Compare November 9, 2026 11:23

This branch has not been deployed

No deployments
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.

2 participants