bevyengine / bevyengine/bevy

Bevy Fails to Validate Cubemap Texture - Too many mipmap levels

Open
#19,369 0 comments 0 reactions 0 assignees View on GitHub
A-Assets A-Rendering C-Bug S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

0.16

## Relevant system information

M3 Max

```2025-05-26T02:36:31.390446Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "macOS 15.5 Sequoia", kernel: "24.5.0", cpu: "Apple M3 Max", core_count: "16", memory: "64.0 GiB" }
2025-05-26T02:36:32.253835Z INFO bevy_render::renderer: AdapterInfo { name: "Apple M3 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
```

## What you did

I'm trying to add a skybox to my game (Attached) I'm following the same png example as a vertical atlas.

It gets pre-processed into a KTX2 Texture.

Whenever I try to reinterpret it as a 3D texture I get:
wgpu error: Validation Error
```
Caused by:
In Device::create_texture
Texture descriptor mip level count 13 is invalid, maximum allowed is 11
```

This is the system that mounts/reinterprets the skybox image:
```rs
fn attach_skybox_to_camera(
cam: Single>,
mut cmds: Commands,
ec_assets: Res,
mut images: ResMut>,
) {
let Some(image) = images.get_mut(ec_assets.skybox.id()) else {
info!("Couldn't get image asset");
return;
};

// NOTE: PNGs do not have any metadata that could indicate they contain a cubemap texture,
// so they appear as one texture. The following code reconfigures the texture as necessary.
if image.texture_descriptor.array_layer_count() == 1 {
info!("Ahh? {}/{}={}", image.height(), image.width(), image.height()/image.width());
image.reinterpret_stacked_2d_as_array(image.height() / image.width());
image.texture_view_descriptor = Some(TextureViewDescriptor {
dimension: Some(TextureViewDimension::Cube),
..default()
});
}

let sbox = Skybox {
image: ec_assets.skybox.clone(),
brightness: 1000.0,
..default()
};

cmds.entity(*cam).insert(sbox);
}
```

Other things I've tried but still got a mip map error:
- I tried just making the image smaller (512x3072) and it seems to just lower the limit,
- Disabled the Default Image Saver for PNG & deleted imported_assets folder,
- Tried different images - i.e. The Ryfjallet_cubemap.png from the bevy examples,
```
Caused by:
In Device::create_texture
Texture descriptor mip level count 12 is invalid, maximum allowed is 10
```

Skybox Image:

![Image](https://github.com/user-attachments/assets/10f4f8ab-7955-476d-a15f-3ade0f9cc787)

Contributor guide

Open the contributing guide

Research direction

Start with the attach_skybox_to_camera function and reproduce the issue using the attached cubemap or the Ryfjallet_cubemap.png example. Follow the image reinterpretation and texture descriptor setup, focusing on the reported mip level count versus the allowed maximum; done means the cubemap validates without the wgpu error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.