bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Bevy Fails to Validate Cubemap Texture - Too many mipmap levels

Open Braymatter opened this issue 11 months ago • 0 comments

Bevy version

0.16

Relevant system information

M3 Max

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:

fn attach_skybox_to_camera(
    cam: Single<Entity, With<Camera>>,
    mut cmds: Commands,
    ec_assets: Res<EmbarkationCradleAssets>,
    mut images: ResMut<Assets<Image>>,
) {
    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

Braymatter avatar May 26 '25 02:05 Braymatter