Skip to content

Conversation

RenaudRohlinger
Copy link
Collaborator

Description

There is an inconsistency between WebGL and WebGPU, where ImageBitmap textures are unflipped by default.
In WebGL 2.0, gl.UNPACK_FLIP_Y_WEBGL has no effect on ImageBitmap uploads, so we cannot flip the texture during upload.
To resolve this, I added a condition in TextureNode to flip the UV for ImageBitmap, similar to how we handle sampler textures.

This contribution is funded by Utsubo

@RenaudRohlinger RenaudRohlinger added this to the r171 milestone Nov 12, 2024
Copy link

github-actions bot commented Nov 12, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.37
79.06
339.37
79.06
+0 B
+0 B
WebGPU 477.54
132.4
477.59
132.42
+48 B
+26 B
WebGPU Nodes 477.01
132.28
477.06
132.31
+48 B
+26 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 464.82
112.02
464.82
112.02
+0 B
+0 B
WebGPU 546.58
148.07
546.62
148.09
+48 B
+19 B
WebGPU Nodes 502.46
137.76
502.5
137.79
+48 B
+24 B

@RenaudRohlinger
Copy link
Collaborator Author

RenaudRohlinger commented Nov 12, 2024

Seems like the issue doesn't happen with ImageBitmaps loaded with the GLTFLoader, this PR breaking a bunch of examples, is there any extra step being done to align BitmapImage between WebGPU and WebGL @sunag?

@RenaudRohlinger RenaudRohlinger removed this from the r171 milestone Nov 12, 2024
@sunag
Copy link
Collaborator

sunag commented Nov 12, 2024

This area is destined to flip-y frame-buffers, for external textures I recommend check here:

this._flipY( textureGPU, textureDescriptorGPU, originDepth );

@sunag
Copy link
Collaborator

sunag commented Nov 13, 2024

My previous answer is a bit out of context. Could you test again?

@RenaudRohlinger
Copy link
Collaborator Author

Can confirm that now both backends are aligned with flipY true and false!
image

@sunag sunag added this to the r171 milestone Nov 13, 2024
@sunag sunag merged commit 20c67d6 into mrdoob:dev Nov 13, 2024
12 checks passed
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.

2 participants