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

Alpha is ignored, unless it comes from the same source as BaseColor #1417

Open
j-conrad opened this issue Jun 15, 2021 · 8 comments
Open

Alpha is ignored, unless it comes from the same source as BaseColor #1417

j-conrad opened this issue Jun 15, 2021 · 8 comments
Labels
enhancement New feature or request exporter This involves or affects the export process Material

Comments

@j-conrad
Copy link

Describe the bug
This is almost identical to #1219. Except this still occurs when using a Background node (for exporting an Unlit shader).

To Reproduce
Steps to reproduce the behavior:

  1. Create a plane
  2. Assign a Background node in its shader graph (unlit shader).
  3. Plug an image texture node (with a PNG containing transparency) from the the Color output to the Color input of the Background node.
  4. Plug an image texture node (with a PNG containing transparency) from the Alpha output to the Strength input of the Background node.
  5. Export as .glb and view in any glTF viewer.
  6. RESULT: The alpha is exported.
  7. Now go back and plug ANY OTHER image (or no image) into the BaseColor input of the Background node.
  8. Re-export as .glb and view in any glTF viewer.
  9. RESULT: The alpha does not show.

Expected behavior
Alpha should get exported regardless of the BaseColor network.

Screenshots
This works as expected. (Alpha is exported)
image

This does not work. (Alpha appears to be ignored)
image

.blend file/ .gltf
Attached

Version

  • OS: Windows
  • Blender Version 2.93.0

Additional context

AlphaBackgroundIssue.zip

@julienduroure
Copy link
Collaborator

Confirmed.
This is a known limitation.
Cf comment in code :
image

@julienduroure julienduroure added exporter This involves or affects the export process Material enhancement New feature or request labels Jun 15, 2021
@scurest
Copy link
Contributor

scurest commented Jun 16, 2021

Note that that's not the correct setup for alpha, so it wouldn't work even if the above comment were fixed. Background Strength has nothing to do with alpha and is always ignored. The right setup is (I assume this is what you want the cube to look like)

alpha

@j-conrad
Copy link
Author

j-conrad commented Jun 16, 2021

Note that that's not the correct setup for alpha, so it wouldn't work even if the above comment were fixed. Background Strength has nothing to do with alpha and is always ignored. The right setup is (I assume this is what you want the cube to look like)

Ok. Looks like I missed that in the Blender docs. Any idea why it works then?

Also, I get different results when swapping those two 'Shader' inputs. If the Transparent BSDF is plugged into the upper Shader input, I get transparency. If the Transparent BSDF is plugged into the lower Shader input, I get zero transparency.

@j-conrad
Copy link
Author

I figured it out. I was misunderstanding how that Mix Shader was working, as well as how that Transparent BSDF works.

The behavior I was seeing makes sense. By swapping those Shader inputs, I was effectively changing which one was being affected by the Factor's alpha texture. That, combined with a complex alpha texture, was making it seem more complicated that it actually was.

I still don't quite understand why my first example works though.

@j-conrad
Copy link
Author

j-conrad commented Jun 16, 2021

Ugh... the plot thickens. I should have actually tested your example, @scurest. If you export as you have demonstrated above, that object does have alpha, but the object is just white instead of having the color of the texture that's being input in the lower Shader node. I'm officially very confused again. Maybe because we're sending a COLOR output into a SHADER input?

My setup (just like yours):
image

The output:
image

@j-conrad
Copy link
Author

j-conrad commented Jun 16, 2021

Something's definitely not quite right, or at least not what the Blender glTF documentation would have me believe.

I replaced the image texture with alpha with a different one I had lying around.

image

And the result of the export:
image

I cannot fathom why the COLOR of that texture with Alpha is being exported at all. Its color output is NOT plugged into anything, only its ALPHA.

The original description of this issue still stands then. It's assuming the color comes from the same source as the alpha, no matter what is mixed into the Mix Shader node.

@scurest
Copy link
Contributor

scurest commented Jun 16, 2021

Yes, the comment julienduroure posted obviously still applies.

Note that that's not the correct setup for alpha, so it wouldn't work even if the above comment were fixed

@aelainelong
Copy link

I cannot fathom why the COLOR of that texture with Alpha is being exported at all. Its color output is NOT plugged into anything, only its ALPHA.

The original description of this issue still stands then. It's assuming the color comes from the same source as the alpha, no matter what is mixed into the Mix Shader node.

Same exact issue I've run into recently. @julienduroure Any thoughts on how difficult this would be to remedy? Or if a fix is even possible given the code comment above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request exporter This involves or affects the export process Material
Projects
None yet
Development

No branches or pull requests

4 participants