Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
UnsignedShort4444Type,
UnsignedShort5551Type
} from '../constants.js';
import { Color } from '../math/Color.js';
import { Frustum } from '../math/Frustum.js';
import { Matrix4 } from '../math/Matrix4.js';
import { Vector3 } from '../math/Vector3.js';
Expand Down Expand Up @@ -174,6 +175,9 @@ class WebGLRenderer {
const _currentScissor = new Vector4();
let _currentScissorTest = null;

const _currentClearColor = new Color( 0x000000 );
let _currentClearAlpha = 0;

//

let _width = canvas.width;
Expand Down Expand Up @@ -1359,6 +1363,11 @@ class WebGLRenderer {

const currentRenderTarget = _this.getRenderTarget();
_this.setRenderTarget( _transmissionRenderTarget );

_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.


_this.clear();

// Turn off the features which can affect the frag color for opaque objects pass.
Expand Down Expand Up @@ -1409,6 +1418,8 @@ class WebGLRenderer {

_this.setRenderTarget( currentRenderTarget );

_this.setClearColor( _currentClearColor, _currentClearAlpha );

_this.toneMapping = currentToneMapping;

}
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shaders/ShaderChunk/output_fragment.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ diffuseColor.a = 1.0;

// https://github.com/mrdoob/three.js/pull/22425
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha + 0.1;
diffuseColor.a *= material.transmissionAlpha;
#endif

gl_FragColor = vec4( outgoingLight, diffuseColor.a );
Expand Down