Skip to content
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

GLTFLoader: Texture alpha should be ignored on opaque materials #15483

Closed
0b5vr opened this issue Dec 28, 2018 · 33 comments · Fixed by #18579 or #18631
Closed

GLTFLoader: Texture alpha should be ignored on opaque materials #15483

0b5vr opened this issue Dec 28, 2018 · 33 comments · Fixed by #18579 or #18631

Comments

@0b5vr
Copy link
Collaborator

0b5vr commented Dec 28, 2018

In GLTFLoader we can load standard materials using StandardMaterial .
However, the alpha channel of its texture doesn't be handled properly, when renderer's alpha is activated.

In OPAQUE or MASK material, alpha channels of texture should be negated:
https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#alpha-coverage

Change the material's blend mode to ZERO-ONE (in GLTFLoader) might solve this problem?

This is how it should be (rendered in Unity):

image

Here's how it looks like in Three.js GLTFLoader:

default

This is the source code:
https://github.com/FMS-Cat/cube-gradient-alpha

Environment:

  • Three.js version: r99
  • Browser: Confirmed in Chrome, Firefox, Edge
  • OSes: Windows. Has not tested in other env
  • Hardware: Probably no requirements
@mrdoob mrdoob added this to the r101 milestone Dec 28, 2018
@donmccurdy
Copy link
Collaborator

Have you checked that modifying the material's blend mode fixes the problem? You can do that after the model is returned from the loader:

gltf.scene.traverse((o) => {
  if (o.isMesh) {
    o.material.blending = THREE.CustomBlending;
    // ...
  }
});

If this is a setting that GLTFLoader should be applying only when the renderer's alpha property is enabled, a loader can't really know when to do that. :/

@0b5vr
Copy link
Collaborator Author

0b5vr commented Jan 3, 2019

Wait uh I thought alpha is going to always be 1 regardless of map's alpha value under the ZERO-ONE blending settings... ._.
I just noticed the problem is harder one...
Priority is kinda low but we probably need to tweak our standard shader (or entire Three.js shaderchunks) to make it enable to negate all the alpha value

@donmccurdy
Copy link
Collaborator

I'm afraid I don't understand the issue — why do the texture's alpha values need to be negated? The link you gave to the Alpha Coverage section of the spec doesn't mention this.

In your sample source repository, which of the two models are you talking about?

@0b5vr
Copy link
Collaborator Author

0b5vr commented Jan 6, 2019

Bleh I might have picked wrong words, negated -> ignored (I have a disability to my English)

@0b5vr
Copy link
Collaborator Author

0b5vr commented Jan 6, 2019

You mean, we should treat the alpha as a "fourth component of the output" even if it's fully "OPAQUE"? That sounds pretty weird for me...
I thought "rendered output is fully opaque" means output alpha is always 1.0 .

In your sample source repository, which of the two models are you talking about?

cube-gradient-alpha.glb , has an alpha channel on its material.pbrMetallicRoughness.baseColorTexture but its material.alphaMode is OPAQUE . (Yes I'm talking about weird case)

@mrdoob mrdoob modified the milestones: r101, r102 Jan 31, 2019
@mrdoob mrdoob modified the milestones: r102, r103 Feb 28, 2019
@donmccurdy donmccurdy changed the title GLTFLoader: Materials should handle alpha channel properly GLTFLoader: Base color alpha channel should be ignored on opaque materials Mar 3, 2019
@donmccurdy donmccurdy changed the title GLTFLoader: Base color alpha channel should be ignored on opaque materials GLTFLoader: Texture alpha should be ignored on opaque materials Mar 3, 2019
@mrdoob mrdoob modified the milestones: r103, r104 Mar 27, 2019
@mrdoob mrdoob modified the milestones: r104, r105 Apr 24, 2019
@mrdoob mrdoob modified the milestones: r105, r106 May 30, 2019
@mrdoob mrdoob modified the milestones: r106, r107 Jun 26, 2019
@mrdoob mrdoob modified the milestones: r107, r108 Jul 31, 2019
@mrdoob mrdoob modified the milestones: r108, r109 Aug 27, 2019
@mrdoob mrdoob modified the milestones: r109, r110 Sep 25, 2019
@mrdoob mrdoob modified the milestones: r110, r111 Oct 30, 2019
@mrdoob mrdoob added this to the r122 milestone Sep 29, 2020
@mrdoob mrdoob modified the milestones: r122, r123 Oct 28, 2020
@mrdoob mrdoob modified the milestones: r123, r124 Nov 25, 2020
@mrdoob mrdoob modified the milestones: r124, r125 Dec 24, 2020
@mrdoob mrdoob modified the milestones: r125, r126 Jan 27, 2021
@mrdoob mrdoob modified the milestones: r126, r127 Feb 23, 2021
@mrdoob mrdoob modified the milestones: r127, r128 Mar 30, 2021
@mrdoob mrdoob modified the milestones: r128, r129 Apr 23, 2021
@mrdoob mrdoob modified the milestones: r129, r130 May 27, 2021
@mrdoob mrdoob modified the milestones: r130, r131 Jun 30, 2021
@mrdoob mrdoob modified the milestones: r131, r132 Jul 28, 2021
@mrdoob mrdoob closed this as completed Aug 25, 2021
@mrdoob mrdoob removed this from the r132 milestone Aug 25, 2021
@mrdoob
Copy link
Owner

mrdoob commented Aug 25, 2021

Better late than never™ #22424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
@mrdoob @WestLangley @elalish @donmccurdy @0b5vr @Mugen87 and others