Skip to content

Conversation

@zajkowskie
Copy link
Contributor

@zajkowskie zajkowskie commented Jan 30, 2023

Fixed #25339

Description

Problem : Wrong mipmaps size (width and height) after KTX2Loader
Solution : Changed mipWidth and mipHeight to transcoded values.

@Mugen87 Mugen87 added this to the r150 milestone Jan 30, 2023
@Mugen87 Mugen87 changed the title Ktx2 loader mipmaps width height fix KTX2Loader: Fix mipmaps width and height. Jan 30, 2023
@donmccurdy
Copy link
Collaborator

donmccurdy commented Jan 31, 2023

Something odd is happening on the webgl_loader_gltf_compressed example. It renders fine, but a bunch of warnings appear in the console:

GL_INVALID_VALUE: Offset overflows texture dimensions.

The only reason I can see is that origWidth/origHeight and width/height differ on the smallest mips:

mip width x height origWidth x origHeight
7 4 ⨉ 4 4 x 4
8 4 ⨉ 4 ⚠️ 2 x 2
9 4 x 4 ⚠️ 1 x 1

I'm not sure what WebGL expects. Maybe we need something more like this?

mipWidth = levelInfo.origWidth < 4 ? levelInfo.origWidth : levelInfo.width;
mipHeight = levelInfo.origHeight < 4 ? levelInfo.origHeight : levelInfo.height;

It should be safe to assume 4x4 blocks for current BasisU codecs.

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 10, 2023

Updated the PR with the code of #25375 (comment).

https://rawcdn.githack.com/zajkowskie/three.js/ebf6dfe327efc9d5bf1819e5e880ce2ed2971123/examples/webgl_loader_texture_ktx2.html
https://rawcdn.githack.com/zajkowskie/three.js/ebf6dfe327efc9d5bf1819e5e880ce2ed2971123/examples/webgl_loader_gltf_compressed.html

It seems the WebGL warning in webgl_loader_gltf_compressed is now gone.

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.

KTX2Loader exmaple - Transcode wrong mipmaps size

3 participants