Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Mar 25, 2024

Related issue: #27971

Description

The renderer now supports WEBGL_render_shared_exponent so the internal format RGB9_E5 can be used. The idea is to pack float data via gl.UNSIGNED_INT_5_9_9_9_REV into Uint32Array. We have to add THREE.RGBFormat back for that.

A minimal data texture setup with THREE.RGBFormat and the new THREE.UnsignedInt5999Type type looks like so:

const data = new Uint32Array( 4 * 4 );
	
const texture = new THREE.DataTexture( data, 4, 4 );
texture.format = THREE.RGBFormat;
texture.type = THREE.UnsignedInt5999Type;

/cc @elalish

Related: https://stackoverflow.com/q/55692758/5250847

@github-actions
Copy link

github-actions bot commented Mar 25, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
671 kB (166.3 kB) 671.2 kB (166.4 kB) +222 B

🌳 Bundle size after tree-shaking

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

Filesize dev Filesize PR Diff
450.9 kB (108.9 kB) 451.1 kB (109 kB) +163 B

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Mar 25, 2024

As mentioned in #27971 (comment), I think we can try the computations of https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_shared_exponent.txt to figure out a helper method that converts three RGB floats (FP32) into a single packed Uint32.

@Mugen87 Mugen87 added this to the r163 milestone Mar 26, 2024
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Mar 26, 2024

The last two commits also add support to WebGPURenderer for both WebGPU and WebGL backend.

@elalish
Copy link
Contributor

elalish commented Mar 26, 2024

@lexaknyazev - thanks for pointing me to WEBGL_render_shared_exponent; I mentioned it to Three.js and they've already adopted it.

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