Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add THREE.CompressedCubeTexture #26369

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

donmccurdy
Copy link
Collaborator

@donmccurdy donmccurdy commented Jul 4, 2023

Related:

Adds a THREE.CompressedCubeTexture class, and updates THREE.KTX2Loader to use it where appropriate. This resolves issues discussed in #25909, where the renderer failed to recognize 'synthetic' compressed cube textures in some cases.

I've kept the constructor signature simple, at least for the time being:

constructor( images, format, type ) { ... }

Tested against the texture below:

pisa.ktx2.zip

The texture was generated from our Pisa PNG cubemap, with the KTX-Software v4.3 alpha release. I ran into an issue with the alpha release, tracked in KhronosGroup/KTX-Software#728, but in future stable releases the command below should work as-is:

ktx create --cubemap --format R8G8B8_SRGB --encode uastc --assign-oetf srgb \
  px.png nx.png py.png ny.png pz.png nz.png pisa.ktx2

@github-actions
Copy link

github-actions bot commented Jul 4, 2023

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
643.1 kB (159.5 kB) 643.3 kB (159.5 kB) +179 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
436.4 kB (105.6 kB) 436.4 kB (105.6 kB) +0 B

@Mugen87 Mugen87 added this to the r155 milestone Jul 4, 2023
@Mugen87 Mugen87 merged commit 4a7c241 into mrdoob:dev Jul 5, 2023
@donmccurdy donmccurdy deleted the feat/CompressedCubeTextureLoader branch July 5, 2023 11:36
@Methuselah96 Methuselah96 mentioned this pull request Jul 13, 2023
9 tasks

constructor( images, format, type ) {

super( undefined, images[ 0 ].width, images[ 0 ].height, format, type, CubeReflectionMapping );
Copy link
Contributor

@Methuselah96 Methuselah96 Dec 5, 2023

Choose a reason for hiding this comment

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

@donmccurdy Would it work to pass in [] for mipmaps instead of undefined? I'm working on the types for this. If taken strictly, Texture.mipmaps and CompressedTexture.mipmaps would now need to be ImageData[] | undefined instead of ImageData[], which is more disruptive of a change for the users of the types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe it's correct that the .mipmaps property is a non-nullable array, but not safe to pass an empty array up to the constructor here... I would just assume that mipmaps gets populated correctly during texture initialization, and not make the property nullable in the TS definitions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, thanks, good to know. For my own education, where do the mipmaps end up getting set for the CompressedCubeTexture in KTX2Loader?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see mipmaps getting set for other textures in createRawTexture, but don't do something similar in _createTextureFrom where CompressedCubeTexture is used.

Copy link
Collaborator Author

@donmccurdy donmccurdy Dec 5, 2023

Choose a reason for hiding this comment

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

You can see where it would be set in #26642, but I can't promise that KTX2Loader sets up all texture types correctly today. Constructing compressed array, cube, and 3D textures is not a fully-documented API, and we don't have many test cases for it, so I'm kind of trial-and-erroring my through this part. Maybe once #26642 is working we'll have a better idea how to construct textures for each of these cases...

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.

3 participants