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

TSL: Add function for BPCEM. #29773

Merged
merged 3 commits into from
Oct 30, 2024
Merged

TSL: Add function for BPCEM. #29773

merged 3 commits into from
Oct 30, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Oct 30, 2024

Related issue: #15897

Description

This PR introduces a helper function for using box projected cube environment mapping (BPCEM) for cube textures and PMREMs. This is a nice feature when using environment maps in indoor scenes.

See https://devlog-martinsh.blogspot.com/2011/09/box-projected-cube-environment-mapping.html.

We had this feature in the repository in earlier days as an example but eventually removed it since the shader patching approach was error-prone and broke the demo more than once. Now with TSL we can implement this feature in a much more elegant fashion. There is now the TSL functiongetParallaxCorrectNormal() which can be used to compute custom uvs when using cubeTexture() or pmremTexture().

@Mugen87 Mugen87 added this to the r170 milestone Oct 30, 2024
@Mugen87 Mugen87 changed the title TSL: Add function for computing BPCEMs. TSL: Add function for computing BPCEM. Oct 30, 2024
@Mugen87 Mugen87 changed the title TSL: Add function for computing BPCEM. TSL: Add function for BPCEM. Oct 30, 2024
Copy link

github-actions bot commented Oct 30, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 691.67
171.43
691.67
171.43
+0 B
+0 B
WebGPU 820.87
221.46
821.32
221.61
+444 B
+144 B
WebGPU Nodes 820.38
221.33
820.83
221.48
+444 B
+150 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 463.82
112.17
463.82
112.17
+0 B
+0 B
WebGPU 541.7
146.38
541.7
146.38
+0 B
+0 B
WebGPU Nodes 497.7
136.21
497.7
136.21
+0 B
+0 B

@sunag
Copy link
Collaborator

sunag commented Oct 30, 2024

Wow! It's so easy to use now.

@sunag sunag merged commit 732bc2a into mrdoob:dev Oct 30, 2024
12 checks passed
@mrdoob
Copy link
Owner

mrdoob commented Oct 31, 2024

/fyi @spite @sneha-belkhale

@@ -354,6 +354,7 @@
"webgpu_materials_arrays",
"webgpu_materials_basic",
"webgpu_materials_displacementmap",
"webgpu_materials_envmaps_bpcem",
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about a different name, for clarity?

webgpu_materials_envmaps_box_projected

Similar to

webgl_materials_envmaps_ground_projected

(The latter is currently missing an underscore.)

Copy link
Collaborator Author

@Mugen87 Mugen87 Nov 2, 2024

Choose a reason for hiding this comment

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

webgl_materials_envmaps_ground_projected

I think this should be webgl_skybox_ground_projected. This example is not related to the envMap material property.

Regarding the new example, I don't feel strong about the name. BPCEM is a similar term like PMREM which is why I like and picked it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Whatever you prefer is OK with me... I thought the acronym may be unfamiliar.

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.

4 participants