Three.js: GLTFLoader: Alpha mode should default to Blend when material color has transparency

Created on 12 Aug 2020  路  6Comments  路  Source: mrdoob/three.js

Description of the problem

Some software exports GLTFs without setting alpha mode, even in materials with transparency. Blender correctly renders these materials as transparent, but the GLTFLoader defaults to opaque even when an alpha < 1.0 is specified in the material.

Suggested solution

When alpha < 1.0, if no alphaMode is specified, default to BLEND rather than OPAQUE.

Question

Most helpful comment

I fail to see the logic behind defaulting to opaque when a material is clearly transparent

It is not always so clear. Transparency can be set in the alpha channel of the texture. The loader is not expected to discern that.

All 6 comments

The glTF specification is pretty specific that when alphaMode=OPAQUE, any transparency in the baseColorTexture or baseColorFactor must be ignored by implementations. I think it would be necessary to report bugs to software exporting alpha < 1, without setting alpha mode. Do you have an example?

Yes, OnShape does not appear to be setting the flag when exporting.

When alpha < 1.0, if no alphaMode is specified, default to BLEND rather than OPAQUE.

According to glTF spec 2.0, the alphaMode property specifies how alpha is interpreted -- not the other way around.

Also, alphaMode is not required, and defaults to OPAQUE.

Thanks. Sounds like the implementation in the loader conforms to the spec then. I fail to see the logic behind defaulting to opaque when a material is clearly transparent, but that is a question for a different forum.

I fail to see the logic behind defaulting to opaque when a material is clearly transparent

It is not always so clear. Transparency can be set in the alpha channel of the texture. The loader is not expected to discern that.

Yes, good point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filharvey picture filharvey  路  3Comments

seep picture seep  路  3Comments

Bandit picture Bandit  路  3Comments

yqrashawn picture yqrashawn  路  3Comments

zsitro picture zsitro  路  3Comments