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

Improve transmission when background is transparent #26003

Closed
wants to merge 1 commit into from

Conversation

WestLangley
Copy link
Collaborator

Follow-on to #25881.

Transmission, as implemented in three.js, requires either opaque scene objects, a skybox, or an opaque scene background to serve as a source of light.

Light is transmitted and attenuated from behind the model towards the camera. If there is no light, there is no color.

Consequently, the rendering will be incorrect if the background is transparent. It will also be incorrect even if there is a CSS background, since the CSS background is not accessible to the renderer.

This workaround ensures a background is present during the transmission calculation to serve as a source of light.

@github-actions
Copy link

github-actions bot commented May 7, 2023

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
637 kB (157.9 kB) 637.1 kB (157.9 kB) +128 B

🌳 Bundle size after tree-shaking

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

Filesize dev Filesize PR Diff
427.3 kB (103.7 kB) 427.4 kB (103.7 kB) +128 B


_this.getClearColor( _currentClearColor );
_currentClearAlpha = _this.getClearAlpha();
if ( _currentClearAlpha < 1 ) _this.setClearColor( 0x7f7f7f, 0.8 );
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Based on my experiments, values greater than 0x7f7f7f are too bright. This seems to be a good compromise.

The clear alpha value of 0.8 allows the CSS background to show through when the scene background is transparent. This is a subjective value.

@WestLangley WestLangley modified the milestone: r153 May 12, 2023
@WestLangley WestLangley deleted the dev-transmission branch July 8, 2023 18:18
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.

1 participant