Skip to content

Data size is wrong for cubemaps #12

Description

@expenses

I've been working on a ktx2 to dds converter, mostly because renderdoc works well as a dds viewer but doesn't handle ktx2 files currently. Currently the size of data in Dds structs files created with Dds::new_dxgi and is_cubemap set to true is only the size of one of the cubemap faces.

Luckily, the data field is public so you can manipulate it without using any crate functions. Here's what I'm doing to pub a ktx2 cubemap in the right format:

let face_count = header.face_count as usize;

let mut faces = vec![Vec::new(); face_count];

for level in ktx2.levels() {
    let size = level.bytes.len() / face_count;
    for (i, face) in faces.iter_mut().enumerate() {
        let slice = &level.bytes[i * size..(i + 1) * size];
        face.extend_from_slice(slice);
    }
}

dds.data = faces.concat();

It'd be cool to have a really flexible api for manipulating the dds data. I'm not 100% sure what that'd be like yet though.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions