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

WebGLRenderer: Add support for WEBGL_render_shared_exponent. #27992

Merged
merged 4 commits into from
Mar 26, 2024

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

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.

@Mugen87 Mugen87 merged commit c13299f into mrdoob:dev Mar 26, 2024
12 checks passed
@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