-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
ShaderChunk: Modulate transmission.a with transmissionFactor #22473
Conversation
@@ -27,6 +27,6 @@ export default /* glsl */` | |||
attenuationTint, attenuationDistance ); | |||
|
|||
totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor ); | |||
transmissionAlpha = transmission.a; | |||
transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what's happening here, but I love the result!
By the way, this is how it would look like without the With the hack: @elalish what do you think? |
The hack looks like it's definitely doing the right thing. The color seems pretty faint; are you sure it should be so low at 0.1? What happens adversely when it's raised? |
May try to modulate with the reflection too... some other day 😇 |
I would revert these hacks. It makes testing of new features difficult. This approach is not going to work, because the CSS background needs to be attenuated by the material color. I expect the only way to possibly do this is to pass a screenshot of the CSS background as a uniform to the shader. |
Does it have an effect when the canvas is not set to use alpha? The idea was that it would be constrained only to changing the transparent canvas situation. You're absolutely right that there's no physical way to do this, but I think it's still important to make a best effort: #22425 (comment) |
Actually, I was not concerned about being physically correct. I was concerned about being remotely correct. :-) |
Unfortunately it's not possible to take a screenshot of the css background. So we are trying to get something that looks decent. But I think this code should only affect cases where |
Sorry, I can not comprehend this code, so I do not know what the hacks are doing. export default /* glsl */`
#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
// https://github.com/mrdoob/three.js/pull/22425
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
`; I think the spheres in the test case all have And I really do not want to have to be concerned about these issues while I am trying to fix the remaining deficiencies in the shaders. |
You can ignore this #ifdef OPAQUE
diffuseColor.a = 1.0;
#endif I'm thinking about reverting the This is my understanding: // OPAQUE
material.map.format = THREE.RGBFormat;
material.transparent = false;
// MASK
material.map.format = THREE.RGBAFormat;
// TODO the alpha needs to be used for the mask only
material.alphaTest = alphaCutoff;
material.transparent = false;
// BLEND
material.map.format = THREE.RGBAFormat;
material.transparent = true; |
As far as I understand...
As far as I know, values greater than 1 get clamped. |
// OPAQUE
material.map.format = THREE.RGBFormat;
material.transparent = false; I would tend to agree. Of course, that means no alpha test using // MASK
material.map.format = THREE.RGBAFormat;
// TODO the alpha needs to be used for the mask only
material.alphaTest = alphaCutoff;
material.transparent = false; Maybe to avoid the transparent restriction it may be sufficient to modify the three.js alpha test code so // BLEND
material.map.format = THREE.RGBAFormat;
material.transparent = true; Yes, I think so. Maybe we need is a |
Based on above, they also control the blending function in three.js |
Do you mean that if |
Yes. It is my understanding that is what the spec calls for -- when using MASK, set alpha to 1. When using alpha test with normal blending, then perhaps what we are doing now is OK -- leaving non-discarded alpha as-is. |
Related issue: #22425
Description
/cc @elalish