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

Nodes: Add CubeMapNode. #29073

Merged
merged 1 commit into from
Aug 7, 2024
Merged

Nodes: Add CubeMapNode. #29073

merged 1 commit into from
Aug 7, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Aug 6, 2024

Related issue: -

Description

WebGPURenderer must be able to automatically convert equirectangular textures into the cube map format. This is now done by a new utility class CubeMapNode. Similar to PMREMNode, this class is intended to setup the environment map for materials and later the background (see #28827).

Copy link

github-actions bot commented Aug 6, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
685.1 kB (169.6 kB) 685.1 kB (169.6 kB) +0 B

🌳 Bundle size after tree-shaking

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

Filesize dev Filesize PR Diff
462 kB (111.5 kB) 462 kB (111.5 kB) +0 B


const _cache = new WeakMap();

class CubeMapNode extends TempNode {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sunag This module should be for internal use only so it is not exported in Nodes.js. Still, I'm a bit unsure about the name CubeMapNode since its quite similar to CubeTextureNode.

CubeMapNode should be in some sense the non-PBR version of PMREMNode. Meaning it encapsulate different inputs to provide a single environment map format for the material.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if we need this, wouldn't just manipulating the UV be enough since we don't need to pre-filter for non-PBR?

import { texture, equirectUV, reflectVector, refractVector } from 'three/ts';

const coord = reflectVector; // refractVector 
const env = texture( textureEquirec, equirectUV( coord ) );

Copy link
Collaborator Author

@Mugen87 Mugen87 Aug 7, 2024

Choose a reason for hiding this comment

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

The problem with using equirectangular uvs are the artifacts that result at the poles which do not occur with the cube map format. They were previously reported as bugs which was one reason for not directly supporting equirectangular textures in the shader.

I'm afraid users will complain when the artifacts appear again when migrating from WebGLRenderer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting, if so let's merge the PR, it seems good to me.

@sunag sunag merged commit 6f29b25 into mrdoob:dev Aug 7, 2024
12 checks passed
@Mugen87 Mugen87 added this to the r168 milestone Aug 7, 2024
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