-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
NodeMaterial: Honor material.premultipliedAlpha
in the shader
#31166
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
base: dev
Are you sure you want to change the base?
NodeMaterial: Honor material.premultipliedAlpha
in the shader
#31166
Conversation
material.premultipliedAlpha
in the shader
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
The E2E screenshot of |
Since |
Well, yes, but maybe you misunderstand what its purpose is...
In the case of built-in materials, the shader itself must also be modified to return premultiplied values instead of non-premultiplied values. So built-in materials and custom materials are different in this regard. Unfortunately, |
Yeah, the double purpose of The node material seems a good opportunity to establish a policy that produce more consistent outputs no matter if you customize a material or not. AFAICS, if the developer needs full control, it's always possible to use custom blending, don't change |
Consider this use case: renderer.setRenderTarget( renderTarget );
renderer.render( scene, camera ); In such a case, Now, use the render target texture as a map: const material = new THREE.MeshBasicMaterial( {
map: rederTarget.texture
} ); The material shader will outut premultiplied colors, but the renderer will use the wrong blending function. So, try this instead: const material = new THREE.MeshBasicMaterial( {
map: rederTarget.texture,
premultipliedAlpha: true
} ); Now this is wrong because the shader will pre-multiply the colors a second time. |
As the title says.
The alternative is to only add this code block in the built-in (node) materials -- as we do with
WebGLRenderer's
built-in materials.