pex-renderer icon indicating copy to clipboard operation
pex-renderer copied to clipboard

Alpha blended transmission

Open vorg opened this issue 1 year ago • 2 comments

In the previous version of pex-renderer we could combine transmission with alpha blending and have reflective glass 50% faded out based on baseColor.a opacity. That is no longer possible. Setting alpha blending disables transmission. What does the glTF spec says here?

vorg avatar May 31 '24 09:05 vorg

https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_transmission#blend-mode

The glTF alphaMode is used for alpha-as-coverage, NOT for physically-based transparency (i.e. this extension). If alpha-as-coverage is not being used, the blend mode of the material should be set to "OPAQUE" even though it is transparent. Again, it's helpful to think of alpha-as-coverage as whether the physical surface is there or not. transmission applies to the surface material that exists. Note that alpha-as-coverage can still be used along with transmission as shown in the example below.

But filament and three.js allow alpha:

https://github.com/mrdoob/three.js/blob/f0f0e195e16490dac58520cdae23a9feee7547f5/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js#L31

https://github.com/mrdoob/three.js/blob/f0f0e195e16490dac58520cdae23a9feee7547f5/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js#L7

https://github.com/google/filament/commit/25a82911016e8a9d6917688d530ea54c4d84a5c2

dmnsgn avatar May 31 '24 10:05 dmnsgn

Needs research what would it take to allow alpha so we can e.g. fade out things with transmission.

vorg avatar Jul 02 '25 13:07 vorg