Skip to content

WebGLRenderer: Add support for packed normal maps.#33055

Merged
Mugen87 merged 4 commits into
mrdoob:devfrom
Ludicon:webgl-packed-normals
Feb 25, 2026
Merged

WebGLRenderer: Add support for packed normal maps.#33055
Mugen87 merged 4 commits into
mrdoob:devfrom
Ludicon:webgl-packed-normals

Conversation

@castano

@castano castano commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Previous PRs added support for packed RG normal maps to the WebGPU backend:

#31695
#32308

This PR extends that support to the WebGL backend by adding a packedNormalMap parameter to the fragment shader. This defines USE_PACKED_NORMALMAP and adds the necessary shader code to normal_fragment_maps. The parameter is set when the format of the textures bound to the normal map type is one of the packed format types (RGFormat, RG11_EAC_Format, or RED_GREEN_RGTC2_Format).

This also updates an incorrect webgl test, which used packed normal maps and did not shade them correctly due to the missing normal reconstruction code.

This contribution is funded by Ludicon

@github-actions

github-actions Bot commented Feb 23, 2026

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 359.17
85.24
359.48
85.34
+311 B
+98 B
WebGPU 626.44
174.13
626.44
174.13
+0 B
+0 B
WebGPU Nodes 625.02
173.88
625.02
173.88
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 490.91
119.65
491.22
119.74
+310 B
+87 B
WebGPU 700.07
189.13
700.07
189.13
+0 B
+0 B
WebGPU Nodes 649.27
176.49
649.27
176.49
+0 B
+0 B

@castano

castano commented Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

@Mugen87 I think the CI error is unrelated to this change. Let me know if you think that's not the case and I'll investigate.

@Mugen87

Mugen87 commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator

A rerun solved the CI issue 🎉 .

I'm okay with this change but I would like to hear the feedback of @donmccurdy because he was involved in the initial discussion.

@donmccurdy Are you okay with supporting packed normal maps like proposed in WebGLRenderer?

@Mugen87 Mugen87 added this to the r184 milestone Feb 25, 2026
@Mugen87

Mugen87 commented Feb 25, 2026

Copy link
Copy Markdown
Collaborator

Oh wait, I see now he has given a heart to the PR. In this case, I assume he is fine with the change 😅 .

@Mugen87 Mugen87 merged commit aa06320 into mrdoob:dev Feb 25, 2026
15 of 16 checks passed
@Mugen87 Mugen87 changed the title Add support for packed normal maps in WebGL backend. WebGLRenderer: Add support for packed normal maps. Feb 25, 2026
@Mugen87

Mugen87 commented Feb 25, 2026

Copy link
Copy Markdown
Collaborator

This PR extends that support to the WebGL backend

BTW: You have changed WebGLRenderer with this PR, not the WebGL backend of WebGPURenderer. That is located in src/rendereres/webgl-fallback.

The WebGL backend of WebGPURenderer already supports packed normals.

@donmccurdy

Copy link
Copy Markdown
Collaborator

Looks good to me, yes — thanks @castano and @Mugen87!

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