question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebGLBakground.setClearColor: Do not set alpha to 1 by default

See original GitHub issue

I had a problem with making a transparent render target correctly. Called setClearAlpha(0) and setClearColor(0x000000) on the active rendertarget, but alpha was then returned to 1 because of the method below (in WebGLBackground). Could it be a better idea to use the value that setClearAlpha saved instead of 1? It might break code where users used a wrong setClearAlpha and the overwrote it with setClearColor by mistake (but with the wanted visual result), making some render targets transparent again when updating three.js.

setClearColor: function ( color, alpha ) {

	clearColor.set( color );
	clearAlpha = alpha !== undefined ? alpha : 1;
	setClear( clearColor, clearAlpha );

}

https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLBackground.js#L210

Three.js version
  • [x ] Dev
  • r120
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
inearcommented, Sep 12, 2020

Sure! Can put some thoughts into a PR, at least as a discussion starter.

1reaction
mrdoobcommented, Sep 11, 2020

You mean doing this, right?

setClearColor: function ( color, alpha ) {

	clearColor.set( color );
	if ( alpha !== undefined ) clearAlpha = alpha;
	setClear( clearColor, clearAlpha );

}
Read more comments on GitHub >

github_iconTop Results From Across the Web

WebGLRenderer#setClearColor – three.js docs
When set to true , the value is 0 . Otherwise it's 1 . Default is false . premultipliedAlpha - whether the renderer...
Read more >
Changing three.js background to transparent or other color
I came across this when I started using three.js as well. It's actually a javascript issue. You currently have: renderer.setClearColorHex( 0x000000, 1 );....
Read more >
WebGLRenderer - Nonfunctional clearColor Parameter #4150
Using the latest version in master (r63), the clearColor parameter does not set the background color as expected.
Read more >
WebGL and Alpha
The default is true. ... A really good way to find if you have any alpha problems is to set the canvas's background...
Read more >
EaselJS v1.0.0 API Documentation : StageGL - CreateJS
If true , the canvas is NOT auto-cleared by WebGL (the spec discourages setting ... If true , this assumes the shader must...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found